schema-gen

command
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

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.

Jump to

Keyboard shortcuts

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