markers

package
v0.16.5 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: Apache-2.0 Imports: 7 Imported by: 28

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 implement 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. It is recommended to implement the ApplyPriority interface in combination with ApplyPriorityDefault and ApplyPriorityFirst constants. Following is an example of how to implement such a marker:

type MyCustomMarker string

func (m MyCustomMarker) ApplyPriority() ApplyPriority {
	return ApplyPriorityFirst
}

func (m MyCustomMarker) ApplyToSchema(schema *apiext.JSONSchemaProps) error {
  ...
}

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.SpecMarker). 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

View Source
const (
	SchemalessName        = "kubebuilder:validation:Schemaless"
	ValidationItemsPrefix = validationPrefix + "items:"
)

Variables

View Source
var AllDefinitions []*definitionWithHelp

AllDefinitions contains all marker definitions for this package.

View Source
var CRDMarkers = []*definitionWithHelp{

	must(markers.MakeDefinition("kubebuilder:subresource:status", markers.DescribesType, SubresourceStatus{})).
		WithHelp(SubresourceStatus{}.Help()),

	must(markers.MakeDefinition("kubebuilder:subresource:scale", markers.DescribesType, SubresourceScale{})).
		WithHelp(SubresourceScale{}.Help()),

	must(markers.MakeDefinition("kubebuilder:printcolumn", markers.DescribesType, PrintColumn{})).
		WithHelp(PrintColumn{}.Help()),

	must(markers.MakeDefinition("kubebuilder:resource", markers.DescribesType, Resource{})).
		WithHelp(Resource{}.Help()),

	must(markers.MakeDefinition("kubebuilder:storageversion", markers.DescribesType, StorageVersion{})).
		WithHelp(StorageVersion{}.Help()),

	must(markers.MakeDefinition("kubebuilder:skipversion", markers.DescribesType, SkipVersion{})).
		WithHelp(SkipVersion{}.Help()),

	must(markers.MakeDefinition("kubebuilder:unservedversion", markers.DescribesType, UnservedVersion{})).
		WithHelp(UnservedVersion{}.Help()),

	must(markers.MakeDefinition("kubebuilder:deprecatedversion", markers.DescribesType, DeprecatedVersion{})).
		WithHelp(DeprecatedVersion{}.Help()),

	must(markers.MakeDefinition("kubebuilder:metadata", markers.DescribesType, Metadata{})).
		WithHelp(Metadata{}.Help()),

	must(markers.MakeDefinition("kubebuilder:selectablefield", markers.DescribesType, SelectableField{})).
		WithHelp(SelectableField{}.Help()),
}

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

View Source
var FieldOnlyMarkers = []*definitionWithHelp{
	must(markers.MakeDefinition("kubebuilder:validation:Required", markers.DescribesField, struct{}{})).
		WithHelp(markers.SimpleHelp("CRD validation", "specifies that this field is required.")),
	must(markers.MakeDefinition("kubebuilder:validation:Optional", markers.DescribesField, struct{}{})).
		WithHelp(markers.SimpleHelp("CRD validation", "specifies that this field is optional.")),
	must(markers.MakeDefinition("required", markers.DescribesField, struct{}{})).
		WithHelp(markers.SimpleHelp("CRD validation", "specifies that this field is required.")),
	must(markers.MakeDefinition("optional", markers.DescribesField, struct{}{})).
		WithHelp(markers.SimpleHelp("CRD validation", "specifies that this field is optional.")),

	must(markers.MakeDefinition("nullable", markers.DescribesField, Nullable{})).
		WithHelp(Nullable{}.Help()),

	must(markers.MakeAnyTypeDefinition("kubebuilder:default", markers.DescribesField, Default{})).
		WithHelp(Default{}.Help()),
	must(markers.MakeDefinition("default", markers.DescribesField, KubernetesDefault{})).
		WithHelp(KubernetesDefault{}.Help()),

	must(markers.MakeAnyTypeDefinition("kubebuilder:example", markers.DescribesField, Example{})).
		WithHelp(Example{}.Help()),

	must(markers.MakeDefinition("kubebuilder:validation:EmbeddedResource", markers.DescribesField, XEmbeddedResource{})).
		WithHelp(XEmbeddedResource{}.Help()),

	must(markers.MakeDefinition(SchemalessName, markers.DescribesField, Schemaless{})).
		WithHelp(Schemaless{}.Help()),
}

FieldOnlyMarkers list field-specific validation markers (i.e. those markers that don't make sense on a type, and thus aren't in ValidationMarkers).

