inventory

package
v0.36.0-flux.5 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const OwningInventoryKey = "config.k8s.io/owning-inventory"

OwningInventoryKey is the annotation key indicating the inventory owning an object.

Variables

View Source
var ConfigMapGVK = schema.GroupVersionKind{
	Group:   "",
	Kind:    "ConfigMap",
	Version: "v1",
}

Functions

func AddInventoryIDAnnotation

func AddInventoryIDAnnotation(obj *unstructured.Unstructured, inv Info)

func CanApply

func CanApply(inv Info, obj *unstructured.Unstructured, policy Policy) (bool, error)

func CanPrune

func CanPrune(inv Info, obj *unstructured.Unstructured, policy Policy) (bool, error)

func FindInventoryObj

func FindInventoryObj(objs object.UnstructuredSet) *unstructured.Unstructured

FindInventoryObj returns the "Inventory" object (ConfigMap with inventory label) if it exists, or nil if it does not exist.

func InvInfoToConfigMap

func InvInfoToConfigMap(inv Info) *unstructured.Unstructured

func IsInventoryObject

func IsInventoryObject(obj *unstructured.Unstructured) bool

IsInventoryObject returns true if the passed object has the inventory label.

func ObjMetadataFromObjectReference

func ObjMetadataFromObjectReference(ref actuation.ObjectReference) object.ObjMetadata

ObjMetadataFromObjectReference converts an ObjectReference to a ObjMetadata

func ObjectReferenceFromObjMetadata

func ObjectReferenceFromObjMetadata(id object.ObjMetadata) actuation.ObjectReference

ObjectReferenceFromObjMetadata converts an ObjMetadata to a ObjectReference

func SplitUnstructureds

splitUnstructureds takes a set of unstructured.Unstructured objects and splits it into one set that contains the inventory object templates and another one that contains the remaining resources. Returns an error if there there is no inventory object or more than one inventory objects.

func ValidateNoInventory

func ValidateNoInventory(objs object.UnstructuredSet) error

ValidateNoInventory takes a set of unstructured.Unstructured objects and validates that no inventory object is in the input slice.

Types

type Client

type Client interface {
	// GetClusterObjs 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 Info) (object.ObjMetadataSet, error)
	// Merge applies the union of the passed objects with the currently
	// stored objects in the inventory object. Returns the set of
	// objects which are not in the passed objects (objects to be pruned).
	// Otherwise, returns an error if one happened.
	Merge(inv Info, objs object.ObjMetadataSet, dryRun common.DryRunStrategy) (object.ObjMetadataSet, 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 Info, objs object.ObjMetadataSet, status []actuation.ObjectStatus, dryRun common.DryRunStrategy) error
	// DeleteInventoryObj deletes the passed inventory object from the APIServer.
	DeleteInventoryObj(inv Info, dryRun common.DryRunStrategy) error
	// ApplyInventoryNamespace applies the Namespace that the inventory object should be in.
	ApplyInventoryNamespace(invNamespace *unstructured.Unstructured, dryRun common.DryRunStrategy) error
	// GetClusterInventoryInfo returns the cluster inventory object.
	GetClusterInventoryInfo(inv Info) (*unstructured.Unstructured, error)
	// GetClusterInventoryObjs looks up the inventory objects from the cluster.
	GetClusterInventoryObjs(inv Info) (object.UnstructuredSet, error)
	// ListClusterInventoryObjs returns a map mapping from inventory name to a list of cluster inventory objects
	ListClusterInventoryObjs(ctx context.Context) (map[string]object.ObjMetadataSet, error)
}

Client expresses an interface for interacting with objects which store references to objects (inventory objects).

type ClientFactory

type ClientFactory interface {
	NewClient(factory cmdutil.Factory) (Client, error)
}

ClientFactory is a factory that constructs new Client instances.

type ClusterClient

type ClusterClient struct {
	InventoryFactoryFunc StorageFactoryFunc
	// contains filtered or unexported fields
}

ClusterClient is a concrete implementation of the Client interface.

func NewClient

func NewClient(factory cmdutil.Factory,
	invFunc StorageFactoryFunc,
	invToUnstructuredFunc ToUnstructuredFunc,
	statusPolicy StatusPolicy,
	gvk schema.GroupVersionKind,
) (*ClusterClient, error)

NewClient returns a concrete implementation of the Client interface or an error.

func (*ClusterClient) ApplyInventoryNamespace

