crds

package
v0.2.0-beta.21 Latest Latest
Warning

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

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

Documentation

Overview

Package crds reads the CustomResourceDefinition manifests a pinned module ships alongside its Go source: the scope a kind's definition declares, for the types whose own doc comment carries no +kubebuilder:resource marker, and the whole definition, for validating what kure emits against the schema the API server would hold it to.

On scope: upstream's default for an unmarked type is Namespaced, but a parser cannot tell that default apart from a marker it failed to read, and treating the second as the first puts a metadata.namespace on an object that must not carry one. The shipped CRD is not a second guess at the same question: it is controller-gen's own answer, generated from the same source in the same module, and it states the scope explicitly whether or not a marker was needed to produce it.

Only manifests inside the directory or archive named are read. Nothing is fetched, and a module that ships none simply yields no answers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Definition

type Definition struct {
	Path string
	CRD  *apiextensionsv1.CustomResourceDefinition
}

Definition is one CustomResourceDefinition read in full, with the manifest it came from, for the error that names it.

func Archive

func Archive(r io.Reader) ([]Definition, error)

Archive returns every CustomResourceDefinition in the .yaml and .yml entries of a gzip-compressed tar, read as Parse reads a manifest. It is how the vendored Flux toolkit bundle is read without unpacking it.

func Definitions

func Definitions(dir string) ([]Definition, error)

Definitions walks a module directory the way Load does and returns every CustomResourceDefinition it ships, decoded in full. The same selection applies: the same directories are skipped, templates are not read, and a patch fragment is not a definition.

func Parse

func Parse(data []byte, name string) ([]Definition, error)

Parse returns every CustomResourceDefinition in one possibly multi-document manifest, decoded in full; name is what errors call the manifest. Documents that define nothing are passed over as Load passes over them. A definition in a version other than apiextensions.k8s.io/v1 is an error: it cannot be read as the v1 type, and a definition this package cannot read whole is a question it declines rather than answers in part.

type Index

type Index map[string]Scope

Index maps "group/Kind" to the scope the module's own CRD manifests declare.

func Load

func Load(dir string) (Index, error)

Load walks a module directory and indexes every CustomResourceDefinition it ships. An empty dir, or a module shipping no manifests, yields an empty index and no error: not shipping CRDs is ordinary, and the caller decides what to do about a kind it therefore cannot answer for.

Two manifests declaring different scopes for the same group/kind is an error rather than a last-write-wins answer, since which one is authoritative is exactly what this package cannot judge.

type Scope

type Scope string

Scope is the scope a CustomResourceDefinition declares.

const (
	// ScopeNamespaced is spec.scope: Namespaced.
	ScopeNamespaced Scope = "Namespaced"
	// ScopeCluster is spec.scope: Cluster.
	ScopeCluster Scope = "Cluster"
)

Jump to

Keyboard shortcuts

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