View Source
var TopologyMarkers = []*definitionWithHelp{
	must(markers.MakeDefinition("listMapKey", markers.DescribesField, ListMapKey(""))).
		WithHelp(ListMapKey("").Help()),
	must(markers.MakeDefinition("listMapKey", markers.DescribesType, ListMapKey(""))).
		WithHelp(ListMapKey("").Help()),
	must(markers.MakeDefinition("listType", markers.DescribesField, ListType(""))).
		WithHelp(ListType("").Help()),
	must(markers.MakeDefinition("listType", markers.DescribesType, ListType(""))).
		WithHelp(ListType("").Help()),
	must(markers.MakeDefinition("mapType", markers.DescribesField, MapType(""))).
		WithHelp(MapType("").Help()),
	must(markers.MakeDefinition("mapType", markers.DescribesType, MapType(""))).
		WithHelp(MapType("").Help()),
	must(markers.MakeDefinition("structType", markers.DescribesField, StructType(""))).
		WithHelp(StructType("").Help()),
	must(markers.MakeDefinition("structType", markers.DescribesType, StructType(""))).
		WithHelp(StructType("").Help()),
}

TopologyMarkers specify topology markers (i.e. markers that describe if a list behaves as an associative-list or a set, if a map is atomic or not).

View Source
var ValidationIshMarkers = []*definitionWithHelp{
	must(markers.MakeDefinition("kubebuilder:pruning:PreserveUnknownFields", markers.DescribesField, XPreserveUnknownFields{})).
		WithHelp(XPreserveUnknownFields{}.Help()),
	must(markers.MakeDefinition("kubebuilder:pruning:PreserveUnknownFields", markers.DescribesType, XPreserveUnknownFields{})).
		WithHelp(XPreserveUnknownFields{}.Help()),
}

ValidationIshMarkers are field-and-type markers that don't fall under the :validation: prefix, and/or don't have a name that directly matches their type.

ValidationMarkers lists all available markers that affect CRD schema generation, except for the few that don't make sense as type-level markers (see FieldOnlyMarkers). 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. At last a copy of all markers with the prefix `+kubebuilder:validation:items:` is produced for marking slice fields and types.

Functions

func Register

func Register(reg *markers.Registry) error

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

Types

type ApplyPriority added in v0.15.0

type ApplyPriority int64

ApplyPriority designates the order markers should be applied. Lower priority indicates it should be applied first

const (
	// ApplyPriorityDefault is the default priority for markers
	// that don't implement ApplyPriorityMarker
	ApplyPriorityDefault ApplyPriority = 10

	// ApplyPriorityFirst is the priority value assigned to markers
	// that implement the ApplyFirst() method
	ApplyPriorityFirst ApplyPriority = 1
)

type ApplyPriorityMarker added in v0.15.0

type ApplyPriorityMarker interface {
	ApplyPriority() ApplyPriority
}

ApplyPriorityMarker designates the order validation markers should be applied. Lower priority indicates it should be applied first

type Default added in v0.2.2

type Default struct {
	Value interface{}
}

+controllertools:marker:generateHelp:category="CRD validation" Default sets the default value for this field.

A default value will be accepted as any value valid for the field. Formatting for common types include: boolean: `true`, string: `Cluster`, numerical: `1.24`, array: `{1,2}`, object: `{policy: "delete"}`). Defaults should be defined in pruned form, and only best-effort validation will be performed. Full validation of a default requires submission of the containing CRD to an apiserver.

func (Default) ApplyPriority added in v0.16.0

func (m Default) ApplyPriority() ApplyPriority

func (Default) ApplyToSchema added in v0.2.2

func (m Default) ApplyToSchema(schema *apiext.JSONSchemaProps) error

Defaults are only valid CRDs created with the v1 API

func (Default) Help added in v0.2.2

func (Default) Help() *markers.DefinitionHelp

type DeprecatedVersion added in v0.6.0

type DeprecatedVersion struct {
	// Warning message to be shown on the deprecated version
	Warning *string `marker:",optional"`
}

DeprecatedVersion marks this version as deprecated.

func (DeprecatedVersion) ApplyToCRD added in v0.6.0

func (DeprecatedVersion) Help added in v0.6.0

type Enum

type Enum []interface{}

+controllertools:marker:generateHelp:category="CRD validation" Enum specifies that this (scalar) field is restricted to the *exact* values specified here.

func (Enum) ApplyToSchema

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

func (Enum) Help

