apply

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: LGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LabelRenderHash is the label that record the hash value of the rendering resource.
	LabelRenderHash = "oam.dev/render-hash"
)

Variables

This section is empty.

Functions

func AddLabels

func AddLabels(o labelAnnotationObject, labels map[string]string)

AddLabels will merge labels with existing labels. If any conflict keys, use new value to override existing value.

func ComputeSpecHash

func ComputeSpecHash(spec interface{}) (string, error)

ComputeSpecHash computes the hash value of a k8s resource spec

func MergeMapOverrideWithDst

func MergeMapOverrideWithDst(src, dst map[string]string) map[string]string

MergeMapOverrideWithDst merges two could be nil maps. Keep the dst for any conflicts,

Types

type APIApplicator

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

APIApplicator implements Applicator

func NewAPIApplicator

func NewAPIApplicator(c client.Client) *APIApplicator

NewAPIApplicator creates an Applicator that applies state to an object or creates the object if not exist.

func (*APIApplicator) Apply

func (a *APIApplicator) Apply(ctx context.Context, desired client.Object, ao ...ApplyOption) error

Apply applies new state to an object or create it if not exist

type Applicator

type Applicator interface {
	Apply(context.Context, client.Object, ...ApplyOption) error
}

Applicator applies new state to an object or create it if not exist. It uses the same mechanism as `kubectl apply`, that is, for each resource being applied, computing a three-way diff merge in client side based on its current state, modified stated, and last-applied-state which is tracked through an specific annotation. If the resource doesn't exist before, Apply will create it.

type ApplyOption

type ApplyOption func(act *applyAction, existing, desired client.Object) error

ApplyOption is called before applying state to the object. ApplyOption is still called even if the object does NOT exist. If the object does not exist, `existing` will be assigned as `nil`. nolint: golint

func DisableUpdateAnnotation

func DisableUpdateAnnotation() ApplyOption

DisableUpdateAnnotation disable write last config to annotation

func MakeCustomApplyOption

func MakeCustomApplyOption(f func(existing, desired client.Object) error) ApplyOption

MakeCustomApplyOption let user can generate applyOption that restrict change apply action.

func MustBeControllableBy

func MustBeControllableBy(u types.UID) ApplyOption

MustBeControllableBy requires that the new object is controllable by an object with the supplied UID. An object is controllable if its controller reference includes the supplied UID.

func MustBeControlledByApp

func MustBeControlledByApp(app *v1beta1.Application) ApplyOption

MustBeControlledByApp requires that the new object is controllable by versioned resourcetracker

func NotUpdateRenderHashEqual

func NotUpdateRenderHashEqual() ApplyOption

NotUpdateRenderHashEqual if the render hash of new object equal to the old hash, should not apply.

Jump to

Keyboard shortcuts

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