mutation

package
v3.16.1 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DeprecatedMutationEnabled  = flag.Bool("enable-mutation", false, "Deprecated. This used to enable the mutation feature, now it has no effect. Use --operation=mutation-webhook and --operation=mutation-status instead.")
	MutationLoggingEnabled     *bool
	MutationAnnotationsEnabled *bool
)
View Source
var ErrNotConverging = errors.New("mutation not converging")

ErrNotConverging reports that applying all Mutators isn't converging.

View Source
var ErrNotRemoved = errors.New("failed to find mutator on sorted list")

ErrNotRemoved reports that we were unable to remove a Mutator properly as System was in an inconsistent state.

Functions

func Enabled

func Enabled() bool

Enabled indicates if the mutation feature is enabled.

Types

type StatsReporter

type StatsReporter interface {
	ReportIterationConvergence(scs SystemConvergenceStatus, iterations int) error
}

StatsReporter reports mutator-related metrics.

func NewStatsReporter

func NewStatsReporter() StatsReporter

NewStatsReporter creates a reporter for webhook metrics.

type System

type System struct {
	// contains filtered or unexported fields
}

System keeps the list of mutators and provides an interface to apply mutations.

func NewSystem

func NewSystem(options SystemOpts) *System

NewSystem initializes an empty mutation system.

func (*System) Get

func (s *System) Get(id types.ID) types.Mutator

Get mutator for given id.

func (*System) GetConflicts

func (s *System) GetConflicts(id types.ID) map[types.ID]bool

func (*System) Mutate

func (s *System) Mutate(mutable *types.Mutable) (bool, error)

Mutate applies the mutation in place to the given object. Returns true if applying Mutators caused any changes to the object.

func (*System) Remove

func (s *System) Remove(id types.ID) error

Remove removes the mutator from the mutation system.

func (*System) Upsert

func (s *System) Upsert(m types.Mutator) error

Upsert updates or inserts the given object. Returns an error in case of schema conflicts.

type SystemConvergenceStatus

type SystemConvergenceStatus string

SystemConvergenceStatus defines the outcomes of the attempted mutation of an object by the mutation System. The System is meant to converge on a fully mutated object.

const (
	// SystemConvergenceTrue denotes a successfully converged mutation system request.
	SystemConvergenceTrue SystemConvergenceStatus = "true"
	// SystemConvergenceFalse denotes an unsuccessfully converged mutation system request.
	SystemConvergenceFalse SystemConvergenceStatus = "false"
)

type SystemOpts

type SystemOpts struct {
	Reporter                          StatsReporter
	NewUUID                           func() uuid.UUID
	ProviderCache                     *externaldata.ProviderCache
	SendRequestToExternalDataProvider externaldata.SendRequestToProvider
	ClientCertWatcher                 *certwatcher.CertWatcher
}

SystemOpts allows for optional dependencies to be passed into the mutation System.

Directories

Path Synopsis
+kubebuilder:object:generate=true +groupName=match.gatekeeper.sh
+kubebuilder:object:generate=true +groupName=match.gatekeeper.sh
path
parser
Package parser provides a parser for a path specification language used in expressing Kubernetes object paths.
Package parser provides a parser for a path specification language used in expressing Kubernetes object paths.

Jump to

Keyboard shortcuts

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