prune

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2020 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const (
	GroupingLabel = "cli-utils.sigs.k8s.io/inventory-id"
	GroupingHash  = "cli-utils.sigs.k8s.io/inventory-hash"
)

Variables

This section is empty.

Functions

func AddInventoryToGroupingObj

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

Adds the inventory of all objects (passed as infos) to the grouping object. Returns an error if a grouping object does not exist, or we are unable to successfully add the inventory to the grouping object; nil otherwise. Each object is in unstructured.Unstructured format.

func ClearGroupingObj

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

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

func CreateGroupingObj added in v0.5.0

func CreateGroupingObj(groupingObjectTemplate *resource.Info,
	resources []*resource.Info) (*resource.Info, error)

CreateGroupingObj creates a grouping object based on a grouping object template and the set of resources that will be in the inventory.

func FindGroupingObject

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

FindGroupingObject returns the "Grouping" object (ConfigMap with grouping label) if it exists, and a boolean describing if it was found.

func IsGroupingObject

func IsGroupingObject(obj runtime.Object) bool

IsGroupingObject returns true if the passed object has the grouping label. TODO(seans3): Check type is ConfigMap.

func RetrieveInventoryFromGroupingObj

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

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

Types

type Inventory

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

Inventory encapsulates a grouping of unique Inventory structs. Organizes the Inventory structs with a map, which ensures there are no duplicates. Allows set operations such as merging sets and subtracting sets.

func NewInventory

func NewInventory(items []*object.ObjMetadata) *Inventory

NewInventory returns a pointer to an Inventory struct grouping the passed Inventory items.

func (*Inventory) AddItems

func (is *Inventory) AddItems(items []*object.ObjMetadata)

AddItems adds Inventory structs to the set which are not already in the set.

func (*Inventory) DeleteItem

func (is *Inventory) DeleteItem(item *object.ObjMetadata) bool

DeleteItem removes an ObjMetadata struct from the set if it exists in the set. Returns true if the ObjMetadata item was deleted, false if it did not exist in the set.

func (*Inventory) Equals

func (is *Inventory) Equals(other *Inventory) bool

Equals returns true if the "other" inventory set is the same as this current inventory set. Relies on the fact that the inventory items are sorted for the String() function.

func (*Inventory) GetItems

func (is *Inventory) GetItems() []*object.ObjMetadata

GetItems returns the set of pointers to ObjMetadata structs.

func (*Inventory) Merge

func (is *Inventory) Merge(other *Inventory) (*Inventory, error)

Merge combines the unique set of ObjMetadata items from the current set with the passed "other" set, returning a new set or error. Returns an error if the passed set to merge is nil.

func (*Inventory) Size

func (is *Inventory) Size() int

Size returns the number of ObjMetadata structs in the set.

func (*Inventory) String

func (is *Inventory) String() string

String returns a string describing set of ObjMetadata structs.

func (*Inventory) Subtract

func (is *Inventory) Subtract(other *Inventory) (*Inventory, error)

Subtract removes the Inventory items in the "other" set from the current set, returning a new set. This does not modify the current set. Returns an error if the passed set to subtract is nil.

type MultipleGroupingObjError added in v0.5.0

type MultipleGroupingObjError struct {
	GroupingObjectTemplates []*resource.Info
}

func (MultipleGroupingObjError) Error added in v0.5.0

func (g MultipleGroupingObjError) Error() string

type NoGroupingObjError added in v0.1.3

type NoGroupingObjError struct{}

func (NoGroupingObjError) Error added in v0.1.3

func (g NoGroupingObjError) Error() string

type PruneOptions

type PruneOptions struct {
	DryRun bool
	// contains filtered or unexported fields
}

PruneOptions encapsulates the necessary information to implement the prune functionality.

func NewPruneOptions

func NewPruneOptions() *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) Initialize

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

func (*PruneOptions) Prune

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

Prune deletes the set of resources which were previously applied (retrieved from previous grouping objects) but omitted in the current apply. Prune also delete all previous grouping 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