func (cic *ClusterClient) ApplyInventoryNamespace(obj *unstructured.Unstructured, dryRun common.DryRunStrategy) 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 (*ClusterClient) DeleteInventoryObj

func (cic *ClusterClient) DeleteInventoryObj(localInv Info, dryRun common.DryRunStrategy) error

DeleteInventoryObj deletes the inventory object from the cluster.

func (*ClusterClient) GetClusterInventoryInfo

func (cic *ClusterClient) GetClusterInventoryInfo(inv Info) (*unstructured.Unstructured, error)

getClusterInventoryObj returns a pointer to the cluster inventory object, or an error if one occurred. Returns the cached cluster inventory object if it has been previously retrieved. Uses the ResourceBuilder to retrieve the inventory object in the cluster, using the namespace, group resource, and inventory label. Merges multiple inventory objects into one if it retrieves more than one (this should be very rare).

TODO(seans3): Remove the special case code to merge multiple cluster inventory objects once we've determined that this case is no longer possible.

func (*ClusterClient) GetClusterInventoryObjs

func (cic *ClusterClient) GetClusterInventoryObjs(inv Info) (object.UnstructuredSet, error)

func (*ClusterClient) GetClusterObjs

func (cic *ClusterClient) GetClusterObjs(localInv Info) (object.ObjMetadataSet, error)

GetClusterObjs returns the objects stored in the cluster inventory object, or an error if one occurred.

func (*ClusterClient) ListClusterInventoryObjs

func (cic *ClusterClient) ListClusterInventoryObjs(ctx context.Context) (map[string]object.ObjMetadataSet, error)

func (*ClusterClient) Merge

func (cic *ClusterClient) Merge(localInv Info, objs object.ObjMetadataSet, dryRun common.DryRunStrategy) (object.ObjMetadataSet, 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 (*ClusterClient) Replace

func (cic *ClusterClient) Replace(localInv Info, objs object.ObjMetadataSet, status []actuation.ObjectStatus,
	dryRun common.DryRunStrategy) error

Replace stores the passed objects in the cluster inventory object, or an error if one occurred.

type ClusterClientFactory

type ClusterClientFactory struct {
	StatusPolicy StatusPolicy
}

ClusterClientFactory is a factory that creates instances of ClusterClient inventory client.

func (ClusterClientFactory) NewClient

func (ccf ClusterClientFactory) NewClient(factory cmdutil.Factory) (Client, error)

type ConfigMap

type ConfigMap struct {
	// contains filtered or unexported fields
}

ConfigMap 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 (*ConfigMap) Apply

func (icm *ConfigMap) Apply(dc dynamic.Interface, mapper meta.RESTMapper, _ StatusPolicy) error

Apply is an Storage interface function implemented to apply the inventory object. StatusPolicy is not needed since ConfigMaps do not have a status subresource.

func (*ConfigMap) ApplyWithPrune

func (icm *ConfigMap) ApplyWithPrune(dc dynamic.Interface, mapper meta.RESTMapper, _ StatusPolicy, _ object.ObjMetadataSet) error

ApplyWithPrune is a Storage interface function implemented to apply the inventory object with a list of objects to be pruned. StatusPolicy is not needed since ConfigMaps do not have a status subresource.

func (*ConfigMap) GetObject

func (icm *ConfigMap) GetObject() (*unstructured.Unstructured, error)

GetObject returns the wrapped object (ConfigMap) as a resource.Info or an error if one occurs.

func (*ConfigMap) ID

func (icm *ConfigMap) ID() string

func (*ConfigMap) Load

func (icm *ConfigMap) Load() (object.ObjMetadataSet, error)

Load is an Inventory interface function returning the set of object metadata from the wrapped ConfigMap, or an error.

func (*ConfigMap) Name

func (icm *ConfigMap) Name() string

func (*ConfigMap) Namespace

func (icm *ConfigMap) Namespace() string

func (*ConfigMap) Store

func (icm *ConfigMap) Store(objMetas object.ObjMetadataSet, status []actuation.ObjectStatus) error

Store is an Inventory interface function implemented to store the object metadata in the wrapped ConfigMap. Actual storing happens in "GetObject".

func (*ConfigMap) Strategy

func (icm *ConfigMap) Strategy() Strategy

func (*ConfigMap) UnstructuredInventory

func (icm *ConfigMap) UnstructuredInventory() *unstructured.Unstructured

type FakeBuilder

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

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

func (fb *FakeBuilder) SetInventoryObjs(objs object.ObjMetadataSet)

SetInventoryObjs sets the objects which will be encoded in an inventory object to be returned when queried for the cluster inventory object.

type FakeClient

type FakeClient struct {
	Objs   object.ObjMetadataSet
	Status []actuation.ObjectStatus
	Err    error
}

FakeClient is a testing implementation of the Client interface.

func NewFakeClient

func NewFakeClient(initObjs object.ObjMetadataSet) *FakeClient

NewFakeClient returns a FakeClient.

func (*FakeClient) ApplyInventoryNamespace

func (fic *FakeClient) ApplyInventoryNamespace(*unstructured.Unstructured, common.DryRunStrategy) error

func (*FakeClient) ClearError

func (fic *FakeClient) ClearError()

ClearError clears the force error

func (*FakeClient) DeleteInventoryObj

func (fic *FakeClient) DeleteInventoryObj(Info, common.DryRunStrategy) error

DeleteInventoryObj returns an error if one is forced; does nothing otherwise.

func (*FakeClient) GetClusterInventoryInfo

func (fic *FakeClient) GetClusterInventoryInfo(Info) (*unstructured.Unstructured, error)

func (*FakeClient) GetClusterInventoryObjs

func (fic *FakeClient) GetClusterInventoryObjs(_ Info) (object.UnstructuredSet, error)

func (*FakeClient) GetClusterObjs

func (fic *FakeClient) GetClusterObjs(Info) (object.ObjMetadataSet, error)

GetClusterObjs returns currently stored set of objects.

func (*FakeClient) ListClusterInventoryObjs

func (fic *FakeClient) ListClusterInventoryObjs(_ context.Context) (map[string]object.ObjMetadataSet, error)

func (*FakeClient) Merge

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 (*FakeClient) Replace

Replace the stored cluster inventory objs with the passed obj, or an error if one is set up.

func (*FakeClient) SetError

func (fic *FakeClient) SetError(err error)

SetError forces an error on the subsequent client call if it returns an error.

type FakeClientFactory

type FakeClientFactory object.ObjMetadataSet

func (FakeClientFactory) NewClient

func (f FakeClientFactory) NewClient(cmdutil.Factory) (Client, error)

type IDMatchStatus

type IDMatchStatus int

IDMatchStatus represents the result of comparing the id from current inventory info and the inventory-id from a live object.

const (
	Empty IDMatchStatus = iota
	Match
	NoMatch
)

func IDMatch

func IDMatch(inv Info, obj *unstructured.Unstructured) IDMatchStatus

func (IDMatchStatus) String

func (i IDMatchStatus) String() string

type Info

type Info 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

	Strategy() Strategy
}

