Documentation ¶
Index ¶
- Constants
- func BackendPluginMainGenerator(projectRepo, apiCodegenPath string, generatedKindsAreVersioned bool) codejen.ManyToOne[codegen.Kind]
- func CRDGenerator(encoder CRDOutputEncoder, extension string) codejen.OneToOne[codegen.Kind]
- func CUEToCRDOpenAPI(v cue.Value, name, version string) (map[string]any, error)
- func CUEValueToOAPIYAML(val cue.Value, cfg CUEOpenAPIConfig) ([]byte, error)
- func CUEValueToOpenAPI(val cue.Value, cfg CUEOpenAPIConfig) (*ast.File, error)
- func CUEValueToString(v cue.Value) string
- func GoTypesFromCUE(v cue.Value, cfg CUEGoConfig, maxNamingDepth int) ([]byte, error)
- func KindVersionToCRDSpecVersion(kv codegen.KindVersion, kindName string, stored bool) (k8s.CustomResourceDefinitionSpecVersion, error)
- func OperatorMainJenny(projectRepo, codegenPath string, generatedKindsAreVersioned bool) codejen.ManyToOne[codegen.Kind]
- func RouterCodeGenerator(projectRepo string) codejen.ManyToOne[codegen.Kind]
- func RouterHandlerCodeGenerator(projectRepo, apiCodegenPath string, generatedKindsAreVersioned bool) codejen.OneToOne[codegen.Kind]
- func SelEq(s1, s2 cue.Selector) bool
- func StaticManyToOneGenerator[Input any](file codejen.File) codejen.ManyToOne[Input]
- func ToPackageName(input string) string
- func TrimPathPrefix(path, prefix cue.Path) cue.Path
- func WatcherJenny(projectRepo, codegenPath string, generatedKindsAreVersioned bool) codejen.OneToOne[codegen.Kind]
- type CRDOutputEncoder
- type CUEGoConfig
- type CUEOpenAPIConfig
- type CodecGenerator
- type GoTypes
- type OperatorConfigJenny
- type OperatorKubeConfigJenny
- type ResourceObjectGenerator
- type SchemaGenerator
- type TypeScriptResourceTypes
- type TypeScriptTypes
Constants ¶
const GoTypesMaxDepth = 5
Variables ¶
This section is empty.
Functions ¶
func BackendPluginMainGenerator ¶
func BackendPluginMainGenerator(projectRepo, apiCodegenPath string, generatedKindsAreVersioned bool) codejen.ManyToOne[codegen.Kind]
BackendPluginMainGenerator returns a many-to-one jenny which generates the `main.go` file needed to run the backend plugin.
func CRDGenerator ¶
func CUEToCRDOpenAPI ¶
func CUEValueToOAPIYAML ¶
func CUEValueToOAPIYAML(val cue.Value, cfg CUEOpenAPIConfig) ([]byte, error)
func CUEValueToOpenAPI ¶
CUEValueToOpenAPI converts a cue.Value into an OpenAPI ast.File
func CUEValueToString ¶
CUEValueToString returns a formatted string output of a cue.Value. This is a more detailed string than using fmt.Println(v), as it will include optional fields and definitions.
func GoTypesFromCUE ¶
func KindVersionToCRDSpecVersion ¶
func KindVersionToCRDSpecVersion(kv codegen.KindVersion, kindName string, stored bool) (k8s.CustomResourceDefinitionSpecVersion, error)
func OperatorMainJenny ¶
func RouterCodeGenerator ¶
func SelEq ¶
SelEq indicates whether two selectors are equivalent. Selectors are equivalent if they are either exactly equal, or if they are equal ignoring path optionality.
func ToPackageName ¶
ToPackageName sanitizes an input into a deterministic allowed go package name. It is used to turn kind names or versions into package names when performing go code generation.
Types ¶
type CRDOutputEncoder ¶
CRDOutputEncoder is a function which marshals an object into a desired output format
type CUEGoConfig ¶
type CUEGoConfig struct { PackageName string Name string Version string IgnoreDiscoveredImports bool // ApplyFuncs is a slice of AST manipulation funcs that will be executed against // the generated Go file prior to running it through goimports. For each slice // element, [dstutil.Apply] is called with the element as the "pre" parameter. ApplyFuncs []dstutil.ApplyFunc // UseGoDeclInComments sets the name of the fields and structs at the beginning of each comment. UseGoDeclInComments bool }
type CUEOpenAPIConfig ¶
type CodecGenerator ¶ added in v0.15.0
type CodecGenerator struct { // This flag exists for compatibility with thema codegen, which only generates code for the current/latest version of the kind OnlyUseCurrentVersion bool }
func (*CodecGenerator) Generate ¶ added in v0.15.0
Generate creates one or more codec go files for the provided Kind nolint:dupl
func (*CodecGenerator) JennyName ¶ added in v0.15.0
func (*CodecGenerator) JennyName() string
type GoTypes ¶
type GoTypes struct { // GenerateOnlyCurrent should be set to true if you only want to generate code for the kind.Properties().Current version. // This will affect the package and path(s) of the generated file(s). GenerateOnlyCurrent bool // Depth represents the tree depth for creating go types from fields. A Depth of 0 will return one go type // (plus any definitions used by that type), a Depth of 1 will return a file with a go type for each top-level field // (plus any definitions encompassed by each type), etc. Note that types are _not_ generated for fields above the Depth // level--i.e. a Depth of 1 will generate go types for each field within the KindVersion.Schema, but not a type for the // Schema itself. Because Depth results in recursive calls, the highest value is bound to a max of GoTypesMaxDepth. Depth int // NamingDepth determines how types are named in relation to Depth. If Depth <= NamingDepth, the go types are named // using the field name of the type. Otherwise, Names used are prefixed by field names between Depth and NamingDepth. // Typically, a value of 0 is "safest" for NamingDepth, as it prevents overlapping names for types. // However, if you know that your fields have unique names up to a certain depth, you may configure this to be higher. NamingDepth int }
GoTypes is a Jenny for turning a codegen.Kind into go types according to its codegen settings.
type OperatorConfigJenny ¶
type OperatorConfigJenny struct { }
func (*OperatorConfigJenny) JennyName ¶
func (*OperatorConfigJenny) JennyName() string
type OperatorKubeConfigJenny ¶
type OperatorKubeConfigJenny struct { }
func (*OperatorKubeConfigJenny) JennyName ¶
func (*OperatorKubeConfigJenny) JennyName() string
type ResourceObjectGenerator ¶
type ResourceObjectGenerator struct { // This flag exists for compatibility with thema codegen, which only generates code for the current/latest version of the kind OnlyUseCurrentVersion bool }
func (*ResourceObjectGenerator) JennyName ¶
func (*ResourceObjectGenerator) JennyName() string
type SchemaGenerator ¶
type SchemaGenerator struct { // This flag exists for compatibility with thema codegen, which only generates code for the current/latest version of the kind OnlyUseCurrentVersion bool }
func (*SchemaGenerator) Generate ¶
Generate creates one or more schema go files for the provided Kind nolint:dupl
func (*SchemaGenerator) JennyName ¶
func (*SchemaGenerator) JennyName() string
type TypeScriptResourceTypes ¶ added in v0.15.0
type TypeScriptResourceTypes struct {
GenerateOnlyCurrent bool
}
func (*TypeScriptResourceTypes) JennyName ¶ added in v0.15.0
func (*TypeScriptResourceTypes) JennyName() string
type TypeScriptTypes ¶
type TypeScriptTypes struct { // GenerateOnlyCurrent should be set to true if you only want to generate code for the kind.Properties().Current version. // This will affect the package and path(s) of the generated file(s). GenerateOnlyCurrent bool // Depth represents the tree depth for creating go types from fields. A Depth of 0 will return one go type // (plus any definitions used by that type), a Depth of 1 will return a file with a go type for each top-level field // (plus any definitions encompassed by each type), etc. Note that types are _not_ generated for fields above the Depth // level--i.e. a Depth of 1 will generate go types for each field within the KindVersion.Schema, but not a type for the // Schema itself. Because Depth results in recursive calls, the highest value is bound to a max of GoTypesMaxDepth. Depth int // NamingDepth determines how types are named in relation to Depth. If Depth <= NamingDepth, the go types are named // using the field name of the type. Otherwise, Names used are prefixed by field names between Depth and NamingDepth. // Typically, a value of 0 is "safest" for NamingDepth, as it prevents overlapping names for types. // However, if you know that your fields have unique names up to a certain depth, you may configure this to be higher. NamingDepth int }
TypeScriptTypes is a one-to-many jenny that generates one or more TypeScript types for a kind. Each type is a specific version of the kind where codegen.frontend is true. If GenerateOnlyCurrent is true, then all other versions of the kind will be ignored and only the kind.Propertoes().Current version will be used for TypeScript type generation (this will impact the generated file path).
func (TypeScriptTypes) JennyName ¶
func (TypeScriptTypes) JennyName() string