metaapply

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package metaapply changes the metadata of an existing object with a server-side apply.

An Applier writes only metadata, and it includes the uid of the object in each apply. Thus an apply cannot create an object, and it cannot change a different object with the same name. An Applier also does not write the complete object, so it cannot drop fields that a Go type does not model.

Each Applier has its own field manager, which ManagerFor makes from a purpose. An apply sets the complete set of fields that its manager owns, so a manager that also owns spec fields would lose them. Apply refuses to write if the manager owns fields outside metadata.

Index

Constants

This section is empty.

Variables

View Source
var ErrOwnsNonMetadata = errors.New("field manager owns fields outside metadata")

ErrOwnsNonMetadata is returned when the field manager of an Applier owns fields outside metadata.

Functions

func ManagerFor

func ManagerFor(purpose string) string

ManagerFor returns the field manager name for purpose. A purpose that is too long is shortened and given a hash suffix, so that different purposes give different names.

Types

type Applier

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

Applier applies metadata to objects of one resource.

func New

New returns an Applier for the resource gvr, whose kind is gvk. Its field manager is ManagerFor(purpose). Use a different purpose for each set of metadata fields.

func (*Applier) Apply

func (a *Applier) Apply(ctx context.Context, obj metav1.Object, set func(body *unstructured.Unstructured)) (*unstructured.Unstructured, error)

Apply applies the metadata that set writes. The body that set receives already has the kind, name, namespace, and uid of obj. Do not change them.

If the object is gone, Apply returns NotFound. If the managed fields of obj show that the manager owns fields outside metadata, Apply returns ErrOwnsNonMetadata and writes nothing. If obj has no managed fields, Apply cannot do this check.

func (*Applier) FieldManager

func (a *Applier) FieldManager() string

FieldManager returns the field manager name of the Applier.

Jump to

Keyboard shortcuts

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