prune

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2020 License: Apache-2.0 Imports: 17 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 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 PrependGroupingObject

func PrependGroupingObject(o *apply.ApplyOptions) func() error

PrependGroupingObject orders the objects to apply so the "grouping" object stores the inventory, and it is first to be applied.

func SortGroupingObject

func SortGroupingObject(infos []*resource.Info) bool

SortGroupingObject reorders the infos slice to place the grouping object in the first position. Returns true if grouping object found, false otherwise.

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 []*ObjMetadata) *Inventory

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

func (*Inventory) AddItems

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

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

func (*Inventory) DeleteItem

func (is *Inventory) DeleteItem(item *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() []*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 ObjMetadata

type ObjMetadata struct {
	Namespace string
	Name      string
	GroupKind schema.GroupKind
}

ObjMetadata organizes and stores the indentifying information for an object. This struct (as a string) is stored in a grouping object to keep track of sets of applied objects.

func RetrieveInventoryFromGroupingObj

func RetrieveInventoryFromGroupingObj(infos []*resource.Info) ([]*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.

func (*ObjMetadata) Equals

func (o *ObjMetadata) Equals(other *ObjMetadata) bool

Equals returns true if the ObjMetadata structs are identical; false otherwise.

func (*ObjMetadata) String

func (o *ObjMetadata) String() string

String create a string version of the ObjMetadata struct.

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, namespace string) 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