Documentation
¶
Overview ¶
Command schema-gen turns a controller-gen CRD schema into a standalone JSON Schema (draft 2020-12) for a source-watcher KRM-style configuration type.
It generates a throwaway wrapper package that embeds the target API type in an apiVersion/kind/metadata envelope (so controller-gen treats it as a CRD kind), renders it with controller-gen, then strips the ObjectMeta metadata and stamps the apiVersion/kind consts into the resulting schema. The wrapper carries metav1.ObjectMeta so the API types themselves stay clean (TypeMeta only).
Three wrapping modes are supported:
- Named-field mode (-field set): the API type is placed under a single JSON field, e.g. {apiVersion, kind, report: <ReportSpec>}.
- Inline mode (-field and -metadata unset): the API type is embedded inline so its fields sit at the root.
- Metadata mode (-metadata set): the API type is placed under the root metadata field, for KRM-style configuration objects whose metadata carries the configuration rather than ObjectMeta. controller-gen special-cases a field literally named metadata, so the wrapper uses a placeholder field that is renamed back to metadata when rewriting the root schema.
Click to show internal directories.
Click to hide internal directories.