generator

package
v2.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2026 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Overview

Package generator generates language-specific schemas for Crossplane and Kubernetes resources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToJSONSchema added in v2.4.0

func ToJSONSchema(s any, gvk runtimeSchema.GroupVersionKind) (*jsonschema.Schema, error)

ToJSONSchema converts any JSON-compatible schema (e.g., *spec.Schema or *extv1.JSONSchemaProps) to a *jsonschema.Schema with YAML language server compatibility fixes applied. When gvk is non-empty, it also sets $id and x-kubernetes-group-version-kind metadata.

Types

type CRDJSONSchema added in v2.5.0

type CRDJSONSchema struct {
	Data    []byte
	Group   string
	Version string
	Kind    string
}

CRDJSONSchema holds a marshaled JSON Schema derived from a single CRD version.

func CRDsToJSONSchemas added in v2.5.0

func CRDsToJSONSchemas(crds []*extv1.CustomResourceDefinition) ([]CRDJSONSchema, error)

CRDsToJSONSchemas converts CRD OpenAPI v3 schemas to marshaled JSON Schemas.

type Interface

type Interface interface {
	Language() string
	GenerateFromCRD(ctx context.Context, fs afero.Fs, runner runner.SchemaRunner) (afero.Fs, error)
	GenerateFromOpenAPI(ctx context.Context, fs afero.Fs, runner runner.SchemaRunner) (afero.Fs, error)
}

Interface generates schemas for a specific language.

func AllLanguages

func AllLanguages(opts ...Option) []Interface

AllLanguages returns generators for all supported languages. The set of supported language identifiers is defined by devv1alpha1.SupportedSchemaLanguages.

func Filter added in v2.4.0

func Filter(all []Interface, langs []string) []Interface

Filter returns the subset of generators whose language identifier appears in langs. The order of generators in the result matches the order of all. If langs is empty, all generators are returned unchanged.

type Option added in v2.5.0

type Option func(*options)

Option configures the generators returned by AllLanguages.

func WithGoModelAccessors added in v2.5.0

func WithGoModelAccessors(enabled bool) Option

WithGoModelAccessors enables generation of GetX/SetX accessor methods on the generated Go models. It is disabled by default and gated behind the features.generateGoModelAccessors config flag.

func WithGoRuntimeObjects added in v2.5.0

func WithGoRuntimeObjects(enabled bool) Option

WithGoRuntimeObjects enables generation of runtime.Object methods (DeepCopy, GetObjectKind, DeepCopyObject) and per-package AddToScheme helpers on the generated Go models. Disabled by default; gated behind the features.generateGoRuntimeObjects config flag.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL