common

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: Apache-2.0 Imports: 12 Imported by: 27

Documentation

Index

Constants

View Source
const (
	// InventoryLabel is the label stored on the ConfigMap
	// inventory object. The value of the label is a unique
	// identifier (by default a UUID), representing the set of
	// objects applied at the same time as the inventory object.
	// This inventory object is used for pruning and deletion.
	InventoryLabel = "cli-utils.sigs.k8s.io/inventory-id"
	// InventoryHash defines an annotation which stores the hash of
	// the set of objects applied at the same time as the inventory
	// object. This annotation is set on the inventory object at the
	// time of the apply. The hash is computed from the sorted strings
	// of the applied object's metadata (ObjMetadata). The hash is
	// used as a suffix of the inventory object name. Example:
	//   inventory-1e5824fb
	InventoryHash = "cli-utils.sigs.k8s.io/inventory-hash"
	// Resource lifecycle annotation key for "on-remove" operations.
	OnRemoveAnnotation = "cli-utils.sigs.k8s.io/on-remove"
	// Resource lifecycle annotation value to prevent deletion.
	OnRemoveKeep = "keep"

	// DefaultFieldManager is default owner of applied fields in
	// server-side apply.
	DefaultFieldManager = "kubectl"

	// LifecycleDeletionAnnotation is the lifecycle annotation key for deletion operation.
	LifecycleDeleteAnnotation = "client.lifecycle.config.k8s.io/deletion"

	// PreventDeletion is the value used with LifecycleDeletionAnnotation
	// to prevent deleting a resource.
	PreventDeletion = "detach"
)

Variables

Functions

func DemandOneDirectory

func DemandOneDirectory(paths []string) (genericclioptions.FileNameFlags, error)

DemandOneDirectoryOrStdin processes "paths" to ensure the single argument in the array is a directory. Returns FileNameFlags populated with the directory (recursive flag set), or the StdIn dash. An empty array gets treated as StdIn (adding dash to the array). Returns an error if more than one element in the array or the filepath is not a directory.

func ExpandDir added in v0.21.0

func ExpandDir(dir string) (string, []string, error)

ExpandDir takes a single package directory as a parameter, and returns the inventory template filepath and an array of config file paths. If no inventory template file, then the first return value is an empty string. Returns an error if one occurred while processing the paths.

func ExpandPackageDir

ExpandPackageDir expands the one package directory entry in the flags to all the config file paths recursively. Excludes the inventory object (since this object is specially processed). Used for the diff command, so it will not always show a diff of the inventory object. Must be called AFTER DemandOneDirectory.

func FilterInputFile added in v0.13.0

func FilterInputFile(in io.Reader, tmpDir string) error

FilterInputFile copies the resource config on stdin into a file at the tmpDir, filtering the inventory object. It is the responsibility of the caller to clean up the tmpDir. Returns an error if one occurs.

func IsDir added in v0.20.3

func IsDir(dir string) bool

func NoDeletion added in v0.21.1

func NoDeletion(key, value string) bool

NoDeletion checks the passed in annotation key and value and returns true if that matches with the prevent deletion annotation.

func RandomStr added in v0.18.0

func RandomStr() string

RandomStr returns an eight-digit (with leading zeros) string of a random number.

Types

type DryRunStrategy added in v0.18.0

type DryRunStrategy int
const (
	// DryRunNone indicates the client will make all mutating calls
	DryRunNone DryRunStrategy = iota

	// DryRunClient, or client-side dry-run, indicates the client will prevent
	// making mutating calls such as CREATE, PATCH, and DELETE
	DryRunClient

	// DryRunServer, or server-side dry-run, indicates the client will send
	// mutating calls to the APIServer with the dry-run parameter to prevent
	// persisting changes.
	//
	// Note that clients sending server-side dry-run calls should verify that
	// the APIServer and the resource supports server-side dry-run, and otherwise
	// clients should fail early.
	//
	// If a client sends a server-side dry-run call to an APIServer that doesn't
	// support server-side dry-run, then the APIServer will persist changes inadvertently.
	DryRunServer
)

func (DryRunStrategy) ClientDryRun added in v0.18.0

func (drs DryRunStrategy) ClientDryRun() bool

ClientDryRun returns true if input drs is DryRunClient

func (DryRunStrategy) ClientOrServerDryRun added in v0.18.0

func (drs DryRunStrategy) ClientOrServerDryRun() bool

ClientOrServerDryRun returns true if input drs is either client or server dry run

func (DryRunStrategy) ServerDryRun added in v0.18.0

func (drs DryRunStrategy) ServerDryRun() bool

ServerDryRun returns true if input drs is DryRunServer

func (DryRunStrategy) Strategy added in v0.21.1

func (drs DryRunStrategy) Strategy() cmdutil.DryRunStrategy

Strategy returns the

func (DryRunStrategy) String added in v0.26.0

func (i DryRunStrategy) String() string

type ServerSideOptions added in v0.21.0

type ServerSideOptions struct {
	// ServerSideApply means the merge patch is calculated on the API server instead of the client.
	ServerSideApply bool

	// ForceConflicts overwrites the fields when applying if the field manager differs.
	ForceConflicts bool

	// FieldManager identifies the client "owner" of the applied fields (e.g. kubectl)
	FieldManager string
}

ServerSideOptions encapsulates the fields to implement server-side apply.

Jump to

Keyboard shortcuts

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