Documentation
¶
Index ¶
- func AddObjsToInventory(infos []*resource.Info) error
- func ClearInventoryObj(infos []*resource.Info) error
- func CreateInventoryObj(inventory Inventory, resources []*resource.Info) (*resource.Info, error)
- func FindInventoryObj(infos []*resource.Info) (*resource.Info, bool)
- func IsInventoryObject(obj runtime.Object) bool
- func RetrieveObjsFromInventory(infos []*resource.Info) ([]*object.ObjMetadata, error)
- func UnionPastObjs(pastInvs []*resource.Info) ([]object.ObjMetadata, error)
- type ClusterInventoryClient
- type FakeInventoryClient
- type Inventory
- type InventoryClient
- type InventoryConfigMap
- type MultipleInventoryObjError
- type NoInventoryObjError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddObjsToInventory ¶
Adds the metadata of all objects (passed as infos) to the inventory object. Returns an error if a inventory object does not exist, or we are unable to successfully add the metadata to the inventory object; nil otherwise. Each object is in unstructured.Unstructured format.
func ClearInventoryObj ¶
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 ¶
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 ¶
FindInventoryObj returns the "Inventory" object (ConfigMap with inventory label) if it exists, and a boolean describing if it was found.
func IsInventoryObject ¶
IsInventoryObject returns true if the passed object has the inventory label.
func RetrieveObjsFromInventory ¶
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 ¶
func UnionPastObjs(pastInvs []*resource.Info) ([]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 ClusterInventoryClient ¶
type ClusterInventoryClient struct {
// contains filtered or unexported fields
}
ClusterInventoryClient is a concrete implementation of the InventoryClient interface.
func NewInventoryClient ¶
func NewInventoryClient(factory util.Factory) (*ClusterInventoryClient, error)
NewInventoryClient returns a concrete implementation of the InventoryClient interface or an error.
func (*ClusterInventoryClient) GetPreviousInventoryObjects ¶
func (cic *ClusterInventoryClient) GetPreviousInventoryObjects(currentInv *resource.Info) ([]*resource.Info, 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 (*ClusterInventoryClient) GetStoredObjRefs ¶
func (cic *ClusterInventoryClient) GetStoredObjRefs(currentInv *resource.Info) ([]object.ObjMetadata, error)
GetStoredObjRefs returns the set of previously applied objects as ObjMetadata, or an error if one occurred. This set of previously applied object references is stored in the inventory objects living in the cluster. Uses information from the current inventory object to find the previously applied inventory objects.
type FakeInventoryClient ¶
type FakeInventoryClient struct {
// contains filtered or unexported fields
}
FakeInventoryClient is a testing implementation of the InventoryClient interface.
func NewFakeInventoryClient ¶
func NewFakeInventoryClient(prevInventories []*resource.Info) *FakeInventoryClient
NewFakeInventoryClient returns a FakeInventoryClient.
func (*FakeInventoryClient) GetPreviousInventoryObjects ¶
func (fic *FakeInventoryClient) GetPreviousInventoryObjects(currentInv *resource.Info) ([]*resource.Info, error)
GetPreviousInventoryObjects returns the hard-coded set of resource infos. This function ensures the fake implements the InventoryClient interface.
func (*FakeInventoryClient) GetStoredObjRefs ¶
func (fic *FakeInventoryClient) GetStoredObjRefs(currentInv *resource.Info) ([]object.ObjMetadata, error)
GetStoredObjRefs returns the union of hard-coded object references stored in the prevInventories.
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 ¶
WrapInventoryObj takes a passed ConfigMap (as a resource.Info), wraps it with the InventoryConfigMap and upcasts the wrapper as an the Inventory interface.
type InventoryClient ¶
type InventoryClient interface { // GetPreviousInventoryObjects returns the inventory objects (as *resource.Info) // that are currently stored in the cluster, or an error if one occurred. Uses // information from the current (recently) created inventory object to find // the previously applied inventory object in the cluster. GetPreviousInventoryObjects(currentInv *resource.Info) ([]*resource.Info, error) // GetStoredObjRefs returns the set of previously applied objects as ObjMetadata, // or an error if one occurred. This set of previously applied object references // is stored in the inventory objects living in the cluster. Uses information // from the current inventory object to find the previously applied inventory // objects. GetStoredObjRefs(currentInv *resource.Info) ([]object.ObjMetadata, error) }
InventoryClient expresses an interface for retrieving Inventory objects in the clus
type InventoryConfigMap ¶
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 ¶
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 ¶
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 ¶
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 ¶
func (MultipleInventoryObjError) Error ¶
func (g MultipleInventoryObjError) Error() string
type NoInventoryObjError ¶
type NoInventoryObjError struct{}
func (NoInventoryObjError) Error ¶
func (g NoInventoryObjError) Error() string