markers

package
v0.2.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2019 License: Apache-2.0 Imports: 5 Imported by: 27

Documentation

Overview

Package markers defines markers for generating schema valiation and CRD structure.

All markers related to CRD generation live in AllDefinitions.

Validation Markers

Validation markers have values that imprlement ApplyToSchema (crd.SchemaMarker). Any marker implementing this will automatically be run after the rest of a given schema node has been generated. Markers that need to be run before any other markers can also implement ApplyFirst, but this is discouraged and may change in the future.

All validation markers start with "+kubebuilder:validation", and have the same name as their type name.

CRD Markers

Markers that modify anything in the CRD itself *except* for the schema implement ApplyToCRD (crd.CRDMarker). They are expected to detect whether they should apply themselves to a specific version in the CRD (as passed to them), or to the root-level CRD for legacy cases. They are applied *after* the rest of the CRD is computed.

Misc

This package also defines the "+groupName" and "+versionName" package-level markers, for defining package<->group-version mappings.

Index

Constants

This section is empty.

Variables

View Source
var AllDefinitions []*markers.Definition

AllDefinitions contains all marker definitions for this package.

View Source
var CRDMarkers = []*markers.Definition{
	markers.Must(markers.MakeDefinition("kubebuilder:subresource:status", markers.DescribesType, SubresourceStatus{})),
	markers.Must(markers.MakeDefinition("kubebuilder:subresource:scale", markers.DescribesType, SubresourceScale{})),
	markers.Must(markers.MakeDefinition("kubebuilder:printcolumn", markers.DescribesType, PrintColumn{})),
	markers.Must(markers.MakeDefinition("kubebuilder:resource", markers.DescribesType, Resource{})),
}

CRDMarkers lists all markers that directly modify the CRD (not validation schemas).

View Source
var ValidationMarkers = mustMakeAllWithPrefix("kubebuilder:validation", markers.DescribesField,

	Maximum(0),
	Minimum(0),
	ExclusiveMaximum(false),
	ExclusiveMinimum(false),
	MultipleOf(0),

	MaxLength(0),
	MinLength(0),
	Pattern(""),

	MaxItems(0),
	MinItems(0),
	UniqueItems(false),

	Enum(nil),
	Format(""),
	Type(""),
)

ValidationMarkers lists all available markers that affect CRD schema generation. All markers start with `+kubebuilder:validation:`, and continue with their type name. A copy is produced of all markers that describes types as well, for making types reusable and writing complex validations on slice items.

Functions

func Register

func Register(reg *markers.Registry) error

Register registers all definitions for CRD generation to the given registry.

Types

type Enum

type Enum []interface{}

func (Enum) ApplyToSchema

func (m Enum) ApplyToSchema(schema *v1beta1.JSONSchemaProps) error

type ExclusiveMaximum

type ExclusiveMaximum bool

func (ExclusiveMaximum) ApplyToSchema

func (m ExclusiveMaximum) ApplyToSchema(schema *v1beta1.JSONSchemaProps) error

type ExclusiveMinimum

type ExclusiveMinimum bool

func (ExclusiveMinimum) ApplyToSchema

func (m ExclusiveMinimum) ApplyToSchema(schema *v1beta1.JSONSchemaProps) error

type Format

type Format string

func (Format) ApplyToSchema

func (m Format) ApplyToSchema(schema *v1beta1.JSONSchemaProps) error

type MaxItems

type MaxItems int

func (MaxItems) ApplyToSchema

func (m MaxItems) ApplyToSchema(schema *v1beta1.JSONSchemaProps) error

type MaxLength

type MaxLength int

func (MaxLength) ApplyToSchema

func (m MaxLength) ApplyToSchema(schema *v1beta1.JSONSchemaProps) error

type Maximum

type Maximum int

func (Maximum) ApplyToSchema

func (m Maximum) ApplyToSchema(schema *v1beta1.JSONSchemaProps) error

type MinItems

type MinItems int

func (MinItems) ApplyToSchema

func (m MinItems) ApplyToSchema(schema *v1beta1.JSONSchemaProps) error

type MinLength

type MinLength int

func (MinLength) ApplyToSchema

func (m MinLength) ApplyToSchema(schema *v1beta1.JSONSchemaProps) error

type Minimum

type Minimum int

func (Minimum) ApplyToSchema

func (m Minimum) ApplyToSchema(schema *v1beta1.JSONSchemaProps) error

type MultipleOf

type MultipleOf int

func (MultipleOf) ApplyToSchema

func (m MultipleOf) ApplyToSchema(schema *v1beta1.JSONSchemaProps) error

type Pattern

type Pattern string

func (Pattern) ApplyToSchema

func (m Pattern) ApplyToSchema(schema *v1beta1.JSONSchemaProps) error

type PrintColumn

type PrintColumn struct {
	Name        string
	Type        string
	JSONPath    string `marker:"JSONPath"` // legacy cruft
	Description string `marker:",optional"`
	Format      string `marker:",optional"`
	Priority    int32  `marker:",optional"`
}

PrintColumn defines "+kubebuilder:printcolumn"

func (PrintColumn) ApplyToCRD

func (s PrintColumn) ApplyToCRD(crd *apiext.CustomResourceDefinitionSpec, version string) error

type Resource

type Resource struct {
	Path       string
	ShortName  []string `marker:",optional"`
	Categories []string `marker:",optional"`
	Singular   string   `marker:",optional"`
}

Resource defines "+kubebuilder:resource"

func (Resource) ApplyToCRD

func (s Resource) ApplyToCRD(crd *apiext.CustomResourceDefinitionSpec, version string) error

type SubresourceScale

type SubresourceScale struct {
	// marker names are leftover legacy cruft
	SpecPath     string  `marker:"specpath"`
	StatusPath   string  `marker:"statuspath"`
	SelectorPath *string `marker:"selectorpath"`
}

SubresourceScale defines "+kubebuilder:subresource:scale"

func (SubresourceScale) ApplyToCRD

func (s SubresourceScale) ApplyToCRD(crd *apiext.CustomResourceDefinitionSpec, version string) error

type SubresourceStatus

type SubresourceStatus struct{}

SubresourceStatus defines "+kubebuilder:subresource:status"

func (SubresourceStatus) ApplyToCRD

type Type

type Type string

func (Type) ApplyFirst

func (m Type) ApplyFirst()

func (Type) ApplyToSchema

func (m Type) ApplyToSchema(schema *v1beta1.JSONSchemaProps) error

type UniqueItems

type UniqueItems bool

func (UniqueItems) ApplyToSchema

func (m UniqueItems) ApplyToSchema(schema *v1beta1.JSONSchemaProps) error

Jump to

Keyboard shortcuts

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