func (Enum) Help() *markers.DefinitionHelp

type Example added in v0.11.3

type Example struct {
	Value interface{}
}

+controllertools:marker:generateHelp:category="CRD validation" Example sets the example value for this field.

An example value will be accepted as any value valid for the field. Formatting for common types include: boolean: `true`, string: `Cluster`, numerical: `1.24`, array: `{1,2}`, object: `{policy: "delete"}`). Examples should be defined in pruned form, and only best-effort validation will be performed. Full validation of an example requires submission of the containing CRD to an apiserver.

func (Example) ApplyToSchema added in v0.11.3

func (m Example) ApplyToSchema(schema *apiext.JSONSchemaProps) error

func (Example) Help added in v0.11.3

func (Example) Help() *markers.DefinitionHelp

type ExclusiveMaximum

type ExclusiveMaximum bool

+controllertools:marker:generateHelp:category="CRD validation" ExclusiveMaximum indicates that the maximum is "up to" but not including that value.

func (ExclusiveMaximum) ApplyToSchema

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

func (ExclusiveMaximum) Help

type ExclusiveMinimum

type ExclusiveMinimum bool

+controllertools:marker:generateHelp:category="CRD validation" ExclusiveMinimum indicates that the minimum is "up to" but not including that value.

func (ExclusiveMinimum) ApplyToSchema

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

func (ExclusiveMinimum) Help

type Format

type Format string

+controllertools:marker:generateHelp:category="CRD validation" Format specifies additional "complex" formatting for this field.

For example, a date-time field would be marked as "type: string" and "format: date-time".

func (Format) ApplyToSchema

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

func (Format) Help

func (Format) Help() *markers.DefinitionHelp

type KubernetesDefault added in v0.16.0

type KubernetesDefault struct {
	Value interface{}
}

+controllertools:marker:generateHelp:category="CRD validation" Default sets the default value for this field.

A default value will be accepted as any value valid for the field. Only JSON-formatted values are accepted. `ref(...)` values are ignored. Formatting for common types include: boolean: `true`, string: `"Cluster"`, numerical: `1.24`, array: `[1,2]`, object: `{"policy": "delete"}`). Defaults should be defined in pruned form, and only best-effort validation will be performed. Full validation of a default requires submission of the containing CRD to an apiserver.

func (KubernetesDefault) ApplyPriority added in v0.16.0

func (m KubernetesDefault) ApplyPriority() ApplyPriority

func (KubernetesDefault) ApplyToSchema added in v0.16.0

func (m KubernetesDefault) ApplyToSchema(schema *apiext.JSONSchemaProps) error

Defaults are only valid CRDs created with the v1 API

func (KubernetesDefault) Help added in v0.16.0

func (*KubernetesDefault) ParseMarker added in v0.16.0

func (m *KubernetesDefault) ParseMarker(_ string, _ string, restFields string) error

type ListMapKey added in v0.2.5

type ListMapKey string

ListMapKey specifies the keys to map listTypes.

It indicates the index of a map list. They can be repeated if multiple keys must be used. It can only be used when ListType is set to map, and the keys should be scalar types.

func (ListMapKey) ApplyToSchema added in v0.2.5

func (l ListMapKey) ApplyToSchema(schema *apiext.JSONSchemaProps) error

func (ListMapKey) Help added in v0.2.5

type ListType added in v0.2.5

type ListType string

ListType specifies the type of data-structure that the list represents (map, set, atomic).

Possible data-structure types of a list are:

  • "map": it needs to have a key field, which will be used to build an associative list. A typical example is a the pod container list, which is indexed by the container name.

  • "set": Fields need to be "scalar", and there can be only one occurrence of each.

  • "atomic": All the fields in the list are treated as a single value, are typically manipulated together by the same actor.

func (ListType) ApplyPriority added in v0.15.0

func (l ListType) ApplyPriority() ApplyPriority

func (ListType) ApplyToSchema added in v0.2.5

func (l ListType) ApplyToSchema(schema *apiext.JSONSchemaProps) error

func (ListType) Help added in v0.2.5

type MapType added in v0.2.5

type MapType string

MapType specifies the level of atomicity of the map; i.e. whether each item in the map is independent of the others, or all fields are treated as a single unit.

Possible values:

  • "granular": items in the map are independent of each other, and can be manipulated by different actors. This is the default behavior.

  • "atomic": all fields are treated as one unit. Any changes have to replace the entire map.

func (MapType) ApplyToSchema added in v0.2.5

