Documentation ¶
Index ¶
- Constants
- func AddInventoryToGroupingObj(infos []*resource.Info) error
- func ClearGroupingObj(infos []*resource.Info) error
- func CreateGroupingObj(groupingObjectTemplate *resource.Info, resources []*resource.Info) (*resource.Info, error)
- func FindGroupingObject(infos []*resource.Info) (*resource.Info, bool)
- func IsGroupingObject(obj runtime.Object) bool
- func RetrieveInventoryFromGroupingObj(infos []*resource.Info) ([]*object.ObjMetadata, error)
- type Inventory
- func (is *Inventory) AddItems(items []*object.ObjMetadata)
- func (is *Inventory) DeleteItem(item *object.ObjMetadata) bool
- func (is *Inventory) Equals(other *Inventory) bool
- func (is *Inventory) GetItems() []*object.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 MultipleGroupingObjError
- type NoGroupingObjError
- 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 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 ¶
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 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 ¶
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 ¶
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 MultipleGroupingObjError ¶ added in v0.5.0
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.