Info 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 Info.

func WrapInventoryInfoObj

func WrapInventoryInfoObj(inv *unstructured.Unstructured) Info

WrapInventoryInfoObj takes a passed ConfigMap (as a resource.Info), wraps it with the ConfigMap and upcasts the wrapper as an the Info interface.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager wraps an Inventory with convenience methods that use ObjMetadata.

func NewManager

func NewManager() *Manager

NewManager returns a new manager instance.

func (*Manager) AddFailedApply

func (tc *Manager) AddFailedApply(id object.ObjMetadata)

AddFailedApply registers that the object failed to apply

func (*Manager) AddFailedDelete

func (tc *Manager) AddFailedDelete(id object.ObjMetadata)

AddFailedDelete registers that the object failed to delete

func (*Manager) AddPendingApply

func (tc *Manager) AddPendingApply(id object.ObjMetadata)

AddPendingApply registers that the object is pending apply

func (*Manager) AddPendingDelete

func (tc *Manager) AddPendingDelete(id object.ObjMetadata)

AddPendingDelete registers that the object is pending delete

func (*Manager) AddSkippedApply

func (tc *Manager) AddSkippedApply(id object.ObjMetadata)

AddSkippedApply registers that the object apply was skipped

func (*Manager) AddSkippedDelete

func (tc *Manager) AddSkippedDelete(id object.ObjMetadata)

AddSkippedDelete registers that the object delete was skipped

func (*Manager) AddSuccessfulApply

func (tc *Manager) AddSuccessfulApply(id object.ObjMetadata, uid types.UID, gen int64)

AddSuccessfulApply updates the context with information about the resource identified by the provided id. Currently, we keep information about the generation of the resource after the apply operation completed.

func (*Manager) AddSuccessfulDelete