func (m MapType) ApplyToSchema(schema *apiext.JSONSchemaProps) error

func (MapType) Help added in v0.2.5

func (MapType) Help() *markers.DefinitionHelp

type MaxItems

type MaxItems int

+controllertools:marker:generateHelp:category="CRD validation" MaxItems specifies the maximum length for this list.

func (MaxItems) ApplyToSchema

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

func (MaxItems) Help

type MaxLength

type MaxLength int

+controllertools:marker:generateHelp:category="CRD validation" MaxLength specifies the maximum length for this string.

func (MaxLength) ApplyToSchema

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

func (MaxLength) Help

type MaxProperties added in v0.4.1

type MaxProperties int

+controllertools:marker:generateHelp:category="CRD validation" MaxProperties restricts the number of keys in an object

func (MaxProperties) ApplyToSchema added in v0.4.1

func (m MaxProperties) ApplyToSchema(schema *apiext.JSONSchemaProps) error

func (MaxProperties) Help added in v0.4.1

type Maximum

type Maximum float64

+controllertools:marker:generateHelp:category="CRD validation" Maximum specifies the maximum numeric value that this field can have.

func (Maximum) ApplyToSchema

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

func (Maximum) Help

func (Maximum) Help() *markers.DefinitionHelp

func (Maximum) Value added in v0.9.0

func (m Maximum) Value() float64

type Metadata added in v0.11.0

type Metadata struct {
	// Annotations will be added into the annotations of this CRD.
	Annotations []string `marker:",optional"`
	// Labels will be added into the labels of this CRD.
	Labels []string `marker:",optional"`
}

Metadata configures the additional annotations or labels for this CRD. For example adding annotation "api-approved.kubernetes.io" for a CRD with Kubernetes groups, or annotation "cert-manager.io/inject-ca-from-secret" for a CRD that needs CA injection.

func (Metadata) ApplyToCRD added in v0.11.0

func (s Metadata) ApplyToCRD(crd *apiext.CustomResourceDefinition, _ string) error

func (Metadata) Help added in v0.11.0

type MinItems

type MinItems int

+controllertools:marker:generateHelp:category="CRD validation" MinItems specifies the minimum length for this list.

func (MinItems) ApplyToSchema

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

func (MinItems) Help

type MinLength

type MinLength int

+controllertools:marker:generateHelp:category="CRD validation" MinLength specifies the minimum length for this string.

func (MinLength) ApplyToSchema

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

func (MinLength) Help

type MinProperties added in v0.4.1

type MinProperties int

+controllertools:marker:generateHelp:category="CRD validation" MinProperties restricts the number of keys in an object

func (MinProperties) ApplyToSchema added in v0.4.1

func (m MinProperties) ApplyToSchema(schema *apiext.JSONSchemaProps) error

func (MinProperties) Help added in v0.4.1

type Minimum

type Minimum float64

+controllertools:marker:generateHelp:category="CRD validation" Minimum specifies the minimum numeric value that this field can have. Negative numbers are supported.

func (Minimum) ApplyToSchema

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

func (Minimum) Help

func (Minimum) Help() *markers.DefinitionHelp

func (Minimum) Value added in v0.9.0

func (m Minimum) Value() float64

type MultipleOf

type MultipleOf float64

+controllertools:marker:generateHelp:category="CRD validation" MultipleOf specifies that this field must have a numeric value that's a multiple of this one.

func (MultipleOf) ApplyToSchema

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

func (MultipleOf) Help

func (MultipleOf) Value added in v0.9.0

func (m MultipleOf) Value() float64

type Nullable

type Nullable struct{}

+controllertools:marker:generateHelp:category="CRD validation" Nullable marks this field as allowing the "null" value.

This is often not necessary, but may be helpful with custom serialization.

func (Nullable) ApplyToSchema

func (m Nullable) ApplyToSchema(schema *apiext.JSONSchemaProps) error

func (Nullable) Help

type Pattern

type Pattern string

+controllertools:marker:generateHelp:category="CRD validation" Pattern specifies that this string must match the given regular expression.

func (Pattern) ApplyToSchema

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

func (Pattern) Help

func (Pattern) Help() *markers.DefinitionHelp

type PrintColumn

