types

package
v3.17.1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	SourceTypeOriginal  = SourceType("Original")
	SourceTypeGenerated = SourceType("Generated")
	SourceTypeAll       = SourceType("All")
	SourceTypeDefault   = SourceTypeAll
)

Variables

This section is empty.

Functions

func IsValidSource

func IsValidSource(src SourceType) bool

func UnmarshalValue

func UnmarshalValue(data []byte) (interface{}, error)

UnmarshalValue unmarshals the value a mutation is meant to assign.

Types

type Anything

type Anything struct {
	Value interface{} `json:"-"`
}

Anything is a struct wrapper around a field of type `interface{}` that plays nicely with controller-gen +kubebuilder:object:generate=false +kubebuilder:validation:Type=""

func (*Anything) DeepCopy

func (in *Anything) DeepCopy() *Anything

func (*Anything) DeepCopyInto

func (in *Anything) DeepCopyInto(out *Anything)

func (*Anything) GetValue

func (in *Anything) GetValue() interface{}

func (Anything) MarshalJSON

func (in Anything) MarshalJSON() ([]byte, error)

MarshalJSON should be implemented against a value per http://stackoverflow.com/questions/21390979/custom-marshaljson-never-gets-called-in-go credit to K8s api machinery's RawExtension for finding this.

func (*Anything) UnmarshalJSON

func (in *Anything) UnmarshalJSON(val []byte) error

type ExternalDataFailurePolicy

type ExternalDataFailurePolicy string

ExternalDataFailurePolicy is the type of the failure policy to use for the external data. +kubebuilder:validation:Enum=UseDefault;Ignore;Fail

const (
	// UseDefault indicates that the default value of the external
	// data provider will be used.
	FailurePolicyUseDefault ExternalDataFailurePolicy = "UseDefault"

	// Ignore indicates that the mutation will be ignored if the external
	// data provider fails.
	FailurePolicyIgnore ExternalDataFailurePolicy = "Ignore"

	// Fail indicates that the mutation will be failed if the external
	// data provider fails.
	FailurePolicyFail ExternalDataFailurePolicy = "Fail"
)

type ExternalDataSource

type ExternalDataSource string

ExternalDataSource is the type of the data source to use for the external data. +kubebuilder:validation:Enum=ValueAtLocation;Username

const (
	// ValueAtLocation indicates that the value at spec.location of the mutation
	// spec will be extracted to the external data provider as the data source.
	DataSourceValueAtLocation ExternalDataSource = "ValueAtLocation"

	// Username indicates that the username of the admission request will
	// be extracted to the external data provider as the data source.
	DataSourceUsername ExternalDataSource = "Username"
)

type ID

type ID struct {
	Group     string
	Kind      string
	Namespace string
	Name      string
}

ID represent the identifier of a mutation object.

func MakeID

func MakeID(obj client.Object) ID

MakeID builds an ID object for the given object.

func (ID) String

func (id ID) String() string

type MetadataGetter

type MetadataGetter interface {
	GetNamespace() string
	GetName() string
}

MetadataGetter is an object that can retrieve the metadata fields that support `AssignField.FromMetadata`.

type Mutable

type Mutable struct {
	// Object is the object to be mutated.
	Object *unstructured.Unstructured

	// Namespace is the namespace of the mutable object.
	Namespace *corev1.Namespace

	// Username is the name of the user who initiates
	// admission request of the mutable object.
	Username string

	// Source specifies which types of resources the mutator should be applied to
	Source SourceType
}

Mutable represents a mutable object and its metadata.

type Mutator

type Mutator interface {
	// Matches tells if the given object is eligible for this mutation.
	Matches(mutable *Mutable) (bool, error)
	// Mutate applies the mutation to the given object
	Mutate(mutable *Mutable) (bool, error)
	// MustTerminate returns true if the mutator requires its path to terminate
	MustTerminate() bool
	// ID returns the id of the current mutator.
	ID() ID
	// HasDiff tells if the mutator has meaningful differences
	// with the provided mutator
	HasDiff(mutator Mutator) bool
	// DeepCopy returns a copy of the current object
	DeepCopy() Mutator
	Path() parser.Path
	String() string
}

Mutator represent a mutation object.

type SourceType

type SourceType string

SourceType specifies which types resource a matcher should be applied to.

Jump to

Keyboard shortcuts

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