managedfields

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2024 License: Apache-2.0 Imports: 14 Imported by: 617

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractInto

func ExtractInto(object runtime.Object, objectType typed.ParseableType, fieldManager string, applyConfiguration interface{}, subresource string) error

ExtractInto extracts the applied configuration state from object for fieldManager into applyConfiguration. If no managed fields are found for the given fieldManager, no error is returned, but applyConfiguration is left unpopulated. It is possible that no managed fields were found for the fieldManager because other field managers have taken ownership of all the fields previously owned by the fieldManager. It is also possible the fieldManager never owned fields.

The provided object MUST bo a root resource object since subresource objects do not contain their own managed fields. For example, an autoscaling.Scale object read from a "scale" subresource does not have any managed fields and so cannot be used as the object.

If the fields of a subresource are a subset of the fields of the root object, and their field paths and types are exactly the same, then ExtractInto can be called with the root resource as the object and the subresource as the applyConfiguration. This works for "status", obviously, because status is represented by the exact same object as the root resource. This does NOT work, for example, with the "scale" subresources of Deployment, ReplicaSet and StatefulSet. While the spec.replicas, status.replicas fields are in the same exact field path locations as they are in autoscaling.Scale, the selector fields are in different locations, and are a different type.

func ValidateManagedFields added in v0.27.0

func ValidateManagedFields(encodedManagedFields []metav1.ManagedFieldsEntry) error

Types

type FieldManager added in v0.27.0

type FieldManager = internal.FieldManager

FieldManager updates the managed fields and merges applied configurations.

func NewDefaultCRDFieldManager added in v0.27.0

func NewDefaultCRDFieldManager(typeConverter TypeConverter, objectConverter runtime.ObjectConvertor, objectDefaulter runtime.ObjectDefaulter, objectCreater runtime.ObjectCreater, kind schema.GroupVersionKind, hub schema.GroupVersion, subresource string, resetFields map[fieldpath.APIVersion]*fieldpath.Set) (_ *FieldManager, err error)

NewDefaultCRDFieldManager creates a new FieldManager specifically for CRDs. This allows for the possibility of fields which are not defined in models, as well as having no models defined at all.

func NewDefaultFieldManager added in v0.27.0

func NewDefaultFieldManager(typeConverter TypeConverter, objectConverter runtime.ObjectConvertor, objectDefaulter runtime.ObjectDefaulter, objectCreater runtime.ObjectCreater, kind schema.GroupVersionKind, hub schema.GroupVersion, subresource string, resetFields map[fieldpath.APIVersion]*fieldpath.Set) (*FieldManager, error)

NewDefaultFieldManager creates a new FieldManager that merges apply requests and update managed fields for other types of requests.

type GvkParser added in v0.23.0

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

GvkParser contains a Parser that allows introspecting the schema.

func NewGVKParser added in v0.23.0

func NewGVKParser(models proto.Models, preserveUnknownFields bool) (*GvkParser, error)

NewGVKParser builds a GVKParser from a proto.Models. This will automatically find the proper version of the object, and the corresponding schema information.

func (*GvkParser) Type added in v0.23.0

Type returns a helper which can produce objects of the given type. Any errors are deferred until a further function is called.

type ResourcePathMappings added in v0.27.0

type ResourcePathMappings map[string]fieldpath.Path

ResourcePathMappings maps a group/version to its replicas path. The assumption is that all the paths correspond to leaf fields.

type ScaleHandler added in v0.27.0

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

ScaleHandler manages the conversion of managed fields between a main resource and the scale subresource

func NewScaleHandler added in v0.27.0

func NewScaleHandler(parentEntries []metav1.ManagedFieldsEntry, groupVersion schema.GroupVersion, mappings ResourcePathMappings) *ScaleHandler

NewScaleHandler creates a new ScaleHandler

func (*ScaleHandler) ToParent added in v0.27.0

func (h *ScaleHandler) ToParent(scaleEntries []metav1.ManagedFieldsEntry) ([]metav1.ManagedFieldsEntry, error)

ToParent merges `scaleEntries` with the entries of the main resource and transforms them accordingly

func (*ScaleHandler) ToSubresource added in v0.27.0

func (h *ScaleHandler) ToSubresource() ([]metav1.ManagedFieldsEntry, error)

ToSubresource filter the managed fields of the main resource and convert them so that they can be handled by scale. For the managed fields that have a replicas path it performs two changes:

  1. APIVersion is changed to the APIVersion of the scale subresource
  2. Replicas path of the main resource is transformed to the replicas path of the scale subresource

type TypeConverter added in v0.27.0

type TypeConverter = internal.TypeConverter

TypeConverter allows you to convert from runtime.Object to typed.TypedValue and the other way around.

func NewDeducedTypeConverter added in v0.27.0

func NewDeducedTypeConverter() TypeConverter

NewDeducedTypeConverter creates a TypeConverter for CRDs that don't have a schema. It does implement the same interface though (and create the same types of objects), so that everything can still work the same. CRDs are merged with all their fields being "atomic" (lists included).

func NewTypeConverter added in v0.27.0

func NewTypeConverter(openapiSpec map[string]*spec.Schema, preserveUnknownFields bool) (TypeConverter, error)

NewTypeConverter builds a TypeConverter from a map of OpenAPIV3 schemas. This will automatically find the proper version of the object, and the corresponding schema information. The keys to the map must be consistent with the names used by Refs within the schemas. The schemas should conform to the Kubernetes Structural Schema OpenAPI restrictions found in docs: https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#specifying-a-structural-schema

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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