type PrintColumn struct {
	// Name specifies the name of the column.
	Name string

	// Type indicates the type of the column.
	//
	// It may be any OpenAPI data type listed at
	// https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types.
	Type string

	// JSONPath specifies the jsonpath expression used to extract the value of the column.
	JSONPath string `marker:"JSONPath"` // legacy cruft

	// Description specifies the help/description for this column.
	Description string `marker:",optional"`

	// Format specifies the format of the column.
	//
	// It may be any OpenAPI data format corresponding to the type, listed at
	// https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types.
	Format string `marker:",optional"`

	// Priority indicates how important it is that this column be displayed.
	//
	// Lower priority (*higher* numbered) columns will be hidden if the terminal
	// width is too small.
	Priority int32 `marker:",optional"`
}

PrintColumn adds a column to "kubectl get" output for this CRD.

func (PrintColumn) ApplyToCRD

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

func (PrintColumn) Help

type Resource

type Resource struct {
	// Path specifies the plural "resource" for this CRD.
	//
	// It generally corresponds to a plural, lower-cased version of the Kind.
	// See https://book.kubebuilder.io/cronjob-tutorial/gvks.html.
	Path string `marker:",optional"`

	// ShortName specifies aliases for this CRD.
	//
	// Short names are often used when people have work with your resource
	// over and over again.  For instance, "rs" for "replicaset" or
	// "crd" for customresourcedefinition.
	ShortName []string `marker:",optional"`

	// Categories specifies which group aliases this resource is part of.
	//
	// Group aliases are used to work with groups of resources at once.
	// The most common one is "all" which covers about a third of the base
	// resources in Kubernetes, and is generally used for "user-facing" resources.
	Categories []string `marker:",optional"`

	// Singular overrides the singular form of your resource.
	//
	// The singular form is otherwise defaulted off the plural (path).
	Singular string `marker:",optional"`

	// Scope overrides the scope of the CRD (Cluster vs Namespaced).
	//
	// Scope defaults to "Namespaced".  Cluster-scoped ("Cluster") resources
	// don't exist in namespaces.
	Scope string `marker:",optional"`
}

Resource configures naming and scope for a CRD.

func (Resource) ApplyToCRD

func (Resource) Help

type Schemaless added in v0.5.0

type Schemaless struct{}

+controllertools:marker:generateHelp:category="CRD validation" Schemaless marks a field as being a schemaless object.

Schemaless objects are not introspected, so you must provide any type and validation information yourself. One use for this tag is for embedding fields that hold JSONSchema typed objects. Because this field disables all type checking, it is recommended to be used only as a last resort.

func (Schemaless) Help added in v0.5.0

type SelectableField added in v0.16.4

type SelectableField struct {
	// JSONPath specifies the jsonpath expression which is used to produce a field selector value.
	JSONPath string `marker:"JSONPath"`
}

SelectableField adds a field that may be used with field selectors.

func (SelectableField) ApplyToCRD added in v0.16.4

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

func (SelectableField) Help added in v0.16.4

type SkipVersion

type SkipVersion struct{}

SkipVersion removes the particular version of the CRD from the CRDs spec.

This is useful if you need to skip generating and listing version entries for 'internal' resource versions, which typically exist if using the Kubernetes upstream conversion-gen tool.

func (SkipVersion) ApplyToCRD

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

func (SkipVersion) Help

type StorageVersion

type StorageVersion struct{}

StorageVersion marks this version as the "storage version" for the CRD for conversion.

