plugins

package
v0.999.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateFieldMutator

func CreateFieldMutator(config FieldMutatorConfig) *fieldMutator

CreateFieldMutator creates a mutator plugin that sets a value for a given field.

func CreateNamePrefixPlugin

func CreateNamePrefixPlugin(config NamePrefixConfig) *namePrefixTransformer

CreateNamePrefixPlugin creates a transformer plugin that adds a prefix to resource names. Acts as a constructor, ensuring the plugin is properly initialized with its configuration.

func CreateNamespacePlugin

func CreateNamespacePlugin(namespace string) (*namespacePlugin, error)

CreateNamespacePlugin creates a new namespace plugin.

func ValidateK8sLabelName

func ValidateK8sLabelName(name string) error

ValidateK8sLabelName uses the strictest naming rule (for Namespaces) to ensure the provided name string is valid for any given Resource.

Types

type FieldMapping

type FieldMapping struct {
	// SourceValue is the value to copy to the target field.
	SourceValue any `json:"sourceValue"`
	// DefaultValue is the value to use if SourceValue is empty.
	// This provides a fallback mechanism, making transformations more robust.
	DefaultValue any `json:"defaultValue,omitempty"`
	// TargetField is the JSON Pointer path to the field in the target object.
	// Uses RFC 6901 JSON Pointer syntax like "/spec/ports/0/port"
	// Special characters in field names are escaped: ~0 for ~ and ~1 for /
	// Example: "/spec/selector/app.kubernetes.io~1instance"
	TargetField string `json:"targetField"`
	// TargetKind is the kind of resource to apply the transformation to.
	TargetKind string `json:"targetKind"`
	// CreateIfNotExists will create the target field and any intermediate
	// map structures if they don't exist in the target resource.
	CreateIfNotExists bool `json:"createIfNotExists,omitempty"`
}

FieldMapping defines a single field mapping.

type FieldMutatorConfig

type FieldMutatorConfig struct {
	// Mappings is a list of field mappings to apply.
	Mappings []FieldMapping `json:"mappings"`
}

FieldMutatorConfig is a collection of FieldMappings.

type NamePrefixConfig

type NamePrefixConfig struct {
	// Prefix to add to resource names.
	Prefix string
	// IncludeKinds specifies which resource kinds to apply the prefix to.
	// If empty, the prefix is applied to all resource kinds not specified in ExcludeKinds.
	IncludeKinds []string
	// ExcludeKinds specifies which resource kinds to exclude from prefixing.
	// This list takes precedence over IncludeKinds; if a kind is in both lists,
	// it will be excluded.
	ExcludeKinds []string
}

NamePrefixConfig holds configuration for the name prefix plugin.

Jump to

Keyboard shortcuts

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