Documentation
¶
Overview ¶
pkg/generat/crd_generator.go
CRD generator — derives a CustomResourceDefinition from a Katalog.
The Katalog is the single source of truth. Everything needed to produce a valid CRD is already declared:
apiTypes → group, version, kind, plural, scope
validation → required fields (deny rules with operator: exists)
mutation → optional fields with defaults + type inference
template exprs → additional spec fields referenced as {{ .spec.* }}
status.fields → status subresource schema + printer columns
conversion → webhook config (when conversion paths are declared)
Usage:
gen := generator.NewCRDGenerator(katalogEntry) crd, err := gen.Generate() yaml.NewEncoder(os.Stdout).Encode(crd)
CLI:
ork generate crd --katalog katalog.yaml -o crd.yaml
pkg/generate/helper.go
pkg/generate/registry_generator.go
Index ¶
- Constants
- func Bundle(kfg *konfig.Konfig, rules []rbacv1.PolicyRule, namespace, outputFile string) error
- func ConfigMap(inputFile, namespace, outputFile string) error
- func Dashboards(c []orktypes.CRDEntry, dryRun bool) error
- func Docs(c []orktypes.CRDEntry, dryRun bool) error
- func RBAC(kfg *konfig.Konfig, rules []rbacv1.PolicyRule, namespace, outputFile string) error
- func RenderConfigMapToString(inputFile, namespace string) (string, error)
- func RenderRBACToString(kfg *konfig.Konfig, rules []rbacv1.PolicyRule, namespace string) (string, error)
- func Runtime(m *merger.Merger, dryRun bool) error
- type CRDGenerator
- type CRDMeta
- type CRGenerator
- type DashboardTemplateData
- type DocsTemplateData
Constants ¶
const ( // RuntimePackage is the fixed output directory for all generated runtime files. // Both the registry and declarative hook implementations are written here. // The Orkestra runtime imports this package directly. RuntimePackage = "pkg/runtime" // RegistryFile is the generated file containing: // - ObjectRegistry // - ListRegistry // - HookRegistry // - ReconcilerRegistry // - RegisterScheme() // // It is regenerated on every `ork generate registry` invocation. RegistryFile = "zz_generated_runtime_registry.go" // ExamplesDir is the output directory for generated example manifests. // Each CRD receives a minimal example YAML manifest for onboarding and testing. ExamplesDir = "_runtime/examples" // DocsDir is the output directory for generated Markdown documentation. // Includes per-CRD docs, an index, and dependency graph documentation. DocsDir = "_runtime/docs" // TestDir is the output directory for generated test scaffolding. // Contains unit test stubs and integration test templates for each CRD. TestDir = "_runtime/test" // DashDir is the output directory for generated Grafana dashboards. // Each CRD receives a dashboard JSON file with metrics panels. DashDir = "_runtime/dashboards" )
Variables ¶
This section is empty.
Functions ¶
func RenderConfigMapToString ¶
func RenderRBACToString ¶
func Runtime ¶
Runtime generates zz_generated_runtime_registry.go from the merged Katalog.
When generation is needed (and why):
Typed CRDs (apiTypes.location set) The compiled Go type must be registered so the informer and REST client can decode API server responses. Without this, List/Watch calls fail with "not suitable for converting" errors. Go hooks (reconciler.hooks declared) The hook function lives in an external package. The generator writes the import and wires it into HookRegistry so addHooks() can find it. Custom constructors (reconciler.default: false) Same as Go hooks — external function needs import and ReconcilerRegistry entry.
When generation is NOT needed:
Dynamic template CRDs (only onCreate/onReconcile/onDelete declared) GenericReconciler.runTemplateReconcile() reads the Katalog's operatorBox:Config directly at runtime and calls the OrkestraRegistry functions itself. No generated file. No ork generate registry. Just ork run.
Types ¶
type CRDGenerator ¶
type CRDGenerator struct {
// contains filtered or unexported fields
}
CRDGenerator produces a CRD from a CRDEntry.
func NewCRDGenerator ¶
func NewCRDGenerator(crd orktypes.CRDEntry) *CRDGenerator
NewCRDGenerator creates a generator for one CRD entry.
func (*CRDGenerator) Generate ¶
func (g *CRDGenerator) Generate() (*apiextv1.CustomResourceDefinition, error)
Generate produces the complete CRD object.
type CRDMeta ¶
type CRDMeta struct {
Name string
Description string
Group string
Version string
Kind string
Plural string
Namespaced bool
Namespace string
Workers int
Resync string
DependsOn []string
Reconciler struct {
Default bool
Function string // for custom reconcilers
}
Queue struct {
MaxQueueDepth int
Default bool
}
API struct {
Object string
List string
Alias string
Import string
}
}
Docs and dashboards
type CRGenerator ¶
type CRGenerator struct {
// contains filtered or unexported fields
}
CRGenerator produces an example CR from a CRDEntry.
func NewCRGenerator ¶
func NewCRGenerator(crd orktypes.CRDEntry) *CRGenerator
NewCRGenerator creates a CR generator for one CRD entry.
func (*CRGenerator) Generate ¶
func (g *CRGenerator) Generate() map[string]interface{}
Generate produces an example CR as a plain map (ready for YAML encoding). Required fields are filled with typed placeholders. Optional fields show their default values.