Documentation ¶
Index ¶
- func FindInventoryObj(objs []*unstructured.Unstructured) *unstructured.Unstructured
- func InvInfoToConfigMap(inv InventoryInfo) *unstructured.Unstructured
- func IsInventoryObject(obj *unstructured.Unstructured) bool
- func SplitUnstructureds(objs []*unstructured.Unstructured) (*unstructured.Unstructured, []*unstructured.Unstructured, error)
- func ValidateNoInventory(objs []*unstructured.Unstructured) error
- type ClusterInventoryClient
- func (cic *ClusterInventoryClient) ApplyInventoryNamespace(obj *unstructured.Unstructured) error
- func (cic *ClusterInventoryClient) DeleteInventoryObj(localInv InventoryInfo) error
- func (cic *ClusterInventoryClient) GetClusterObjs(localInv InventoryInfo) ([]object.ObjMetadata, error)
- func (cic *ClusterInventoryClient) Merge(localInv InventoryInfo, objs []object.ObjMetadata) ([]object.ObjMetadata, error)
- func (cic *ClusterInventoryClient) Replace(localInv InventoryInfo, objs []object.ObjMetadata) error
- func (cic *ClusterInventoryClient) SetDryRunStrategy(drs common.DryRunStrategy)
- type FakeBuilder
- type FakeInventoryClient
- func (fic *FakeInventoryClient) ApplyInventoryNamespace(inv *unstructured.Unstructured) error
- func (fic *FakeInventoryClient) ClearError()
- func (fic *FakeInventoryClient) DeleteInventoryObj(inv InventoryInfo) error
- func (fic *FakeInventoryClient) GetClusterObjs(inv InventoryInfo) ([]object.ObjMetadata, error)
- func (fic *FakeInventoryClient) Merge(inv InventoryInfo, objs []object.ObjMetadata) ([]object.ObjMetadata, error)
- func (fic *FakeInventoryClient) Replace(inv InventoryInfo, objs []object.ObjMetadata) error
- func (fic *FakeInventoryClient) SetDryRunStrategy(drs common.DryRunStrategy)
- func (fic *FakeInventoryClient) SetError(err error)
- type Inventory
- type InventoryClient
- type InventoryConfigMap
- func (icm *InventoryConfigMap) GetObject() (*unstructured.Unstructured, error)
- func (icm *InventoryConfigMap) ID() string
- func (icm *InventoryConfigMap) Load() ([]object.ObjMetadata, error)
- func (icm *InventoryConfigMap) Name() string
- func (icm *InventoryConfigMap) Namespace() string
- func (icm *InventoryConfigMap) Store(objMetas []object.ObjMetadata) error
- func (icm *InventoryConfigMap) UnstructuredInventory() *unstructured.Unstructured
- type InventoryFactoryFunc
- type InventoryInfo
- type InventoryNamespaceInSet
- type InventoryToUnstructuredFunc
- type MultipleInventoryObjError
- type NoInventoryObjError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindInventoryObj ¶
func FindInventoryObj(objs []*unstructured.Unstructured) *unstructured.Unstructured
FindInventoryObj returns the "Inventory" object (ConfigMap with inventory label) if it exists, or nil if it does not exist.
func InvInfoToConfigMap ¶ added in v0.22.0
func InvInfoToConfigMap(inv InventoryInfo) *unstructured.Unstructured
func IsInventoryObject ¶
func IsInventoryObject(obj *unstructured.Unstructured) bool
IsInventoryObject returns true if the passed object has the inventory label.
func SplitUnstructureds ¶ added in v0.21.0
func SplitUnstructureds(objs []*unstructured.Unstructured) (*unstructured.Unstructured, []*unstructured.Unstructured, error)
splitUnstructureds takes a slice of unstructured.Unstructured objects and splits it into one slice that contains the inventory object templates and another one that contains the remaining resources.
func ValidateNoInventory ¶ added in v0.21.1
func ValidateNoInventory(objs []*unstructured.Unstructured) error
ValidateNoInventory takes a slice of unstructured.Unstructured objects and validates that no inventory object is in the input slice.
Types ¶
type ClusterInventoryClient ¶
type ClusterInventoryClient struct { InventoryFactoryFunc InventoryFactoryFunc // contains filtered or unexported fields }
ClusterInventoryClient is a concrete implementation of the InventoryClient interface.
func NewInventoryClient ¶
func NewInventoryClient(factory cmdutil.Factory, invFunc InventoryFactoryFunc, invToUnstructuredFunc InventoryToUnstructuredFunc) (*ClusterInventoryClient, error)
NewInventoryClient returns a concrete implementation of the InventoryClient interface or an error.
func (*ClusterInventoryClient) ApplyInventoryNamespace ¶ added in v0.20.0
func (cic *ClusterInventoryClient) ApplyInventoryNamespace(obj *unstructured.Unstructured) error
ApplyInventoryNamespace creates the passed namespace if it does not already exist, or returns an error if one happened. NOTE: No error if already exists.
func (*ClusterInventoryClient) DeleteInventoryObj ¶ added in v0.18.0
func (cic *ClusterInventoryClient) DeleteInventoryObj(localInv InventoryInfo) error
DeleteInventoryObj deletes the inventory object from the cluster.
func (*ClusterInventoryClient) GetClusterObjs ¶ added in v0.18.0
func (cic *ClusterInventoryClient) GetClusterObjs(localInv InventoryInfo) ([]object.ObjMetadata, error)
GetClusterObjs returns the objects stored in the cluster inventory object, or an error if one occurred.
func (*ClusterInventoryClient) Merge ¶ added in v0.18.0
func (cic *ClusterInventoryClient) Merge(localInv InventoryInfo, objs []object.ObjMetadata) ([]object.ObjMetadata, error)
Merge stores the union of the passed objects with the objects currently stored in the cluster inventory object. Retrieves and caches the cluster inventory object. Returns the set differrence of the cluster inventory objects and the currently applied objects. This is the set of objects to prune. Creates the initial cluster inventory object storing the passed objects if an inventory object does not exist. Returns an error if one occurred.
func (*ClusterInventoryClient) Replace ¶ added in v0.18.0
func (cic *ClusterInventoryClient) Replace(localInv InventoryInfo, objs []object.ObjMetadata) error
Replace stores the passed objects in the cluster inventory object, or an error if one occurred.
func (*ClusterInventoryClient) SetDryRunStrategy ¶ added in v0.18.0
func (cic *ClusterInventoryClient) SetDryRunStrategy(drs common.DryRunStrategy)
SetDryRun sets whether the inventory client will mutate the inventory object in the cluster.
type FakeBuilder ¶ added in v0.18.0
type FakeBuilder struct {
// contains filtered or unexported fields
}
FakeBuilder encapsulates a resource Builder which will hard-code the return of an inventory object with the encoded past invObjs.
func (*FakeBuilder) GetBuilder ¶ added in v0.18.0
func (fb *FakeBuilder) GetBuilder() func() *resource.Builder
Returns the fake resource Builder with the fake client, test restmapper, and the fake category expander.
func (*FakeBuilder) SetInventoryObjs ¶ added in v0.18.0
func (fb *FakeBuilder) SetInventoryObjs(objs []object.ObjMetadata)
SetInventoryObjs sets the objects which will be encoded in an inventory object to be returned when queried for the cluster inventory object.
type FakeInventoryClient ¶
type FakeInventoryClient struct { Objs []object.ObjMetadata Err error }
FakeInventoryClient is a testing implementation of the InventoryClient interface.
func NewFakeInventoryClient ¶
func NewFakeInventoryClient(initObjs []object.ObjMetadata) *FakeInventoryClient
NewFakeInventoryClient returns a FakeInventoryClient.
func (*FakeInventoryClient) ApplyInventoryNamespace ¶ added in v0.20.0
func (fic *FakeInventoryClient) ApplyInventoryNamespace(inv *unstructured.Unstructured) error
func (*FakeInventoryClient) ClearError ¶ added in v0.18.0
func (fic *FakeInventoryClient) ClearError()
ClearError clears the force error
func (*FakeInventoryClient) DeleteInventoryObj ¶ added in v0.18.0
func (fic *FakeInventoryClient) DeleteInventoryObj(inv InventoryInfo) error
DeleteInventoryObj returns an error if one is forced; does nothing otherwise.
func (*FakeInventoryClient) GetClusterObjs ¶ added in v0.18.0
func (fic *FakeInventoryClient) GetClusterObjs(inv InventoryInfo) ([]object.ObjMetadata, error)
GetClusterObjs returns currently stored set of objects.
func (*FakeInventoryClient) Merge ¶ added in v0.18.0
func (fic *FakeInventoryClient) Merge(inv InventoryInfo, objs []object.ObjMetadata) ([]object.ObjMetadata, error)
Merge stores the passed objects with the current stored cluster inventory objects. Returns the set difference of the current set of objects minus the passed set of objects, or an error if one is set up.
func (*FakeInventoryClient) Replace ¶ added in v0.18.0
func (fic *FakeInventoryClient) Replace(inv InventoryInfo, objs []object.ObjMetadata) error
Replace the stored cluster inventory objs with the passed obj, or an error if one is set up.
func (*FakeInventoryClient) SetDryRunStrategy ¶ added in v0.18.0
func (fic *FakeInventoryClient) SetDryRunStrategy(drs common.DryRunStrategy)
func (*FakeInventoryClient) SetError ¶ added in v0.18.0
func (fic *FakeInventoryClient) SetError(err error)
SetError forces an error on the subsequent client call if it returns an error.
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() (*unstructured.Unstructured, error) }
Inventory describes methods necessary for an object which can persist the object metadata for pruning and other group operations.
func WrapInventoryObj ¶
func WrapInventoryObj(inv *unstructured.Unstructured) Inventory
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 { // GetCluster 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. GetClusterObjs(inv InventoryInfo) ([]object.ObjMetadata, error) // Merge applies the union of the passed objects with the currently // stored objects in the inventory object. Returns the slice of // objects which are a set diff (objects to be pruned). Otherwise, // returns an error if one happened. Merge(inv InventoryInfo, objs []object.ObjMetadata) ([]object.ObjMetadata, error) // Replace replaces the set of objects stored in the inventory // object with the passed set of objects, or an error if one occurs. Replace(inv InventoryInfo, objs []object.ObjMetadata) error // DeleteInventoryObj deletes the passed inventory object from the APIServer. DeleteInventoryObj(inv InventoryInfo) error // SetDryRunStrategy sets the dry run strategy on whether this we actually mutate. SetDryRunStrategy(drs common.DryRunStrategy) // ApplyInventoryNamespace applies the Namespace that the inventory object should be in. ApplyInventoryNamespace(invNamespace *unstructured.Unstructured) error }
InventoryClient expresses an interface for interacting with objects which store references to objects (inventory objects).
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() (*unstructured.Unstructured, error)
GetObject returns the wrapped object (ConfigMap) as a resource.Info or an error if one occurs.
func (*InventoryConfigMap) ID ¶ added in v0.22.0
func (icm *InventoryConfigMap) ID() string
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) Name ¶ added in v0.22.0
func (icm *InventoryConfigMap) Name() string
func (*InventoryConfigMap) Namespace ¶ added in v0.22.0
func (icm *InventoryConfigMap) Namespace() string
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".
func (*InventoryConfigMap) UnstructuredInventory ¶ added in v0.22.0
func (icm *InventoryConfigMap) UnstructuredInventory() *unstructured.Unstructured
type InventoryFactoryFunc ¶ added in v0.18.0
type InventoryFactoryFunc func(*unstructured.Unstructured) Inventory
InventoryFactoryFunc creates the object which implements the Inventory interface from the passed info object.
type InventoryInfo ¶ added in v0.22.0
type InventoryInfo interface { // Namespace of the inventory object. // It should be the value of the field .metadata.namespace. Namespace() string // Name of the inventory object. // It should be the value of the field .metadata.name. Name() string // ID of the inventory object. It is optional. // The Provider contained in the applier should know // if the Id is necessary and how to use it for pruning objects. ID() string }
InventoryInfo provides the minimal information for the applier to create, look up and update an inventory. The inventory object can be any type, the Provider in the applier needs to know how to create, look up and update it based on the InventoryInfo.
func WrapInventoryInfoObj ¶ added in v0.22.0
func WrapInventoryInfoObj(inv *unstructured.Unstructured) InventoryInfo
WrapInventoryInfoObj takes a passed ConfigMap (as a resource.Info), wraps it with the InventoryConfigMap and upcasts the wrapper as an the InventoryInfo interface.
type InventoryNamespaceInSet ¶ added in v0.18.0
type InventoryNamespaceInSet struct {
Namespace string
}
func (InventoryNamespaceInSet) Error ¶ added in v0.18.0
func (g InventoryNamespaceInSet) Error() string
type InventoryToUnstructuredFunc ¶ added in v0.22.0
type InventoryToUnstructuredFunc func(InventoryInfo) *unstructured.Unstructured
InventoryToUnstructuredFunc returns the unstructured object for the given InventoryInfo.
type MultipleInventoryObjError ¶
type MultipleInventoryObjError struct {
InventoryObjectTemplates []*unstructured.Unstructured
}
func (MultipleInventoryObjError) Error ¶
func (g MultipleInventoryObjError) Error() string
type NoInventoryObjError ¶
type NoInventoryObjError struct{}
func (NoInventoryObjError) Error ¶
func (g NoInventoryObjError) Error() string