Help us shape the future of Go! Take the 2026 Go Developer Survey

generator

package
v0.0.1-test Latest Latest
Warning

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

Go to latest
Published: Sep 10, 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

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

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

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

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

type Option func(*options)

Option configures the generators returned by AllLanguages.

func WithGoModelAccessors

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

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