func (tc *Manager) AddSuccessfulDelete(id object.ObjMetadata, uid types.UID)

AddSuccessfulDelete updates the context with information about the resource identified by the provided id. Currently, we only track the uid, because the DELETE call doesn't always return the generation, namely if the object was scheduled to be deleted asynchronously, which might cause further updates by finalizers. The UID will change if the object is re-created.

func (*Manager) AppliedGeneration

func (tc *Manager) AppliedGeneration(id object.ObjMetadata) (int64, bool)

AppliedGeneration looks up the generation of the given resource after it was applied.

func (*Manager) AppliedResourceUID

func (tc *Manager) AppliedResourceUID(id object.ObjMetadata) (types.UID, bool)

AppliedResourceUID looks up the UID of a successfully applied resource

func (*Manager) AppliedResourceUIDs

func (tc *Manager) AppliedResourceUIDs() sets.String

AppliedResourceUIDs returns a set with the UIDs of all the successfully applied resources.

func (*Manager) FailedApplies

func (tc *Manager) FailedApplies() object.ObjMetadataSet

FailedApplies returns all the objects that failed to apply

func (*Manager) FailedDeletes

func (tc *Manager) FailedDeletes() object.ObjMetadataSet

FailedDeletes returns all the objects that failed to delete

func (*Manager) FailedReconciles

func (tc *Manager) FailedReconciles() object.ObjMetadataSet

FailedReconciles returns all the objects that failed to reconcile

func (*Manager) Inventory

func (tc *Manager) Inventory() *actuation.Inventory

Inventory returns the in-memory version of the managed inventory.

func (*Manager) IsFailedApply

func (tc *Manager) IsFailedApply(id object.ObjMetadata) bool

IsFailedApply returns true if the object failed to apply

func (*Manager) IsFailedDelete

func (tc *Manager) IsFailedDelete(id object.ObjMetadata) bool

IsFailedDelete returns true if the object failed to delete

func (*Manager) IsFailedReconcile

func (tc *Manager) IsFailedReconcile(id object.ObjMetadata) bool

IsFailedReconcile returns true if the object failed to reconcile

func (*Manager) IsPendingApply

func (tc *Manager) IsPendingApply(id object.ObjMetadata) bool

IsPendingApply returns true if the object pending apply

func (*Manager) IsPendingDelete

func (tc *Manager) IsPendingDelete(id object.ObjMetadata) bool

IsPendingDelete returns true if the object pending delete

func (*Manager) IsPendingReconcile

func (tc *Manager) IsPendingReconcile(id object.ObjMetadata) bool

IsPendingReconcile returns true if the object reconcile is pending

func (*Manager) IsSkippedApply

func (tc *Manager) IsSkippedApply(id object.ObjMetadata) bool

IsSkippedApply returns true if the object apply was skipped

func (*Manager) IsSkippedDelete

func (tc *Manager) IsSkippedDelete(id object.ObjMetadata) bool

IsSkippedDelete returns true if the object delete was skipped

func (*Manager) IsSkippedReconcile

func (tc *Manager) IsSkippedReconcile(id object.ObjMetadata) bool

IsSkippedReconcile returns true if the object reconcile was skipped

func (*Manager) IsSuccessfulApply

func (tc *Manager) IsSuccessfulApply(id object.ObjMetadata) bool

IsSuccessfulApply returns true if the object apply was successful

func (*Manager) IsSuccessfulDelete

func (tc *Manager) IsSuccessfulDelete(id object.ObjMetadata) bool

IsSuccessfulDelete returns true if the object delete was successful

func (*Manager) IsSuccessfulReconcile

func (tc *Manager) IsSuccessfulReconcile(id object.ObjMetadata) bool

IsSuccessfulReconcile returns true if the object is reconciled

func (*Manager) IsTimeoutReconcile

func (tc *Manager) IsTimeoutReconcile(id object.ObjMetadata) bool

IsTimeoutReconcile returns true if the object reconcile was skipped

func (*Manager) ObjectStatus

func (tc *Manager) ObjectStatus(id object.ObjMetadata) (*actuation.ObjectStatus, bool)

ObjectStatus retrieves the status of an object with the specified ID. The returned status is a pointer and can be updated in-place for efficiency.

func (*Manager) ObjectsWithActuationStatus

func (tc *Manager) ObjectsWithActuationStatus(strategy actuation.ActuationStrategy, status actuation.ActuationStatus) object.ObjMetadataSet

