Documentation ¶
Index ¶
- Constants
- func AddInventoryToGroupingObj(infos []*resource.Info) error
- func ClearGroupingObj(infos []*resource.Info) error
- func FindGroupingObject(infos []*resource.Info) (*resource.Info, bool)
- func IsGroupingObject(obj runtime.Object) bool
- func PrependGroupingObject(o *apply.ApplyOptions) func() error
- func SortGroupingObject(infos []*resource.Info) bool
- type Inventory
- func (is *Inventory) AddItems(items []*ObjMetadata)
- func (is *Inventory) DeleteItem(item *ObjMetadata) bool
- func (is *Inventory) Equals(other *Inventory) bool
- func (is *Inventory) GetItems() []*ObjMetadata
- func (is *Inventory) Merge(other *Inventory) (*Inventory, error)
- func (is *Inventory) Size() int
- func (is *Inventory) String() string
- func (is *Inventory) Subtract(other *Inventory) (*Inventory, error)
- type ObjMetadata
- type PruneOptions
Constants ¶
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 ¶
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 ¶
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 ¶
FindGroupingObject returns the "Grouping" object (ConfigMap with grouping label) if it exists, and a boolean describing if it was found.
func IsGroupingObject ¶
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 ¶
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 ¶
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 ¶
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.
type ObjMetadata ¶
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.