codegen

package
v0.17.8 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResourceProperties added in v0.14.0

type APIResourceProperties struct {
	Group string `json:"group"`
	Scope string `json:"scope"`
}

APIResourceProperties contains information about a Kind expressible as a kubernetes API resource

type AnyKind added in v0.14.0

type AnyKind struct {
	Props       KindProperties
	AllVersions []KindVersion
}

AnyKind is a simple implementation of Kind

func (*AnyKind) Name added in v0.14.0

func (a *AnyKind) Name() string

func (*AnyKind) Properties added in v0.14.0

func (a *AnyKind) Properties() KindProperties

func (*AnyKind) Version added in v0.14.0

func (a *AnyKind) Version(v string) *KindVersion

func (*AnyKind) Versions added in v0.14.0

func (a *AnyKind) Versions() []KindVersion

type Generator

type Generator[T any] struct {
	// contains filtered or unexported fields
}

func NewGenerator added in v0.14.0

func NewGenerator[T any](parser Parser[T], files fs.FS) (*Generator[T], error)

func (*Generator[T]) FilteredGenerate added in v0.14.0

func (g *Generator[T]) FilteredGenerate(jennies JennyList[T], filterFunc func(T) bool, selectors ...string) (codejen.Files, error)

func (*Generator[T]) Generate

func (g *Generator[T]) Generate(jennies JennyList[T], selectors ...string) (codejen.Files, error)

type JennyList added in v0.14.0

type JennyList[T any] interface {
	Generate(...T) (codejen.Files, error)
}

type Kind added in v0.14.0

type Kind interface {
	Name() string
	Properties() KindProperties
	Versions() []KindVersion
	Version(version string) *KindVersion
}

Kind is a common interface declaration for code generation. Any type parser should be able to parse a kind into this definition to supply to various common Jennies in the codegen package.

type KindCodegenProperties added in v0.14.0

type KindCodegenProperties struct {
	Frontend bool `json:"frontend"`
	Backend  bool `json:"backend"`
}

KindCodegenProperties contains code generation directives for a Kind or KindVersion

type KindProperties added in v0.14.0

type KindProperties struct {
	// Kind is the unique-within-the-group name of the kind
	Kind string `json:"kind"`
	// Group is the group the Kind is a part of
	Group string `json:"group"`
	// MachineName is the machine version of the Kind, which follows the regex: /^[a-z]+[a-z0-9]*$/
	MachineName string `json:"machineName"`
	// PluralMachineName is the plural of the MachineName
	PluralMachineName string `json:"pluralMachineName"`
	// PluralName is the plural of the Kind
	PluralName string `json:"pluralName"`
	// Current is the version string of the version considered to be "current".
	// This does not have to be the latest, but determines preference when generating code.
	Current string `json:"current"`
	// APIResource is an optional field which, if present, indicates that the Kind is expressible as a kubernetes API resource,
	// and contains attributes which allow identification as such.
	APIResource *APIResourceProperties `json:"apiResource"`
	// Codegen contains code-generation directives for the codegen pipeline
	Codegen KindCodegenProperties `json:"codegen"`
}

KindProperties is the collection of properties for a Kind which are used for code generation

type KindVersion added in v0.14.0

type KindVersion struct {
	Version string `json:"version"`
	// Schema is the CUE schema for the version
	// This should eventually be changed to JSONSchema/OpenAPI(/AST?)
	Schema  cue.Value             `json:"schema"` // TODO: this should eventually be OpenAPI/JSONSchema (ast or bytes?)
	Codegen KindCodegenProperties `json:"codegen"`
	Served  bool                  `json:"served"`
}

type Parser added in v0.14.0

type Parser[T any] interface {
	Parse(fs.FS, ...string) ([]T, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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