prune

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2020 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearInventoryObj added in v0.8.0

func ClearInventoryObj(infos []*resource.Info) error

ClearInventoryObj finds the inventory object in the list of objects, and sets an empty inventory. Returns error if the inventory object is not Unstructured, the inventory object does not exist, or if we can't set the empty inventory on the inventory object. If successful, returns nil.

func CreateInventoryObj added in v0.8.0

func CreateInventoryObj(inventory Inventory, resources []*resource.Info) (*resource.Info, error)

CreateInventoryObj creates an inventory object based on a inventory object template. The passed "resources" parameter are applied at the same time as the inventory object, and metadata for each is stored in the inventory object.

func FindInventoryObj added in v0.8.0

func FindInventoryObj(infos []*resource.Info) (*resource.Info, bool)

FindInventoryObj returns the "Inventory" object (ConfigMap with inventory label) if it exists, and a boolean describing if it was found.

func IsInventoryObject added in v0.8.0

func IsInventoryObject(obj runtime.Object) bool

IsInventoryObject returns true if the passed object has the inventory label.

func RetrieveObjsFromInventory added in v0.9.0

func RetrieveObjsFromInventory(infos []*resource.Info) ([]*object.ObjMetadata, error)

RetrieveObjsFromInventoryObj returns a slice of pointers to the object metadata. This function finds the inventory object, then parses the stored resource metadata into ObjMetadata structs. Returns an error if there is a problem parsing the data into ObjMetadata structs, or if the inventory object is not in Unstructured format; nil otherwise. If a inventory object does not exist, or it does not have a "data" map, then returns an empty slice and no error.

func UnionPastObjs added in v0.10.0

func UnionPastObjs(pastInvs []Inventory) ([]object.ObjMetadata, error)

UnionPastObjs takes a set of inventory objects (infos), returning the union of the objects referenced by these inventory objects. Returns an error if any of the passed objects are not inventory objects, or if unable to retrieve the referenced objects from any inventory object.

Types

type Inventory

type Inventory interface {
	// Load retrieves the set of object metadata from the inventory object
	Load() ([]object.ObjMetadata, error)
	// Store the set of object metadata in the inventory object
	Store(objs []object.ObjMetadata) error
	// GetObject returns the object that stores the inventory
	GetObject() (*resource.Info, error)
}

Inventory describes methods necessary for an object which can persist the object metadata for pruning and other group operations.

func WrapInventoryObj added in v0.13.0

func WrapInventoryObj(info *resource.Info) Inventory

WrapInventoryObj takes a passed ConfigMap (as a resource.Info), wraps it with the InventoryConfigMap and upcasts the wrapper as an the Inventory interface.

type InventoryConfigMap added in v0.13.0

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

InventoryConfigMap wraps a ConfigMap resource and implements the Inventory interface. This wrapper loads and stores the object metadata (inventory) to and from the wrapped ConfigMap.

func (*InventoryConfigMap) GetObject added in v0.13.0

func (icm *InventoryConfigMap) GetObject() (*resource.Info, error)

GetObject returns the wrapped object (ConfigMap) as a resource.Info or an error if one occurs.

func (*InventoryConfigMap) Load added in v0.13.0

func (icm *InventoryConfigMap) Load() ([]object.ObjMetadata, error)

Load is an Inventory interface function returning the set of object metadata from the wrapped ConfigMap, or an error.

func (*InventoryConfigMap) Store added in v0.13.0

func (icm *InventoryConfigMap) Store(objMetas []object.ObjMetadata) error

Store is an Inventory interface function implemented to store the object metadata in the wrapped ConfigMap. Actual storing happens in "GetObject".

type MultipleInventoryObjError added in v0.9.0

type MultipleInventoryObjError struct {
	InventoryObjectTemplates []*resource.Info
}

func (MultipleInventoryObjError) Error added in v0.9.0

type NoInventoryObjError added in v0.9.0

type NoInventoryObjError struct{}

func (NoInventoryObjError) Error added in v0.9.0

func (g NoInventoryObjError) Error() string

type Options added in v0.8.0

type Options struct {
	// DryRun defines whether objects should actually be pruned or if
	// we should just print what would happen without actually doing it.
	DryRun bool

	PropagationPolicy metav1.DeletionPropagation
}

Options defines a set of parameters that can be used to tune the behavior of the pruner.

type PruneOptions

type PruneOptions struct {

	// InventoryFactoryFunc wraps and returns an interface for the
	// object which will load and store the inventory.
	InventoryFactoryFunc func(*resource.Info) Inventory
	// contains filtered or unexported fields
}

PruneOptions encapsulates the necessary information to implement the prune functionality.

func NewPruneOptions

func NewPruneOptions(currentUids sets.String) *PruneOptions

NewPruneOptions returns a struct (PruneOptions) encapsulating the necessary information to run the prune. Returns an error if an error occurs gathering this information.

func (*PruneOptions) GetPreviousInventoryObjects added in v0.13.0

func (po *PruneOptions) GetPreviousInventoryObjects(currentInv *resource.Info) ([]Inventory, error)

GetPreviousInventoryObjects returns the set of inventory objects that have the same label as the current inventory object. Removes the current inventory object from this set. Returns an error if there is a problem retrieving the inventory objects.

func (*PruneOptions) Initialize

func (po *PruneOptions) Initialize(factory util.Factory) error

func (*PruneOptions) Prune

func (po *PruneOptions) Prune(currentObjects []*resource.Info, eventChannel chan<- event.Event, o Options) error

Prune deletes the set of resources which were previously applied (retrieved from previous inventory objects) but omitted in the current apply. Prune also delete all previous inventory objects. Returns an error if there was a problem.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