flux-schema

module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: Apache-2.0

README

flux-schema

release test cve-scan license slsa

Flux CLI plugin for Kubernetes schema extraction and manifests validation.

[!NOTE] This repository is in early development and the plugin system is not yet available in a stable release of Flux. The instructions for installing and using the plugin will be added here when RFC-0013 has been implemented and released in Flux 2.9 or later.

Available Commands

flux-schema extract

The extract command reads Kubernetes CustomResourceDefinition YAML and writes one JSON Schema file per CRD version. The input can be a bare CRD, a List of CRDs, or a multi-document YAML stream.

Generate schemas for every CRD installed in a cluster:

kubectl get crds -o yaml > crds.yaml
flux-schema extract crds.yaml -d ./schemas

By default, files are named {{ .Kind }}-{{ .GroupPrefix }}-{{ .Version }}.json. The output is compatible with kubeconform and kubeval, making this command a drop-in replacement for kubeconform's openapi2jsonschema.py script.

Note that the generated schemas apply the following OpenAPI → JSON Schema transformations:

  • Objects with properties are closed with additionalProperties: false, except under nodes marked with x-kubernetes-preserve-unknown-fields: true, which stay open so free-form maps validate correctly.
  • Integer-or-string fields are rewritten to oneOf: [{type: string}, {type: integer}]. Both the legacy format: int-or-string and the structural x-kubernetes-int-or-string: true forms are recognized.

You can supply --output-format with a Go template to change the layout, e.g. the CRDs-catalog per-group-directory layout:

flux-schema extract crds.yaml \
  --output-format '{{ .Group }}/{{ .Kind }}_{{ .Version }}.json'

Template variables (all lowercased at render time):

Variable Example
.Group source.toolkit.fluxcd.io
.GroupPrefix source
.Kind gitrepository
.Version v1

Nested directories referenced by --output-format are created automatically.

Directories

Path Synopsis
cmd
flux-schema command
internal
extractor
Package extractor converts Kubernetes CustomResourceDefinition YAML into per-version JSON Schema documents.
Package extractor converts Kubernetes CustomResourceDefinition YAML into per-version JSON Schema documents.
tmpl
Package tmpl renders Go text/template strings with the CRD schema variables shared across flux-schema commands.
Package tmpl renders Go text/template strings with the CRD schema variables shared across flux-schema commands.

Jump to

Keyboard shortcuts

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