apply

package
v0.0.0-...-4d57693 Latest Latest
Warning

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

Go to latest
Published: May 12, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package apply is a client-side substitute for `Kubernetes server side apply`. It tries to guess the right thing to do without any type-specific knowledge. Instead of generating a PATCH request, it does the patching locally and returns a full object with the ResourceVersion intact.

credit: https://github.com/AmitKumarDas/metac/tree/master/dynamic/apply

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLastApplied

func GetLastApplied(obj *unstructured.Unstructured) (map[string]interface{}, error)

GetLastApplied returns the last applied state of the given object. Last applied state is derived based on a predefined annotation key to store last applied state.

func GetLastAppliedByAnnKey

func GetLastAppliedByAnnKey(obj *unstructured.Unstructured, annKey string) (map[string]interface{}, error)

GetLastAppliedByAnnKey returns the last applied state of the given object based on the provided annotation

func Merge

func Merge(observed, lastApplied, desired map[string]interface{}) (map[string]interface{}, error)

Merge updates the observed object with the desired changes. Merge is based on a 3-way apply that takes in observed state, last applied state & desired state into consideration.

func SanitizeLastAppliedByAnnKey

func SanitizeLastAppliedByAnnKey(last map[string]interface{}, annKey string)

SanitizeLastAppliedByAnnKey sanitizes the last applied state by removing last applied state related info (i.e. its own info) to avoid building up of nested last applied states.

In other words, last applied state might have an annotation that stores the previous last applied state which in turn might have an annotation that stores the previous to previous last applied state. This nested annotation gets added everytime a reconcile event happens for the resource that needs to be applied against Kubernetes cluster.

func SetLastApplied

func SetLastApplied(obj *unstructured.Unstructured, lastApplied map[string]interface{}) error

SetLastApplied sets the last applied state against a predefined annotation key

func SetLastAppliedByAnnKey

func SetLastAppliedByAnnKey(
	obj *unstructured.Unstructured,
	lastApplied map[string]interface{},
	annKey string,
) error

SetLastAppliedByAnnKey sets the last applied state against the provided annotation key

Types

This section is empty.

Jump to

Keyboard shortcuts

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