apiextensions-apiserver: k8s.io/apiextensions-apiserver/pkg/apiserver/schema/defaulting Index | Files

package defaulting

import "k8s.io/apiextensions-apiserver/pkg/apiserver/schema/defaulting"

Index

Package Files

algorithm.go prune.go surroundingobject.go validation.go

func Default Uses

func Default(x interface{}, s *structuralschema.Structural)

Default does defaulting of x depending on default values in s. Default values from s are deep-copied.

func PruneDefaults Uses

func PruneDefaults(s *structuralschema.Structural) error

PruneDefaults prunes default values according to the schema and according to the ObjectMeta definition of the running server. It mutates the passed schema.

func ValidateDefaults Uses

func ValidateDefaults(pth *field.Path, s *structuralschema.Structural, isResourceRoot, requirePrunedDefaults bool) (field.ErrorList, error)

ValidateDefaults checks that default values validate and are properly pruned.

type AccessorFunc Uses

type AccessorFunc func(obj map[string]interface{}) (x interface{}, found bool, err error)

AccessorFunc returns a node x in obj on a fixed (implicitly encoded) JSON path if that path exists in obj (found==true). If it does not exist, found is false. If on the path the type of a field is wrong, an error is returned.

type SurroundingObjectFunc Uses

type SurroundingObjectFunc func(focus interface{}) (map[string]interface{}, AccessorFunc, error)

SurroundingObjectFunc is a surrounding object builder with a given x at a leaf. Which leave is determined by the series of Index() and Child(k) calls. It also returns the inverse of the builder, namely the accessor that extracts x from the test object.

With obj, acc, _ := someSurroundingObjectFunc(x) we get:

acc(obj) == x
reflect.DeepEqual(acc(DeepCopy(obj), x) == x

where x is the original instance for slices and maps.

If after computation of acc the node holding x in obj is mutated (e.g. pruned), the accessor will return that mutated node value (e.g. the pruned x).

Example (ignoring the last two return values):

NewRootObjectFunc()(x) == x
NewRootObjectFunc().Index()(x) == [x]
NewRootObjectFunc().Index().Child("foo") == [{"foo": x}]
NewRootObjectFunc().Index().Child("foo").Child("bar") == [{"foo": {"bar":x}}]
NewRootObjectFunc().Index().Child("foo").Child("bar").Index() == [{"foo": {"bar":[x]}}]

and:

NewRootObjectFunc(), then acc(x) == x
NewRootObjectFunc().Index(), then acc([x]) == x
NewRootObjectFunc().Index().Child("foo"), then acc([{"foo": x}]) == x
NewRootObjectFunc().Index().Child("foo").Child("bar"), then acc([{"foo": {"bar":x}}]) == x
NewRootObjectFunc().Index().Child("foo").Child("bar").Index(), then acc([{"foo": {"bar":[x]}}]) == x

func NewRootObjectFunc Uses

func NewRootObjectFunc() SurroundingObjectFunc

NewRootObjectFunc returns the identity function. The passed focus value must be an object.

func (SurroundingObjectFunc) Child Uses

func (f SurroundingObjectFunc) Child(k string) SurroundingObjectFunc

Child returns a function x => f({k: x}) and the corresponding accessor.

func (SurroundingObjectFunc) Index Uses

func (f SurroundingObjectFunc) Index() SurroundingObjectFunc

Index returns a function x => f([x]) and the corresponding accessor.

func (SurroundingObjectFunc) WithTypeMeta Uses

func (f SurroundingObjectFunc) WithTypeMeta(meta metav1.TypeMeta) SurroundingObjectFunc

WithTypeMeta returns a closure with the TypeMeta fields set if they are defined. This mutates f(x).

Package defaulting imports 11 packages (graph) and is imported by 2 packages. Updated 2019-09-06. Refresh now. Tools for package owners.