Documentation ¶
Index ¶
Constants ¶
const (
// Kind is the kind for the kustomize function.
Kind = "CommonLabels"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CommonLabelsFn ¶
type CommonLabelsFn struct { // Kind is the API name. Must be PodEnvs. Kind string `yaml:"kind"` // APIVersion is the API version. Must be examples.kpt.dev/v1alpha1 APIVersion string `yaml:"apiVersion"` // Metadata defines instance metadata. Metadata v1alpha1.Metadata `yaml:"metadata"` // Spec defines the desired declarative configuration. Spec Spec `yaml:"spec"` }
CommonLabelsFn is a filter to add common labels to resources as well as remove labels from resources.
Only the field metadata.labels will be created if it doesn't exist. For all other labels field specified by CommonLabelsFn.Spec.FsSlice the labels map will not be created if it doesn't exist and any labels won't be added. This is because the function relies on the existence of the labels field e.g "spec.template.metadata.labels" to know that the resource has a labels field that should be set. The exception is metadata.labels as all K8s resources should have metadata.labels. In practice this should be fine as its expected that other labels fields would be non empty (e.g. spec.template.metadata.labels).
TODO(jeremy): We could potentially create the labels field if the FsSlice includes a kind and/or APIVersion because in that case we can correctly apply the labels map creation to only the resources that would use that non-standard location for labels.
TODO(jeremy): If we wanted to support adding labels I think we would need FsSlice's to enumerate the different kinds and then for those we could create labels if it doesn't exist. In practice I don't think this should be much of an issue.ß
type Spec ¶
type Spec struct { // Labels is the labels to set Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` // RemoveLabels is a list of keys to remove RemoveLabels []string `json:"removeLabel,omitempty" yaml:"removeKeys,omitempty"` // FsSlice contains the FieldSpecs to locate labels field, FsSlice types.FsSlice `json:"fieldSpecs,omitempty" yaml:"fieldSpecs,omitempty"` }
Spec is the spec for the kustomize function.