ObjectsWithActuationStatus retrieves the set of objects with the specified actuation strategy and status.

func (*Manager) ObjectsWithReconcileStatus

func (tc *Manager) ObjectsWithReconcileStatus(status actuation.ReconcileStatus) object.ObjMetadataSet

ObjectsWithActuationStatus retrieves the set of objects with the specified reconcile status, regardless of actuation strategy.

func (*Manager) PendingApplies

func (tc *Manager) PendingApplies() object.ObjMetadataSet

PendingApplies returns all the objects that are pending apply

func (*Manager) PendingDeletes

func (tc *Manager) PendingDeletes() object.ObjMetadataSet

PendingDeletes returns all the objects that are pending delete

func (*Manager) PendingReconciles

func (tc *Manager) PendingReconciles() object.ObjMetadataSet

PendingReconciles returns all the objects where reconcile is pending

func (*Manager) SetFailedReconcile

func (tc *Manager) SetFailedReconcile(id object.ObjMetadata) error

SetFailedReconcile registers that the object failed to reconcile

func (*Manager) SetObjectStatus

func (tc *Manager) SetObjectStatus(newObjStatus actuation.ObjectStatus)

SetObjectStatus updates or adds an ObjectStatus record to the inventory.

func (*Manager) SetPendingReconcile

func (tc *Manager) SetPendingReconcile(id object.ObjMetadata) error

SetPendingReconcile registers that the object reconcile is pending

func (*Manager) SetSkippedReconcile

func (tc *Manager) SetSkippedReconcile(id object.ObjMetadata) error

SetSkippedReconcile registers that the object reconcile was skipped

func (*Manager) SetSuccessfulReconcile

func (tc *Manager) SetSuccessfulReconcile(id object.ObjMetadata) error

SetSuccessfulReconcile registers that the object is reconciled

func (*Manager) SetTimeoutReconcile

func (tc *Manager) SetTimeoutReconcile(id object.ObjMetadata) error

SetTimeoutReconcile registers that the object reconcile was skipped

func (*Manager) SkippedApplies

func (tc *Manager) SkippedApplies() object.ObjMetadataSet

SkippedApplies returns all the objects where apply was skipped

func (*Manager) SkippedDeletes

func (tc *Manager) SkippedDeletes() object.ObjMetadataSet

SkippedDeletes returns all the objects where deletion was skipped

func (*Manager) SkippedReconciles

func (tc *Manager) SkippedReconciles() object.ObjMetadataSet

SkippedReconciles returns all the objects where reconcile was skipped

func (*Manager) SuccessfulApplies

func (tc *Manager) SuccessfulApplies() object.ObjMetadataSet

SuccessfulApplies returns all the objects (as ObjMetadata) that were added as applied resources to the Manager.

func (*Manager) SuccessfulDeletes

func (tc *Manager) SuccessfulDeletes() object.ObjMetadataSet

SuccessfulDeletes returns all the objects (as ObjMetadata) that were successfully deleted.

func (*Manager) SuccessfulReconciles

func (tc *Manager) SuccessfulReconciles() object.ObjMetadataSet

SuccessfulReconciles returns all the reconciled objects

func (*Manager) TimeoutReconciles

func (tc *Manager) TimeoutReconciles() object.ObjMetadataSet

TimeoutReconciles returns all the objects where reconcile was skipped

type MultipleInventoryObjError

type MultipleInventoryObjError struct {
	InventoryObjectTemplates object.UnstructuredSet
}

func (*MultipleInventoryObjError) Error

func (e *MultipleInventoryObjError) Error() string

func (*MultipleInventoryObjError) Is

Is returns true if the specified error is equal to this error. Use errors.Is(error) to recursively check if an error wraps this error.

type NoInventoryObjError

type NoInventoryObjError struct{}

func (*NoInventoryObjError) Error

func (e *NoInventoryObjError) Error() string

func (*NoInventoryObjError) Is

func (e *NoInventoryObjError) Is(err error) bool

Is returns true if the specified error is equal to this error. Use errors.Is(error) to recursively check if an error wraps this error.

type Policy

type Policy int

Policy defines if an inventory object can take over objects that belong to another inventory object or don't belong to any inventory object. This is done by determining if the apply/prune operation can go through for a resource based on the comparison the inventory-id value in the package and the owning-inventory annotation in the live object.