When conversion is enabled for a CRD (i.e. it's not a trivial-versions/single-version CRD), one version is set as the "storage version" to be stored in etcd. Attempting to store any other version will result in conversion to the storage version via a conversion webhook.

func (StorageVersion) ApplyToCRD

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

func (StorageVersion) Help

type StructType added in v0.2.5

type StructType string

StructType specifies the level of atomicity of the struct; i.e. whether each field in the struct is independent of the others, or all fields are treated as a single unit.

Possible values:

  • "granular": fields in the struct are independent of each other, and can be manipulated by different actors. This is the default behavior.

  • "atomic": all fields are treated as one unit. Any changes have to replace the entire struct.

func (StructType) ApplyToSchema added in v0.2.5

func (s StructType) ApplyToSchema(schema *apiext.JSONSchemaProps) error

func (StructType) Help added in v0.2.5

type SubresourceScale

type SubresourceScale struct {

	// SpecPath specifies the jsonpath to the replicas field for the scale's spec.
	SpecPath string `marker:"specpath"`

	// StatusPath specifies the jsonpath to the replicas field for the scale's status.
	StatusPath string `marker:"statuspath"`

	// SelectorPath specifies the jsonpath to the pod label selector field for the scale's status.
	//
	// The selector field must be the *string* form (serialized form) of a selector.
	// Setting a pod label selector is necessary for your type to work with the HorizontalPodAutoscaler.
	SelectorPath *string `marker:"selectorpath"`
}

SubresourceScale enables the "/scale" subresource on a CRD.

func (SubresourceScale) ApplyToCRD

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

func (SubresourceScale) Help

type SubresourceStatus

type SubresourceStatus struct{}

SubresourceStatus enables the "/status" subresource on a CRD.

func (SubresourceStatus) ApplyToCRD

func (SubresourceStatus) Help

type Type

type Type string

+controllertools:marker:generateHelp:category="CRD validation" Type overrides the type for this field (which defaults to the equivalent of the Go type).

This generally must be paired with custom serialization. For example, the metav1.Time field would be marked as "type: string" and "format: date-time".

func (Type) ApplyPriority added in v0.15.0

func (m Type) ApplyPriority() ApplyPriority

func (Type) ApplyToSchema

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

func (Type) Help

func (Type) Help() *markers.DefinitionHelp

type UniqueItems

type UniqueItems bool

+controllertools:marker:generateHelp:category="CRD validation" UniqueItems specifies that all items in this list must be unique.

func (UniqueItems) ApplyToSchema

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

func (UniqueItems) Help

type UnservedVersion added in v0.2.8

type UnservedVersion struct{}

UnservedVersion does not serve this version.

This is useful if you need to drop support for a version in favor of a newer version.

func (UnservedVersion) ApplyToCRD added in v0.2.8

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

func (UnservedVersion) Help added in v0.2.8

type XEmbeddedResource added in v0.2.3

type XEmbeddedResource struct{}

+controllertools:marker:generateHelp:category="CRD validation" EmbeddedResource marks a fields as an embedded resource with apiVersion, kind and metadata fields.

An embedded resource is a value that has apiVersion, kind and metadata fields. They are validated implicitly according to the semantics of the currently running apiserver. It is not necessary to add any additional schema for these field, yet it is possible. This can be combined with PreserveUnknownFields.

func (XEmbeddedResource) ApplyToSchema added in v0.2.3

func (m XEmbeddedResource) ApplyToSchema(schema *apiext.JSONSchemaProps) error

func (XEmbeddedResource) Help added in v0.2.3

type XIntOrString added in v0.7.0

type XIntOrString struct{}

+controllertools:marker:generateHelp:category="CRD validation" IntOrString marks a fields as an IntOrString.

This is required when applying patterns or other validations to an IntOrString field. Known information about the type is applied during the collapse phase and as such is not normally available during marker application.

func (XIntOrString) ApplyPriority added in v0.15.0

func (m XIntOrString) ApplyPriority() ApplyPriority

func (XIntOrString) ApplyToSchema added in v0.7.0

func (m XIntOrString) ApplyToSchema(schema *apiext.JSONSchemaProps) error

func (XIntOrString) Help added in v0.7.0

type XPreserveUnknownFields added in v0.2.3

type XPreserveUnknownFields struct{}

+controllertools:marker:generateHelp:category="CRD processing" PreserveUnknownFields stops the apiserver from pruning fields which are not specified.

By default the apiserver drops unknown fields from the request payload during the decoding step. This marker stops the API server from doing so. It affects fields recursively, but switches back to normal pruning behaviour if nested properties or additionalProperties are specified in the schema. This can either be true or undefined. False is forbidden.

NB: The kubebuilder:validation:XPreserveUnknownFields variant is deprecated in favor of the kubebuilder:pruning:PreserveUnknownFields variant. They function identically.

func (XPreserveUnknownFields) ApplyToSchema added in v0.2.3

func (m XPreserveUnknownFields) ApplyToSchema(schema *apiext.JSONSchemaProps) error

func (XPreserveUnknownFields) Help added in v0.2.3

type XValidation added in v0.9.0

type XValidation struct {
	Rule              string
	Message           string `marker:",optional"`
	MessageExpression string `marker:"messageExpression,optional"`
	Reason            string `marker:"reason,optional"`
	FieldPath         string `marker:"fieldPath,optional"`
}

+controllertools:marker:generateHelp:category="CRD validation" XValidation marks a field as requiring a value for which a given expression evaluates to true.

This marker may be repeated to specify multiple expressions, all of which must evaluate to true.

func (XValidation) ApplyToSchema added in v0.9.0

func (m XValidation) ApplyToSchema(schema *apiext.JSONSchemaProps) error

func (XValidation) Help added in v0.9.0

Jump to

Keyboard shortcuts

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