Documentation
¶
Index ¶
- Constants
- func DescribeExpressionMatch(match ExpressionMatch) string
- type ExpressionMatch
- func (in *ExpressionMatch) DeepCopy() *ExpressionMatch
- func (in *ExpressionMatch) DeepCopyInto(out *ExpressionMatch)
- func (m ExpressionMatch) Describe() string
- func (m ExpressionMatch) Matches(value string) (bool, error)
- func (m ExpressionMatch) MatchesWithExpressionMatcher(matcher ExpressionRegexMatcher, value string) (bool, error)
- func (m ExpressionMatch) ValidateLimits(fieldPath string) error
- type ExpressionRegex
- type ExpressionRegexMatcher
- type JSONSchemaFormExtension
- type JSONSchemaFormWidget
- type KubernetesResourceFormOption
- type KubernetesResourceFormSource
- type RenderedResource
- type ResourceCreationPolicy
- type ResourceDeletionPolicy
- type ResourceReplicationPolicy
- type ResourceTemplate
- type ResourceTemplatePolicy
- func (p ResourceTemplatePolicy) AllowsAdoption() bool
- func (in *ResourceTemplatePolicy) DeepCopy() *ResourceTemplatePolicy
- func (in *ResourceTemplatePolicy) DeepCopyInto(out *ResourceTemplatePolicy)
- func (p ResourceTemplatePolicy) IsProtected() bool
- func (p ResourceTemplatePolicy) ShouldOrphan() bool
- type VersionKind
- func (in *VersionKind) DeepCopy() *VersionKind
- func (in *VersionKind) DeepCopyInto(out *VersionKind)
- func (s VersionKind) GroupVersionKind() schema.GroupVersionKind
- func (s VersionKind) HasWildcard() bool
- func (s VersionKind) MatchesGroupVersionKind(gvk schema.GroupVersionKind) bool
- func (s VersionKind) MatchesVersionKind(value VersionKind) bool
- type VersionKinds
- func (in *VersionKinds) DeepCopy() *VersionKinds
- func (in *VersionKinds) DeepCopyInto(out *VersionKinds)
- func (s VersionKinds) HasWildcard() bool
- func (s VersionKinds) MatchesGroupVersionKind(gvk schema.GroupVersionKind) bool
- func (s VersionKinds) NormalizedAPIGroups() []string
- func (s VersionKinds) StatusAPIGroups() []string
- func (s VersionKinds) ValidateKnownKinds(mapper apimeta.RESTMapper, fieldPath string) error
- func (s VersionKinds) ValidateKnownKindsWithScope(mapper apimeta.RESTMapper, fieldPath string, ...) error
- func (s VersionKinds) VersionKinds() []VersionKind
Constants ¶
const ( MaxExpressionMatchExactValues = 64 MaxExpressionRegexLength = 4096 )
const ( // JSONSchemaFormWidgetKubernetesResource renders a selector whose options // are loaded from the Kubernetes API using discovery and the requestor's // credentials. JSONSchemaFormWidgetKubernetesResource JSONSchemaFormWidget = "kubernetes-resource" // JSONSchemaFormRequestNamespace resolves to the namespace in which the // RenderedResource is being created. JSONSchemaFormRequestNamespace = "request" // JSONSchemaFormAllNamespaces lists a namespaced GVK across all namespaces. JSONSchemaFormAllNamespaces = "*" // JSONSchemaFormDefaultOptionTemplate is used for both the label and value // when their corresponding option template is omitted. JSONSchemaFormDefaultOptionTemplate = "{{ .metadata.name }}" )
const ( WildcardVersionKindMatcher = "*" CoreAPIVersion = "v1" )
const JSONSchemaFormExtensionKey = "x-capsule-form"
JSONSchemaFormExtensionKey is the vendor-extension keyword understood by Capsule form consumers inside a JSON Schema property.
const JSONSchemaKubernetesValidationsKey = "x-kubernetes-validations"
JSONSchemaKubernetesValidationsKey is the Kubernetes-compatible vendor extension used to attach CEL validation rules to a parameter schema.
Variables ¶
This section is empty.
Functions ¶
func DescribeExpressionMatch ¶
func DescribeExpressionMatch(match ExpressionMatch) string
Types ¶
type ExpressionMatch ¶
type ExpressionMatch struct {
ExpressionRegex `json:",inline"`
// Exact matches one of the provided values exactly.
//
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:MaxItems=64
// +kubebuilder:validation:Items:MinLength=1
// +optional
Exact []string `json:"exact,omitempty"`
}
At least one of Exact or Exp must be set. Both may be set together. +kubebuilder:object:generate=true +kubebuilder:validation:XValidation:rule="has(self.exact) || has(self.exp)",message="at least one of exact or exp must be set"
func (*ExpressionMatch) DeepCopy ¶
func (in *ExpressionMatch) DeepCopy() *ExpressionMatch
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExpressionMatch.
func (*ExpressionMatch) DeepCopyInto ¶
func (in *ExpressionMatch) DeepCopyInto(out *ExpressionMatch)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (ExpressionMatch) Describe ¶
func (m ExpressionMatch) Describe() string
func (ExpressionMatch) MatchesWithExpressionMatcher ¶
func (m ExpressionMatch) MatchesWithExpressionMatcher( matcher ExpressionRegexMatcher, value string, ) (bool, error)
func (ExpressionMatch) ValidateLimits ¶ added in v0.15.0
func (m ExpressionMatch) ValidateLimits(fieldPath string) error
ValidateLimits checks policy size limits without compiling the expression. Length is measured in Unicode characters to match Kubernetes schema validation.
type ExpressionRegex ¶
type ExpressionRegex struct {
// Exp matches regular expression.
//
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=4096
// +optional
Expression string `json:"exp,omitempty"`
// Negate regular Expression
//+kubebuilder:default:=false
Negate bool `json:"negate,omitempty"`
}
type ExpressionRegexMatcher ¶
type ExpressionRegexMatcher interface {
MatchRegex(expression ExpressionRegex, value string) (bool, error)
}
type JSONSchemaFormExtension ¶ added in v0.15.0
type JSONSchemaFormExtension struct {
// Widget selects the form control used for the property.
// +kubebuilder:validation:Enum=kubernetes-resource
Widget JSONSchemaFormWidget `json:"widget"`
// Source describes the Kubernetes resources used as selectable options.
Source *KubernetesResourceFormSource `json:"source"`
// Option controls how each Kubernetes object is presented and converted to
// the JSON Schema property's string value.
// +optional
Option *KubernetesResourceFormOption `json:"option,omitempty"`
}
JSONSchemaFormExtension describes optional form behavior for a JSON Schema property. It remains a JSON Schema vendor extension and therefore does not alter validation of the submitted parameter value.
+kubebuilder:object:generate=true
func (*JSONSchemaFormExtension) DeepCopy ¶ added in v0.15.0
func (in *JSONSchemaFormExtension) DeepCopy() *JSONSchemaFormExtension
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JSONSchemaFormExtension.
func (*JSONSchemaFormExtension) DeepCopyInto ¶ added in v0.15.0
func (in *JSONSchemaFormExtension) DeepCopyInto(out *JSONSchemaFormExtension)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type JSONSchemaFormWidget ¶ added in v0.15.0
type JSONSchemaFormWidget string
JSONSchemaFormWidget identifies a form widget supplied by Capsule.
type KubernetesResourceFormOption ¶ added in v0.15.0
type KubernetesResourceFormOption struct {
// LabelTemplate renders the human-readable option label. It defaults to
// "{{ .metadata.name }}".
// +optional
LabelTemplate string `json:"labelTemplate,omitempty"`
// ValueTemplate renders the value stored in the RenderedResource parameters. It
// defaults to "{{ .metadata.name }}".
// +optional
ValueTemplate string `json:"valueTemplate,omitempty"`
}
KubernetesResourceFormOption controls how one listed Kubernetes object is displayed and serialized. Both fields use Go text/template syntax with the unstructured Kubernetes object as the root value.
+kubebuilder:object:generate=true
func (*KubernetesResourceFormOption) DeepCopy ¶ added in v0.15.0
func (in *KubernetesResourceFormOption) DeepCopy() *KubernetesResourceFormOption
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesResourceFormOption.
func (*KubernetesResourceFormOption) DeepCopyInto ¶ added in v0.15.0
func (in *KubernetesResourceFormOption) DeepCopyInto(out *KubernetesResourceFormOption)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type KubernetesResourceFormSource ¶ added in v0.15.0
type KubernetesResourceFormSource struct {
// APIVersion of the resource, for example "v1" or "gateway.networking.k8s.io/v1".
APIVersion string `json:"apiVersion"`
// Kind of the resource, for example "Secret" or "GatewayClass".
Kind string `json:"kind"`
// Namespace controls the list scope for namespaced resources. "request"
// selects the RenderedResource namespace, "*" selects all namespaces, and any
// other value selects that literal namespace. When omitted, form consumers
// use the RenderedResource namespace for namespaced GVKs and cluster scope for
// cluster-scoped GVKs.
// +optional
Namespace string `json:"namespace,omitempty"`
// LabelSelector is an optional Kubernetes label-selector expression applied
// to the list request.
// +optional
LabelSelector string `json:"labelSelector,omitempty"`
// FieldSelector is an optional Kubernetes field-selector expression applied
// to the list request.
// +optional
FieldSelector string `json:"fieldSelector,omitempty"`
}
KubernetesResourceFormSource identifies an arbitrary Kubernetes GVK to list for a kubernetes-resource form widget.
+kubebuilder:object:generate=true
func (*KubernetesResourceFormSource) DeepCopy ¶ added in v0.15.0
func (in *KubernetesResourceFormSource) DeepCopy() *KubernetesResourceFormSource
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesResourceFormSource.
func (*KubernetesResourceFormSource) DeepCopyInto ¶ added in v0.15.0
func (in *KubernetesResourceFormSource) DeepCopyInto(out *KubernetesResourceFormSource)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type RenderedResource ¶ added in v0.15.0
type RenderedResource struct {
// Policy controls how every rendered target is created and managed.
Policy ResourceTemplatePolicy `json:"policy,omitempty"`
// Targets are the fully rendered Kubernetes manifests.
// +kubebuilder:validation:MinItems=1
Targets []k8sruntime.RawExtension `json:"targets"`
}
RenderedResource is an execution-ready group of Kubernetes manifests produced from a ResourceTemplate. It intentionally cannot contain a source template so status consumers and reconcilers only observe concrete targets. +kubebuilder:object:generate=true
func (*RenderedResource) DeepCopy ¶ added in v0.15.0
func (in *RenderedResource) DeepCopy() *RenderedResource
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RenderedResource.
func (*RenderedResource) DeepCopyInto ¶ added in v0.15.0
func (in *RenderedResource) DeepCopyInto(out *RenderedResource)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type ResourceCreationPolicy ¶ added in v0.15.0
type ResourceCreationPolicy string
ResourceCreationPolicy controls whether a rendered target may adopt an existing Kubernetes resource.
const ( // ResourceCreationPolicyOwner requires the resource to have been created by // the applying controller. This is also the runtime default. ResourceCreationPolicyOwner ResourceCreationPolicy = "Owner" // ResourceCreationPolicyMerge allows an existing resource to be adopted and // managed through server-side apply. ResourceCreationPolicyMerge ResourceCreationPolicy = "Merge" )
type ResourceDeletionPolicy ¶ added in v0.15.0
type ResourceDeletionPolicy string
ResourceDeletionPolicy controls what happens to a rendered target when its parent stops managing it.
const ( // ResourceDeletionPolicyRemove removes resources created for the parent and // relinquishes adopted resources. This is also the runtime default. ResourceDeletionPolicyRemove ResourceDeletionPolicy = "Remove" // ResourceDeletionPolicyOrphan keeps the resource and removes Capsule's // lifecycle metadata when the parent stops managing it. ResourceDeletionPolicyOrphan ResourceDeletionPolicy = "Orphan" )
type ResourceReplicationPolicy ¶ added in v0.15.0
type ResourceReplicationPolicy struct {
ResourceTemplatePolicy `json:",inline"`
// Condition is an optional CEL boolean expression checked before each target
// is applied. object is the existing destination object, or null when absent;
// now is the evaluation timestamp. False skips rendered content without
// pruning or releasing an already managed object. Policy and protection are
// still reconciled for managed objects. Evaluation errors prevent writes.
// Rendering still occurs before evaluation. Omitting Condition preserves the
// existing apply behavior. Conditions do not affect deletion or orphaning.
// +optional
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=4096
Condition string `json:"condition,omitempty"`
}
ResourceReplicationPolicy extends the shared lifecycle policy with a condition evaluated on each TR/GTR reconciliation. +kubebuilder:object:generate=true
func (*ResourceReplicationPolicy) DeepCopy ¶ added in v0.15.0
func (in *ResourceReplicationPolicy) DeepCopy() *ResourceReplicationPolicy
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceReplicationPolicy.
func (*ResourceReplicationPolicy) DeepCopyInto ¶ added in v0.15.0
func (in *ResourceReplicationPolicy) DeepCopyInto(out *ResourceReplicationPolicy)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type ResourceTemplate ¶ added in v0.15.0
type ResourceTemplate struct {
// Policy controls how every target in this resource group is created and managed.
// +kubebuilder:default={}
Policy ResourceTemplatePolicy `json:"policy,omitempty"`
// Targets are Kubernetes resource objects to render and manage with Policy.
// Parameters and loaded context use the flat template root; trusted request
// metadata is available under .request.
// +optional
// +kubebuilder:validation:MinItems=1
Targets []k8sruntime.RawExtension `json:"targets,omitempty"`
// Template is an optional Go template which may render one or more YAML or
// JSON Kubernetes resources separated by YAML document markers. Request
// parameters are available under .params and loaded resources under
// .context.resources. Trusted request metadata is available under .request
// with name, username, groups, and timestamp fields.
// +optional
// +kubebuilder:validation:MinLength=1
Template string `json:"template,omitempty"`
}
+kubebuilder:object:generate=true +kubebuilder:validation:XValidation:rule="(has(self.targets) && size(self.targets) > 0) || has(self.template)",message="at least one target or a template is required"
func (*ResourceTemplate) DeepCopy ¶ added in v0.15.0
func (in *ResourceTemplate) DeepCopy() *ResourceTemplate
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceTemplate.
func (*ResourceTemplate) DeepCopyInto ¶ added in v0.15.0
func (in *ResourceTemplate) DeepCopyInto(out *ResourceTemplate)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type ResourceTemplatePolicy ¶ added in v0.15.0
type ResourceTemplatePolicy struct {
// Creation controls how an existing target is handled. Owner requires the
// resource to have been created by the applying controller and otherwise
// returns an error. Merge adopts an existing resource when possible and
// creates the resource when it does not exist.
// +kubebuilder:default=Owner
// +kubebuilder:validation:Enum=Owner;Merge
Creation ResourceCreationPolicy `json:"creation,omitempty"`
// Protect prevents users from changing or deleting the target through
// admission while it is managed. Protection is enabled by default.
// +kubebuilder:default=true
Protect *bool `json:"protect,omitempty"`
// Force allows server-side apply to acquire conflicting field ownership.
// +kubebuilder:default=false
Force bool `json:"force,omitempty"`
// Deletion controls what happens when the parent stops managing the target.
// Remove deletes resources created for the parent and relinquishes adopted
// resources. Orphan keeps the resource and removes Capsule's lifecycle
// metadata. Removal is the default.
// +kubebuilder:default=Remove
// +kubebuilder:validation:Enum=Remove;Orphan
Deletion ResourceDeletionPolicy `json:"deletion,omitempty"`
}
+kubebuilder:object:generate=true
func (ResourceTemplatePolicy) AllowsAdoption ¶ added in v0.15.0
func (p ResourceTemplatePolicy) AllowsAdoption() bool
AllowsAdoption reports whether an existing resource may be adopted.
func (*ResourceTemplatePolicy) DeepCopy ¶ added in v0.15.0
func (in *ResourceTemplatePolicy) DeepCopy() *ResourceTemplatePolicy
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceTemplatePolicy.
func (*ResourceTemplatePolicy) DeepCopyInto ¶ added in v0.15.0
func (in *ResourceTemplatePolicy) DeepCopyInto(out *ResourceTemplatePolicy)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (ResourceTemplatePolicy) IsProtected ¶ added in v0.15.0
func (p ResourceTemplatePolicy) IsProtected() bool
IsProtected reports whether admission protection is enabled. A missing value is treated as true so callers which did not pass through API defaulting behave consistently with persisted custom resources.
func (ResourceTemplatePolicy) ShouldOrphan ¶ added in v0.15.0
func (p ResourceTemplatePolicy) ShouldOrphan() bool
ShouldOrphan reports whether the target should be retained when its parent stops managing it. A missing value uses Remove semantics.
type VersionKind ¶
type VersionKind struct {
// Kind of the referent.
//
// Use "*" to match all kinds.
//
// +kubebuilder:validation:MinLength=1
Kind string `json:"kind" protobuf:"bytes,1,opt,name=kind"`
// API version, API group, or API group/version selector of the referent.
//
// Empty APIVersion means the core Kubernetes API version "v1".
// Use "*" to explicitly match all API groups and versions.
//
// Examples:
// - "" means core "v1".
// - "v1" means core "v1".
// - "apps" means any version in the "apps" API group.
// - "apps/v1" means the "apps/v1" API group/version.
// - "apps/*" means any version in the "apps" API group.
//
// +optional
APIVersion string `json:"apiVersion,omitempty" protobuf:"bytes,5,opt,name=apiVersion"`
}
+kubebuilder:object:generate=true
func (*VersionKind) DeepCopy ¶
func (in *VersionKind) DeepCopy() *VersionKind
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VersionKind.
func (*VersionKind) DeepCopyInto ¶
func (in *VersionKind) DeepCopyInto(out *VersionKind)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (VersionKind) GroupVersionKind ¶
func (s VersionKind) GroupVersionKind() schema.GroupVersionKind
func (VersionKind) HasWildcard ¶
func (s VersionKind) HasWildcard() bool
HasWildcard returns true when APIVersion or Kind contains a wildcard matcher.
func (VersionKind) MatchesGroupVersionKind ¶
func (s VersionKind) MatchesGroupVersionKind(gvk schema.GroupVersionKind) bool
MatchesGroupVersionKind returns true when the receiver matches the provided GVK.
Matching is exact unless the receiver contains '*'. Empty APIVersion is treated as "v1". Kind must be set. Use "*" to explicitly match all kinds.
func (VersionKind) MatchesVersionKind ¶
func (s VersionKind) MatchesVersionKind(value VersionKind) bool
MatchesVersionKind returns true when the receiver matches another VersionKind.
The receiver is interpreted as the pattern. The provided VersionKind is interpreted as the concrete value.
type VersionKinds ¶
type VersionKinds struct {
// API groups or API group/version selectors of the referents.
//
// Empty or omitted APIGroups means the core Kubernetes API version "v1".
// Use "*" to match all API groups and versions.
//
// Examples:
// - [] or [""] means core "v1".
// - ["v1"] means core "v1".
// - ["apps"] means any version in the "apps" API group.
// - ["apps/v1"] means only "apps/v1".
// - ["apps", "batch/v1"] means any "apps" version and "batch/v1".
// - ["*"] means all API groups and versions.
//
// +optional
APIGroups []string `json:"apiGroups,omitempty"`
// Kinds of the referents.
//
// Use "*" to match all kinds.
//
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:items:MinLength=1
Kinds []string `json:"kinds"`
}
+kubebuilder:object:generate=true
func (*VersionKinds) DeepCopy ¶
func (in *VersionKinds) DeepCopy() *VersionKinds
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VersionKinds.
func (*VersionKinds) DeepCopyInto ¶
func (in *VersionKinds) DeepCopyInto(out *VersionKinds)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (VersionKinds) HasWildcard ¶
func (s VersionKinds) HasWildcard() bool
func (VersionKinds) MatchesGroupVersionKind ¶
func (s VersionKinds) MatchesGroupVersionKind(gvk schema.GroupVersionKind) bool
func (VersionKinds) NormalizedAPIGroups ¶
func (s VersionKinds) NormalizedAPIGroups() []string
func (VersionKinds) StatusAPIGroups ¶
func (s VersionKinds) StatusAPIGroups() []string
func (VersionKinds) ValidateKnownKinds ¶
func (s VersionKinds) ValidateKnownKinds(mapper apimeta.RESTMapper, fieldPath string) error
ValidateKnownKinds validates concrete apiGroup/kind or apiGroupVersion/kind combinations against the RESTMapper. Wildcard API groups or wildcard kinds are intentionally skipped because they are selectors, not concrete Kubernetes resources.
func (VersionKinds) ValidateKnownKindsWithScope ¶ added in v0.13.10
func (s VersionKinds) ValidateKnownKindsWithScope( mapper apimeta.RESTMapper, fieldPath string, allowScope func(schema.GroupVersionKind, apimeta.RESTScope) bool, ) error
ValidateKnownKindsWithScope validates concrete targets and optionally their REST scope. Wildcard selectors are skipped because discovery cannot enumerate their complete set reliably.
func (VersionKinds) VersionKinds ¶
func (s VersionKinds) VersionKinds() []VersionKind