Documentation ¶
Index ¶
- Variables
- func GetBackendPluginSecurePackageFiles() (map[string][]byte, error)
- func ToPackageName(input string) string
- func WriteAppGoFile(metadata AppMetadata, out io.Writer) error
- func WriteBackendPluginHandler(metadata BackendPluginHandlerTemplateMetadata, out io.Writer) error
- func WriteBackendPluginMain(metadata BackendPluginRouterTemplateMetadata, out io.Writer) error
- func WriteBackendPluginRouter(metadata BackendPluginRouterTemplateMetadata, out io.Writer) error
- func WriteCodec(metadata SchemaMetadata, out io.Writer) error
- func WriteLineageGo(metadata LineageMetadata, out io.Writer) error
- func WriteManifestGoFile(metadata ManifestGoFileMetadata, out io.Writer) error
- func WriteOperatorConfig(out io.Writer) error
- func WriteOperatorKubeConfig(out io.Writer) error
- func WriteOperatorMain(metadata OperatorMainMetadata, out io.Writer) error
- func WriteResourceObject(metadata ResourceObjectTemplateMetadata, out io.Writer) error
- func WriteResourceTSType(metadata ResourceTSTemplateMetadata, out io.Writer) error
- func WriteSchema(metadata SchemaMetadata, out io.Writer) error
- func WriteThemaCodec(metadata ResourceObjectTemplateMetadata, out io.Writer) error
- func WriteWatcher(metadata WatcherMetadata, out io.Writer) error
- func WriteWrappedType(metadata WrappedTypeMetadata, out io.Writer) error
- type AppMetadata
- type AppMetadataKind
- type BackendPluginHandlerTemplateMetadata
- type BackendPluginRouterTemplateMetadata
- type CustomMetadataFieldGoType
- type LineageMetadata
- type ManifestGoFileMetadata
- type ObjectMetadataField
- type OperatorMainMetadata
- type ResourceObjectTemplateMetadata
- type ResourceTSTemplateMetadata
- type SchemaMetadata
- type SchemaMetadataSeletableField
- type SubresourceMetadata
- type WatcherMetadata
- type WrappedTypeMetadata
Constants ¶
This section is empty.
Variables ¶
var ( // GoTypeString is a CustomMetadataFieldGoType for "string" go types GoTypeString = CustomMetadataFieldGoType{ GoType: "string", SetFuncTemplate: func(inputVarName string, setToVarName string) string { return fmt.Sprintf("%s = %s", setToVarName, inputVarName) }, GetFuncTemplate: func(varName string) string { return fmt.Sprintf("return %s", varName) }, } // GoTypeInt is a CustomMetadataFieldGoType for "int" go types GoTypeInt = CustomMetadataFieldGoType{ GoType: "int", SetFuncTemplate: func(inputVarName string, setToVarName string) string { return fmt.Sprintf("%s = strconv.Itoa(%s)", setToVarName, inputVarName) }, GetFuncTemplate: func(varName string) string { return fmt.Sprintf("i, _ := strconv.Atoi(%s)\nreturn i", varName) }, AdditionalImports: []string{"strconv"}, } // GoTypeTime is a CustomMetadataFieldGoType for "time.Time" go types GoTypeTime = CustomMetadataFieldGoType{ GoType: "time.Time", SetFuncTemplate: func(inputVarName string, setToVarName string) string { return fmt.Sprintf("%s = %s.Format(time.RFC3339)", setToVarName, inputVarName) }, GetFuncTemplate: func(varName string) string { return fmt.Sprintf("parsed, _ := time.Parse(time.RFC3339, %s)\nreturn parsed", varName) }, AdditionalImports: []string{"time"}, } )
Functions ¶
func GetBackendPluginSecurePackageFiles ¶
GetBackendPluginSecurePackageFiles returns go files for the `secure` package in the backend plugin, as a map of <filename> (without "secure" in path) => contents
func ToPackageName ¶ added in v0.14.0
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.
func WriteAppGoFile ¶ added in v0.23.0
func WriteAppGoFile(metadata AppMetadata, out io.Writer) error
func WriteBackendPluginHandler ¶
func WriteBackendPluginHandler(metadata BackendPluginHandlerTemplateMetadata, out io.Writer) error
WriteBackendPluginHandler executes the Backend Plugin Handler template, and writes out the generated go code to out
func WriteBackendPluginMain ¶
func WriteBackendPluginMain(metadata BackendPluginRouterTemplateMetadata, out io.Writer) error
WriteBackendPluginMain executes the Backend Plugin Main template, and writes out the generated go code to out
func WriteBackendPluginRouter ¶
func WriteBackendPluginRouter(metadata BackendPluginRouterTemplateMetadata, out io.Writer) error
WriteBackendPluginRouter executes the Backend Plugin Router template, and writes out the generated go code to out
func WriteCodec ¶ added in v0.15.0
func WriteCodec(metadata SchemaMetadata, out io.Writer) error
WriteCodec executes the Generic Resource Codec template, and writes out the generated go code to out
func WriteLineageGo ¶
func WriteLineageGo(metadata LineageMetadata, out io.Writer) error
WriteLineageGo executes the lineage go template, and writes out the generated go code to out
func WriteManifestGoFile ¶ added in v0.20.0
func WriteManifestGoFile(metadata ManifestGoFileMetadata, out io.Writer) error
func WriteOperatorConfig ¶ added in v0.11.0
func WriteOperatorKubeConfig ¶
func WriteOperatorMain ¶
func WriteOperatorMain(metadata OperatorMainMetadata, out io.Writer) error
func WriteResourceObject ¶
func WriteResourceObject(metadata ResourceObjectTemplateMetadata, out io.Writer) error
WriteResourceObject executes the Resource Object template, and writes out the generated go code to out
func WriteResourceTSType ¶ added in v0.15.0
func WriteResourceTSType(metadata ResourceTSTemplateMetadata, out io.Writer) error
func WriteSchema ¶
func WriteSchema(metadata SchemaMetadata, out io.Writer) error
WriteSchema executes the Resource Schema template, and writes out the generated go code to out
func WriteThemaCodec ¶ added in v0.15.0
func WriteThemaCodec(metadata ResourceObjectTemplateMetadata, out io.Writer) error
WriteThemaCodec executes the Thema-specific Codec template, and writes out the generated go code to out
func WriteWatcher ¶
func WriteWatcher(metadata WatcherMetadata, out io.Writer) error
func WriteWrappedType ¶
func WriteWrappedType(metadata WrappedTypeMetadata, out io.Writer) error
WriteWrappedType executes the wrappedtype go template, and writes out the generated go code to out
Types ¶
type AppMetadata ¶ added in v0.23.0
type AppMetadata struct { PackageName string ProjectName string Repo string CodegenPath string WatcherPackage string KindsAreGrouped bool Resources []AppMetadataKind }
func (AppMetadata) ToPackageName ¶ added in v0.23.0
func (AppMetadata) ToPackageName(input string) string
func (AppMetadata) ToPackageNameVariable ¶ added in v0.23.0
func (AppMetadata) ToPackageNameVariable(input string) string
type AppMetadataKind ¶ added in v0.23.0
type AppMetadataKind struct { codegen.KindProperties Versions []string }
type BackendPluginHandlerTemplateMetadata ¶
type BackendPluginHandlerTemplateMetadata struct { codegen.KindProperties Repo string APICodegenPath string TypeName string IsResource bool Version string KindPackage string KindsAreGrouped bool }
BackendPluginHandlerTemplateMetadata is the metadata required by the Backend Plugin Handler template
func (BackendPluginHandlerTemplateMetadata) ToPackageName ¶ added in v0.14.0
func (BackendPluginHandlerTemplateMetadata) ToPackageName(input string) string
type BackendPluginRouterTemplateMetadata ¶
type BackendPluginRouterTemplateMetadata struct { Repo string APICodegenPath string Resources []codegen.KindProperties PluginID string KindsAreGrouped bool }
BackendPluginRouterTemplateMetadata is the metadata required by the Backend Plugin Router template
func (BackendPluginRouterTemplateMetadata) ToPackageName ¶ added in v0.14.0
func (BackendPluginRouterTemplateMetadata) ToPackageName(input string) string
func (BackendPluginRouterTemplateMetadata) ToPackageNameVariable ¶ added in v0.16.0
func (BackendPluginRouterTemplateMetadata) ToPackageNameVariable(input string) string
type CustomMetadataFieldGoType ¶ added in v0.15.0
type CustomMetadataFieldGoType struct { // GoType is the type string (ex. "string", "time.Time") GoType string // SetFuncTemplate should return a go template string that sets the value. // inputVarName is the name of the variable in the SetX function (which has type of GoType), // and setToVarName is the name of the string-type variable which it must be set to SetFuncTemplate func(inputVarName string, setToVarName string) string // GetFuncTemplate should return a go template string that gets the value as the appropriate go type. // fromStringVarName is the string-type variable name which the value is currently stored as GetFuncTemplate func(fromStringVarName string) string // AdditionalImports is a list of any additional imports needed for the Get/Set functions or type (such as "time") AdditionalImports []string }
CustomMetadataFieldGoType is a struct that contains information and codegen functions for a Go type which needs setters and getters in a resource.Object implementation TODO: do we need the approach to be this generic/is there a less-confusing way to implement this?
type LineageMetadata ¶
type LineageMetadata struct { Package string TypeName string CUEFile string CUESelector string SchemaPackagePath string SchemaPackageName string ObjectTypeName string Subresources []SubresourceMetadata }
LineageMetadata is the metadata required by the lineage go code template
type ManifestGoFileMetadata ¶ added in v0.20.0
type ManifestGoFileMetadata struct { Package string ManifestData app.ManifestData }
func (ManifestGoFileMetadata) ToAdmissionOperationName ¶ added in v0.20.0
func (ManifestGoFileMetadata) ToAdmissionOperationName(input app.AdmissionOperation) string
func (ManifestGoFileMetadata) ToJSONBacktickString ¶ added in v0.23.0
func (ManifestGoFileMetadata) ToJSONBacktickString(input any) string
func (ManifestGoFileMetadata) ToJSONString ¶ added in v0.23.0
func (ManifestGoFileMetadata) ToJSONString(input any) string
func (ManifestGoFileMetadata) ToPackageName ¶ added in v0.23.0
func (ManifestGoFileMetadata) ToPackageName(input string) string
type ObjectMetadataField ¶
type ObjectMetadataField struct { JSONName string FieldName string GoType CustomMetadataFieldGoType }
type OperatorMainMetadata ¶
type OperatorMainMetadata struct { PackageName string ProjectName string Repo string CodegenPath string WatcherPackage string KindsAreGrouped bool Resources []codegen.KindProperties }
func (OperatorMainMetadata) ToPackageName ¶ added in v0.14.0
func (OperatorMainMetadata) ToPackageName(input string) string
func (OperatorMainMetadata) ToPackageNameVariable ¶ added in v0.16.0
func (OperatorMainMetadata) ToPackageNameVariable(input string) string
type ResourceObjectTemplateMetadata ¶
type ResourceObjectTemplateMetadata struct { Package string TypeName string SpecTypeName string ObjectTypeName string ObjectShortName string Subresources []SubresourceMetadata CustomMetadataFields []ObjectMetadataField }
ResourceObjectTemplateMetadata is the metadata required by the Resource Object template
type ResourceTSTemplateMetadata ¶ added in v0.15.0
type ResourceTSTemplateMetadata struct { TypeName string FilePrefix string Subresources []SubresourceMetadata }
type SchemaMetadata ¶
type SchemaMetadata struct { Package string Group string Version string Kind string Plural string Scope string SelectableFields []SchemaMetadataSeletableField FuncPrefix string }
SchemaMetadata is the metadata required by the Resource Schema template
func (SchemaMetadata) ToObjectPath ¶ added in v0.18.2
func (SchemaMetadata) ToObjectPath(s string) string
type SchemaMetadataSeletableField ¶ added in v0.21.0
type SubresourceMetadata ¶
SubresourceMetadata is subresource information used in templates
type WatcherMetadata ¶
type WatcherMetadata struct { codegen.KindProperties PackageName string Repo string CodegenPath string Version string KindPackage string KindsAreGrouped bool }
func (WatcherMetadata) ToPackageName ¶ added in v0.14.0
func (WatcherMetadata) ToPackageName(input string) string