const (
	// PolicyMustMatch: This policy enforces that the resources being applied can not
	// have any overlap with objects in other inventories or objects that already exist
	// in the cluster but don't belong to an inventory.
	//
	// The apply operation can go through when
	// - A new resources in the package doesn't exist in the cluster
	// - An existing resource in the package doesn't exist in the cluster
	// - An existing resource exist in the cluster. The owning-inventory annotation in the live object
	//   matches with that in the package.
	//
	// The prune operation can go through when
	// - The owning-inventory annotation in the live object match with that
	//   in the package.
	PolicyMustMatch Policy = iota // MustMatch

	// PolicyAdoptIfNoInventory: This policy enforces that resources being applied
	// can not have any overlap with objects in other inventories, but are
	// permitted to take ownership of objects that don't belong to any inventories.
	//
	// The apply operation can go through when
	// - New resource in the package doesn't exist in the cluster
	// - If a new resource exist in the cluster, its owning-inventory annotation is empty
	// - Existing resource in the package doesn't exist in the cluster
	// - If existing resource exist in the cluster, its owning-inventory annotation in the live object
	//   is empty
	// - An existing resource exist in the cluster. The owning-inventory annotation in the live object
	//   matches with that in the package.
	//
	// The prune operation can go through when
	// - The owning-inventory annotation in the live object match with that
	//   in the package.
	// - The live object doesn't have the owning-inventory annotation.
	PolicyAdoptIfNoInventory // AdoptIfNoInventory

	// PolicyAdoptAll: This policy will let the current inventory take ownership of any objects.
	//
	// The apply operation can go through for any resource in the package even if the
	// live object has an unmatched owning-inventory annotation.
	//
	// The prune operation can go through when
	// - The owning-inventory annotation in the live object match or doesn't match with that
	//   in the package.
	// - The live object doesn't have the owning-inventory annotation.
	PolicyAdoptAll // AdoptAll
)

func (Policy) String

func (i Policy) String() string

type PolicyPreventedActuationError

type PolicyPreventedActuationError struct {
	Strategy actuation.ActuationStrategy
	Policy   Policy
	Status   IDMatchStatus
}

func (*PolicyPreventedActuationError) Error

func (*PolicyPreventedActuationError) Is

Is returns true if the specified error is equal to this error. Use errors.Is(error) to recursively check if an error wraps this error.

type StatusPolicy

type StatusPolicy int

StatusPolicy specifies whether the inventory client should apply status to the inventory object. The status contains the actuation and reconcile stauts of each object in the inventory.

const (
	// StatusPolicyNone disables inventory status updates.
	StatusPolicyNone StatusPolicy = iota // None

	// StatusPolicyAll fully enables inventory status updates.
	StatusPolicyAll // All
)

func (StatusPolicy) String

func (i StatusPolicy) String() string

type Storage

type Storage interface {
	// Load retrieves the set of object metadata from the inventory object
	Load() (object.ObjMetadataSet, error)
	// Store the set of object metadata in the inventory object. This will
	// replace the metadata, spec and status.
	Store(objs object.ObjMetadataSet, status []actuation.ObjectStatus) error
	// GetObject returns the object that stores the inventory
	GetObject() (*unstructured.Unstructured, error)
	// Apply applies the inventory object. This utility function is used
	// in InventoryClient.Merge and merges the metadata, spec and status.
	Apply(dynamic.Interface, meta.RESTMapper, StatusPolicy) error
	// ApplyWithPrune applies the inventory object with a set of pruneIDs of
	// objects to be pruned (object.ObjMetadataSet). This function is used in
	// InventoryClient.Replace. pruneIDs are required for enabling custom logic
	// handling of multiple ResourceGroup inventories.
	ApplyWithPrune(dynamic.Interface, meta.RESTMapper, StatusPolicy, object.ObjMetadataSet) error
}

Storage 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) Storage

WrapInventoryObj takes a passed ConfigMap (as a resource.Info), wraps it with the ConfigMap and upcasts the wrapper as an the Inventory interface.

type StorageFactoryFunc

type StorageFactoryFunc func(*unstructured.Unstructured) Storage

StorageFactoryFunc creates the object which implements the Inventory interface from the passed info object.

type Strategy

type Strategy string
const (
	NameStrategy  Strategy = "name"
	LabelStrategy Strategy = "label"
)

type ToUnstructuredFunc

type ToUnstructuredFunc func(Info) *unstructured.Unstructured

ToUnstructuredFunc returns the unstructured object for the given Info.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL