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 ¶
- Variables
- func Register(reg *markers.Registry) error
- type Enum
- type ExclusiveMaximum
- type ExclusiveMinimum
- type Format
- type MaxItems
- type MaxLength
- type Maximum
- type MinItems
- type MinLength
- type Minimum
- type MultipleOf
- type Pattern
- type PrintColumn
- type Resource
- type SubresourceScale
- type SubresourceStatus
- type Type
- type UniqueItems
Constants ¶
This section is empty.
Variables ¶
var AllDefinitions []*markers.Definition
AllDefinitions contains all marker definitions for this package.
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).
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 ¶
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 ¶
func (s SubresourceStatus) ApplyToCRD(crd *apiext.CustomResourceDefinitionSpec, version string) error
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