core

package
v3.18.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNonKeyedSetter = errors.New("mutator does not understand keyed lists")
	ErrNameLength     = errors.New("maximum name length is 63 characters")
)

ErrNonKeyedSetter occurs when a setter that doesn't understand keyed lists is called against a keyed list.

Functions

func CheckKeyNotChanged

func CheckKeyNotChanged(p parser.Path) error

CheckKeyNotChanged does not allow to change the key field of a list element. A path like foo[name: bar].name is rejected.

func HasMetadataRoot

func HasMetadataRoot(path parser.Path) bool

HasMetadataRoot returns true if the root node at given path references the metadata field.

func MatchWithApplyTo

func MatchWithApplyTo(mut *types.Mutable, applies []match.ApplyTo, mat *match.Match) (bool, error)

func Mutate

func Mutate(
	path parser.Path,
	tester *path.Tester,
	setter Setter,
	obj *unstructured.Unstructured,
) (bool, error)

func NewTester

func NewTester(name string, kind string, path parser.Path, ptests []unversioned.PathTest) (*patht.Tester, error)

NewTester returns a path.Tester for the given object name, kind path and pathtests.

func NewValidatedBindings

func NewValidatedBindings(name string, kind string, applies []match.ApplyTo) ([]schema.GroupVersionKind, error)

NewValidatedBindings returns a slice of gvks from the given applies, or an error if the applies are invalid.

func ValidateName added in v3.15.0

func ValidateName(name string) error

Types

type Setter

type Setter interface {
	// SetValue takes the object that needs mutating and the key of the
	// field on that object that should be mutated. It is up to the
	// implementor to actually mutate the object.
	SetValue(obj map[string]interface{}, key string) error

	// KeyedListOkay returns whether this setter can handle keyed lists.
	// If it can't, an attempt to mutate a keyed-list-type field will
	// result in an error.
	KeyedListOkay() bool

	// KeyedListValue is the value that will be assigned to the
	// targeted keyed list entry. Unlike SetValue(), this does
	// not do mutation directly.
	KeyedListValue() (map[string]interface{}, error)
}

Setter tells the mutate function what to do once we have found the node that needs mutating.

func NewDefaultSetter

func NewDefaultSetter(value interface{}) Setter

Jump to

Keyboard shortcuts

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