configmap

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConfigMapAnnotation defines the annotation that should be set on Filters if they should be applied to
	// YAMLs stored in configmaps. Valid values are "only" and "both". Only means only apply to configmap and
	// both means apply to both the configmap contents and all other resources.
	ConfigMapAnnotation = "kustomize.primer.ai/applytocm"
	// ConfigMapOnly is the value of the annotation to only apply filter to configmap contents.
	ConfigMapOnly = "only"
	// ConfigMapBoth is the value of the annotation to apply filter to configmap contents and YAMLs in source directory.
	ConfigMapBoth = "both"
)
View Source
const (
	// Kind is the kind for the kustomize function.
	Kind = "ConfigMapPatch"
)

Variables

This section is empty.

Functions

func Filter

func Filter() kio.Filter

Filter returns a new PatchFn

Types

type PatchFn

type PatchFn struct {
	// Kind is the API name.  Must be ConfigMapPatch.
	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"`
}

PatchFn patches a configmap. It works by looking for all configmaps that define the specified keys and overriding them. This is different from a strategic patch merge because we don't need to know the name of the configmap to apply it.

func (PatchFn) Filter

func (f PatchFn) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error)

Filter applies the filter to the nodes.

type Spec

type Spec struct {
	// Data is a mapping of the values to set if present.
	Data map[string]string `yaml:"data"`
}

Spec is the spec for the kustomize function.

type WrappedFilter

type WrappedFilter struct {
	Filters []kio.Filter
}

WrappedFilter applies a set of Filters to the data inside a configmap. This is useful if you have a ConfigMap containing YAML files and you want to apply the filters to the contents of those YAML files.

To users, users add the annotation "kustomize.primer.ai/applytocm" to their kustomize function definitions. The dispatcher will then wrap the specified kustomize function.

Example: apiVersion: v1alpha1 kind: PodEnvs metadata: annotations:

kustomize.primer.ai/applytocm: both

spec:

remove:
  - DD_AGENT_HOST

Important: If you have a function that accumulates data (see for example readFn in extractor.go) note that the init function of the filter gets invoked multiple times. Therefore, its important to not zero out the field doing accumulation on each call to init.

func (WrappedFilter) Filter

func (f WrappedFilter) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error)

Filter applies the filter to the nodes.

Jump to

Keyboard shortcuts

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