filters

package
v0.4.9 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: Apache-2.0 Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FieldPath added in v0.3.8

func FieldPath(p string, data map[string]string) ([]string, error)

FieldPath evaluates a path template using the supplied context and then splits it into individual path segments (honoring escaped delimiters).

func FilterAll added in v0.3.3

func FilterAll(f yaml.Filter) kio.Filter

FilterAll is similar to `kio.FilterAll` except instead of evaluating for side effects, only the non-nil nodes returned by the filter are preserved.

func FilterOne

func FilterOne(f kio.Filter) yaml.Filter

FilterOne is the opposite of kio.FilterAll, useful if you have a filter that is optimized for filtering batches of nodes, but you just need to call `Pipe` on a single node.

func Flatten added in v0.3.12

func Flatten(schema *spec.Schema) kio.Filter

Flatten never returns more than a single node, every other node is merged into that first node using the supplied schema

func Has added in v0.3.7

func Has(functions ...yaml.Filter) yaml.Filter

Has is similar to `yaml.Tee` except it only produces a result if the supplied functions evaluate to a non-nil result.

func InstallOrder added in v0.4.0

func InstallOrder() kio.Filter

InstallOrder returns a filter that sorts nodes in the order in which they should be created in a cluster. This uses the Helm ordering which is more complete than the Kustomize ordering.

func SetNamespace added in v0.3.12

func SetNamespace(namespace string) yaml.Filter

SetNamespace is like `SetK8sNamespace` except it skips cluster scoped resources.

func SetPath added in v0.3.17

func SetPath(p string, v *yaml.RNode) yaml.Filter

SetPath returns a filter that sets the node value at the specified path. Note that this path uses "." separators rather then "/".

func SetValues added in v0.3.17

func SetValues(nameValue []string, forceString bool) yaml.Filter

SetValues returns a filter that sets the supplied "path=value" specifications onto incoming nodes. Use forceString to bypass tagging the node values.

func SortByKind added in v0.4.0

func SortByKind(priority []string) kio.Filter

SortByKind returns a filter that sorts nodes based on the supplied list of kinds.

func UninstallOrder added in v0.4.0

func UninstallOrder() kio.Filter

UninstallOrder returns a filter that sorts nodes in the order in which they should be deleted from a cluster. This is not directly the reverse of the installation order.

func WithContext added in v0.3.20

func WithContext(ctx context.Context, f ContextFilterFunc) yaml.Filter

WithContext binds a context to a context filter function.

Types

type ApplicationFilter added in v0.3.8

type ApplicationFilter struct {
	// Flag indicating if this filter should act as a pass-through.
	Enabled bool
	// Flag indicating we should show resources which do not belong to an application.
	ShowUnownedResources bool
	// The ordered names of the labels that contains the application name, default is "app.kubernetes.io/name, k8s-app, app".
	ApplicationNameLabels []string
	// The name of the label that contains the application instance name, default is "app.kubernetes.io/instance".
	ApplicationInstanceLabel string
}

ApplicationFilter produces applications based on the observed resources.

func (*ApplicationFilter) Filter added in v0.3.8

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

Filter keeps all the application resources and creates application resources for all other nodes that are not associated with an application.

type ContextFilterFunc added in v0.3.20

type ContextFilterFunc func(context.Context, *yaml.RNode) (*yaml.RNode, error)

ContextFilterFunc is a context-aware YAML filter function.

type PatchFilter added in v0.4.8

type PatchFilter struct {
	// The media type of the patch being applied.
	PatchType string
	// The actual raw patch.
	PatchData []byte
}

PatchFilter is used to apply an arbitrary patch.

func (*PatchFilter) Filter added in v0.4.8

func (f *PatchFilter) Filter(node *yaml.RNode) (*yaml.RNode, error)

Filter applies the configured patch.

type Pipeline added in v0.3.3

type Pipeline struct {
	Inputs                []kio.Reader
	Filters               []kio.Filter
	Outputs               []kio.Writer
	ContinueOnEmptyResult bool
}

Pipeline is an alternate to the kio.Pipeline. This pipeline has the following differences: 1. The read/filter is separated so this pipeline can be used as a reader in another pipeline 2. This pipeline does not try to reconcile Kustomize annotations 3. This pipeline does not support callbacks 4. This pipeline implicitly clears empty annotations

func (*Pipeline) Execute added in v0.4.8

func (p *Pipeline) Execute() error

Execute reads and filters the nodes before sending them to the writers.

func (*Pipeline) Read added in v0.3.3

func (p *Pipeline) Read() ([]*yaml.RNode, error)

Read evaluates the inputs and filters, ignoring the writers.

type ResourceMetaFilter

type ResourceMetaFilter struct {
	// Regular expression matching the group.
	Group string `json:"group,omitempty" yaml:"group,omitempty"`
	// Regular expression matching the version.
	Version string `json:"version,omitempty" yaml:"version,omitempty"`
	// Regular expression matching the kind.
	Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
	// Regular expression matching the namespace.
	Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
	// Regular expression matching the name.
	Name string `json:"name,omitempty" yaml:"name,omitempty"`
	// Kubernetes selector matching labels.
	LabelSelector string `json:"labelSelector,omitempty" yaml:"labelSelector,omitempty"`
	// Kubernetes selector matching annotations
	AnnotationSelector string `json:"annotationSelector,omitempty" yaml:"annotationSelector,omitempty"`

	// Invert the matching behavior (i.e. keep non-matching nodes).
	InvertMatch bool `json:"invertMatch,omitempty" yaml:"invertMatch,omitempty"`
}

ResourceMetaFilter filters nodes based on their resource metadata using regular expressions or Kubernetes selectors.

func (*ResourceMetaFilter) Filter

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

type UnsupportedPatchError added in v0.4.8

type UnsupportedPatchError struct {
	PatchType string
}

UnsupportedPatchError is raised when a patch format is not recognized.

func (*UnsupportedPatchError) Error added in v0.4.8

func (e *UnsupportedPatchError) Error() string

type WorkloadFilter added in v0.4.1

type WorkloadFilter struct {
	// Flag indicating if this filter should act as a pass-through.
	Enabled bool
	// Secondary filter which can be optionally used to accept non-workload resources.
	NonWorkloadFilter *ResourceMetaFilter
}

WorkloadFilter keeps only workload resources, i.e. those that directly or indirectly own pods. For this filter to work, all intermediate resources must be present and must have owner metadata specified.

func (*WorkloadFilter) Filter added in v0.4.1

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

Filter keeps all the workload resources.

Jump to

Keyboard shortcuts

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