mutator

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Deserializer  = codecs.UniversalDeserializer()
	InternalError = errors.New("internal admission controller error")
)

Functions

func Handler

func Handler(mutator Mutator) http.HandlerFunc

Types

type Mutator

type Mutator interface {
	Log(keyVals ...interface{})
	Mutate(ctx context.Context, review *v1beta1.AdmissionRequest) ([]PatchOperation, error)
	Resource() string
}

type PatchOperation

type PatchOperation struct {
	Operation string      `json:"op"`
	Path      string      `json:"path"`
	Value     interface{} `json:"value"`
}

PatchOperation specifies one JSONPatch operation. See [RFC6902](https://tools.ietf.org/html/rfc6902) for details.

func PatchAdd

func PatchAdd(path string, value interface{}) *PatchOperation

PatchAdd creates a patch operation of type "add".

The "add" operation performs one of the following functions, depending upon what the target location references:

  • If the target location specifies an array index, a new value is inserted into the array at the specified index.
  • If the target location specifies an object member that does not already exist, a new member is added to the object.
  • If the target location specifies an object member that does exist, that member's value is replaced.

func PatchReplace

func PatchReplace(path string, value interface{}) PatchOperation

PatchReplace creates a patch operation of type "replace".

Jump to

Keyboard shortcuts

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