Documentation
¶
Index ¶
- Variables
- func AllowedNamespaceMetadataTemplatesString() string
- func ContainsFastTemplateSyntax(value string) bool
- func FastTemplate(template string, templateContext map[string]string) string
- func FastTemplateLabelSelector(in *metav1.LabelSelector, templateContext map[string]string) (*metav1.LabelSelector, error)
- func FastTemplateMap(m map[string]string, templateContext map[string]string) map[string]string
- func FastTemplateNormalize(key string) string
- func RenderNamespaceRuleBodies(context map[string]any, key MissingKeyOption, ...) ([]*rules.NamespaceRuleBodyNamespace, error)
- func RenderTemplateBytes(context map[string]any, key MissingKeyOption, tplBytes []byte) ([]byte, error)
- func RenderUnstructuredItems(context ReferenceContext, key MissingKeyOption, tplString string) (items []*unstructured.Unstructured, err error)
- func RequiresFastTemplate(value string) bool
- func SelectorRequiresTemplating(sel *metav1.LabelSelector) bool
- func ValidateAllowedTemplatesOnly(fieldPath string, value string) []string
- func ValidateKubernetesStringOrAllowedTemplates(fieldPath string, value string, validate func(string) []string) []string
- type MissingKeyOption
- type NamespaceValidator
- type ReferenceContext
- type ResourceReference
- func (in *ResourceReference) DeepCopy() *ResourceReference
- func (in *ResourceReference) DeepCopyInto(out *ResourceReference)
- func (t ResourceReference) IsNamespacedGVK(restMapper k8smeta.RESTMapper) (bool, error)
- func (t ResourceReference) LoadResources(ctx context.Context, kubeClient client.Client, restMapper k8smeta.RESTMapper, ...) ([]*unstructured.Unstructured, error)
- func (t ResourceReference) LoadTemplated(templateContext map[string]string) (ResourceReference, error)
- func (t ResourceReference) RequiresTemplating() bool
- type TemplateContext
- type TemplateResourceReference
Constants ¶
This section is empty.
Variables ¶
var AllowedNamespaceMetadataTemplates = sets.New[string](
"tenant.name",
"namespace",
)
var FastTemplateExpression = regexp.MustCompile(`{{\s*([^{}]+)\s*}}`)
Functions ¶
func AllowedNamespaceMetadataTemplatesString ¶ added in v0.13.2
func AllowedNamespaceMetadataTemplatesString() string
func ContainsFastTemplateSyntax ¶ added in v0.13.0
func FastTemplate ¶ added in v0.13.0
FastTemplate applies templating to the provided string.
func FastTemplateLabelSelector ¶ added in v0.13.0
func FastTemplateLabelSelector( in *metav1.LabelSelector, templateContext map[string]string, ) (*metav1.LabelSelector, error)
func FastTemplateMap ¶ added in v0.13.0
FastTemplateMap applies templating to all values in the provided map in place.
func FastTemplateNormalize ¶ added in v0.13.2
func RenderNamespaceRuleBodies ¶ added in v0.13.7
func RenderNamespaceRuleBodies( context map[string]any, key MissingKeyOption, bodies []*rules.NamespaceRuleBodyNamespace, ) ([]*rules.NamespaceRuleBodyNamespace, error)
func RenderTemplateBytes ¶ added in v0.13.7
func RenderUnstructuredItems ¶ added in v0.13.0
func RenderUnstructuredItems( context ReferenceContext, key MissingKeyOption, tplString string, ) (items []*unstructured.Unstructured, err error)
RenderUnstructuredItems attempts to render a given string template into a list of unstructured resources.
func RequiresFastTemplate ¶ added in v0.13.0
RequiresFastTemplate evaluates if given string requires templating.
func SelectorRequiresTemplating ¶ added in v0.13.0
func SelectorRequiresTemplating(sel *metav1.LabelSelector) bool
func ValidateAllowedTemplatesOnly ¶ added in v0.13.0
Types ¶
type MissingKeyOption ¶ added in v0.13.0
type MissingKeyOption string
+kubebuilder:validation:Enum=invalid;zero;error
const ( MissingKeyInvalid MissingKeyOption = "invalid" MissingKeyZero MissingKeyOption = "zero" MissingKeyError MissingKeyOption = "error" )
func (MissingKeyOption) String ¶ added in v0.13.0
func (p MissingKeyOption) String() string
type NamespaceValidator ¶ added in v0.13.0
func NewNamespaceValidator ¶ added in v0.13.0
func NewNamespaceValidator(allowCrossNamespaceSelection bool, allowed sets.Set[string]) NamespaceValidator
type ReferenceContext ¶ added in v0.13.0
+kubebuilder:object:generate=false
func (*ReferenceContext) String ¶ added in v0.13.0
func (t *ReferenceContext) String() (string, error)
type ResourceReference ¶ added in v0.13.0
type ResourceReference struct {
gvk.VersionKind `json:",inline"`
// Name of the values referent. This is useful
// when you traying to get a specific resource
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=253
// +optional
Name string `json:"name,omitempty"`
// Namespace of the values referent.
// +optional
Namespace string `json:"namespace,omitempty"`
// Selector which allows to get any amount of these resources based on labels
// +optional
Selector *metav1.LabelSelector `json:"selector,omitempty"`
// Only relevant if name is set. If an item is not optional, there will be an error thrown when it does not exist
// +kubebuilder:default:=true
Optional bool `json:"optional,omitempty"`
}
Reference +kubebuilder:object:generate=true
func (*ResourceReference) DeepCopy ¶ added in v0.13.0
func (in *ResourceReference) DeepCopy() *ResourceReference
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceReference.
func (*ResourceReference) DeepCopyInto ¶ added in v0.13.0
func (in *ResourceReference) DeepCopyInto(out *ResourceReference)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (ResourceReference) IsNamespacedGVK ¶ added in v0.13.0
func (t ResourceReference) IsNamespacedGVK( restMapper k8smeta.RESTMapper, ) (bool, error)
func (ResourceReference) LoadResources ¶ added in v0.13.0
func (t ResourceReference) LoadResources( ctx context.Context, kubeClient client.Client, restMapper k8smeta.RESTMapper, namespace string, additionSelectors []labels.Selector, templateContext map[string]string, allowClusterScoped bool, validateNamespace NamespaceValidator, ) ([]*unstructured.Unstructured, error)
func (ResourceReference) LoadTemplated ¶ added in v0.13.0
func (t ResourceReference) LoadTemplated(templateContext map[string]string) (ResourceReference, error)
func (ResourceReference) RequiresTemplating ¶ added in v0.13.0
func (t ResourceReference) RequiresTemplating() bool
type TemplateContext ¶ added in v0.13.0
type TemplateContext struct {
Resources []*TemplateResourceReference `json:"resources,omitempty"`
}
Additional Context to enhance templating +kubebuilder:object:generate=true
func (*TemplateContext) DeepCopy ¶ added in v0.13.0
func (in *TemplateContext) DeepCopy() *TemplateContext
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TemplateContext.
func (*TemplateContext) DeepCopyInto ¶ added in v0.13.0
func (in *TemplateContext) DeepCopyInto(out *TemplateContext)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*TemplateContext) GatherContext ¶ added in v0.13.0
func (t *TemplateContext) GatherContext( ctx context.Context, kubeClient client.Client, restMapper k8smeta.RESTMapper, templateContext map[string]string, namespace string, additionSelectors []labels.Selector, validateNamespace NamespaceValidator, ) (ReferenceContext, error)
type TemplateResourceReference ¶ added in v0.13.0
type TemplateResourceReference struct {
ResourceReference `json:",inline"`
// Index to mount the resource in the template context
Index string `json:"index,omitempty"`
}
+kubebuilder:object:generate=true
func (*TemplateResourceReference) DeepCopy ¶ added in v0.13.0
func (in *TemplateResourceReference) DeepCopy() *TemplateResourceReference
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TemplateResourceReference.
func (*TemplateResourceReference) DeepCopyInto ¶ added in v0.13.0
func (in *TemplateResourceReference) DeepCopyInto(out *TemplateResourceReference)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.