Documentation ¶
Overview ¶
Package fieldmanager is a special package as its main purpose is to expose the dependencies required by structured-merge-diff library to calculate diffs when server-side apply option is enabled. The dependency tree necessary to have a `merge.Updater` instance isn't trivial to implement and the strategy used is borrowing a copy from Kubernetes apiserver codebase in order to expose the required functionality.
Below there is a list of borrowed files and a reference to which package/file in Kubernetes they were copied from:
- borrowed_fields.go: k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/internal/fields.go - borrowed_managedfields.go: k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/internal/managedfields.go - borrowed_typeconverter.go: k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/typeconverter.go - borrowed_versionconverter.go: k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/versionconverter.go
In order to keep maintenance as minimal as possible the borrowed files are verbatim copy from Kubernetes. The private objects that need to be exposed are wrapped in the wrapper.go file. Updating the borrowed files should be trivial in most cases but must be done manually as we have no control over future refactorings Kubernetes might do.
Index ¶
- Variables
- func BuildManagerIdentifier(encodedManager *metav1.ManagedFieldsEntry) (manager string, err error)
- func EncodeObjectManagedFields(obj runtime.Object, managed ManagedInterface) error
- func FieldsToSet(f metav1.FieldsV1) (s fieldpath.Set, err error)
- func NewVersionConverter(gvkParser *managedfields.GvkParser, o runtime.ObjectConvertor, ...) merge.Converter
- func RemoveObjectManagedFields(obj runtime.Object)
- func SetToFields(s fieldpath.Set) (f metav1.FieldsV1, err error)
- type DeducedTypeConverter
- type ManagedInterface
- type TypeConverter
Constants ¶
This section is empty.
Variables ¶
var EmptyFields = func() metav1.FieldsV1 { f, err := SetToFields(*fieldpath.NewSet()) if err != nil { panic("should never happen") } return f }()
EmptyFields represents a set with no paths It looks like metav1.Fields{Raw: []byte("{}")}
Functions ¶
func BuildManagerIdentifier ¶
func BuildManagerIdentifier(encodedManager *metav1.ManagedFieldsEntry) (manager string, err error)
BuildManagerIdentifier creates a manager identifier string from a ManagedFieldsEntry
func EncodeObjectManagedFields ¶
func EncodeObjectManagedFields(obj runtime.Object, managed ManagedInterface) error
EncodeObjectManagedFields converts and stores the fieldpathManagedFields into the objects ManagedFields
func FieldsToSet ¶
FieldsToSet creates a set paths from an input trie of fields
func NewVersionConverter ¶
func NewVersionConverter(gvkParser *managedfields.GvkParser, o runtime.ObjectConvertor, h schema.GroupVersion) merge.Converter
NewVersionConverter will expose the version converter from the borrowed private function from k8s apiserver handler.
func RemoveObjectManagedFields ¶
RemoveObjectManagedFields removes the ManagedFields from the object before we merge so that it doesn't appear in the ManagedFields recursively.
Types ¶
type DeducedTypeConverter ¶
type DeducedTypeConverter struct{}
DeducedTypeConverter is 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).
Note that this is not going to be sufficient for converting to/from CRDs that have a schema defined (we don't support that schema yet). TODO(jennybuckley): Use the schema provided by a CRD if it exists.
func (DeducedTypeConverter) ObjectToTyped ¶
func (DeducedTypeConverter) ObjectToTyped(obj runtime.Object) (*typed.TypedValue, error)
ObjectToTyped converts an object into a TypedValue with a "deduced type".
func (DeducedTypeConverter) TypedToObject ¶
func (DeducedTypeConverter) TypedToObject(value *typed.TypedValue) (runtime.Object, error)
TypedToObject transforms the typed value into a runtime.Object. That is not specific to deduced type.
type ManagedInterface ¶
type ManagedInterface interface { // Fields gets the fieldpath.ManagedFields. Fields() fieldpath.ManagedFields // Times gets the timestamps associated with each operation. Times() map[string]*metav1.Time }
ManagedInterface groups a fieldpath.ManagedFields together with the timestamps associated with each operation.
func DecodeManagedFields ¶
func DecodeManagedFields(encodedManagedFields []metav1.ManagedFieldsEntry) (ManagedInterface, error)
DecodeManagedFields converts ManagedFields from the wire format (api format) to the format used by sigs.k8s.io/structured-merge-diff
func NewEmptyManaged ¶
func NewEmptyManaged() ManagedInterface
NewEmptyManaged creates an empty ManagedInterface.
func NewManaged ¶
func NewManaged(f fieldpath.ManagedFields, t map[string]*metav1.Time) ManagedInterface
NewManaged creates a ManagedInterface from a fieldpath.ManagedFields and the timestamps associated with each operation.
type TypeConverter ¶
type TypeConverter interface { ObjectToTyped(runtime.Object) (*typed.TypedValue, error) TypedToObject(*typed.TypedValue) (runtime.Object, error) }
TypeConverter allows you to convert from runtime.Object to typed.TypedValue and the other way around.
func NewTypeConverter ¶
func NewTypeConverter(models proto.Models, preserveUnknownFields bool) (TypeConverter, error)
NewTypeConverter builds a TypeConverter from a proto.Models. This will automatically find the proper version of the object, and the corresponding schema information.