Documentation
¶
Index ¶
- type DeleteEventFactory
- type EventFactory
- type Options
- type PruneEventFactory
- type PruneOptions
- func (po *PruneOptions) GetObject(obj object.ObjMetadata) (*unstructured.Unstructured, error)
- func (po *PruneOptions) GetPruneObjs(inv inventory.InventoryInfo, localObjs object.UnstructuredSet, o Options) (object.UnstructuredSet, error)
- func (po *PruneOptions) Prune(pruneObjs object.UnstructuredSet, pruneFilters []filter.ValidationFilter, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DeleteEventFactory ¶ added in v0.26.0
type DeleteEventFactory struct {
// contains filtered or unexported fields
}
DeleteEventFactory implements EventFactory interface as a concrete representation of for delete events.
func (DeleteEventFactory) CreateFailedEvent ¶ added in v0.26.0
func (def DeleteEventFactory) CreateFailedEvent(id object.ObjMetadata, err error) event.Event
func (DeleteEventFactory) CreateSkippedEvent ¶ added in v0.26.0
func (def DeleteEventFactory) CreateSkippedEvent(obj *unstructured.Unstructured, reason string) event.Event
func (DeleteEventFactory) CreateSuccessEvent ¶ added in v0.26.0
func (def DeleteEventFactory) CreateSuccessEvent(obj *unstructured.Unstructured) event.Event
type EventFactory ¶ added in v0.26.0
type EventFactory interface { CreateSuccessEvent(obj *unstructured.Unstructured) event.Event CreateSkippedEvent(obj *unstructured.Unstructured, reason string) event.Event CreateFailedEvent(id object.ObjMetadata, err error) event.Event }
EventFactory is an abstract interface describing functions to generate events for pruning or deleting.
func CreateEventFactory ¶ added in v0.26.0
func CreateEventFactory(isDelete bool, groupName string) EventFactory
CreateEventFactory returns the correct concrete version of an EventFactory based on the passed boolean.
type Options ¶ added in v0.8.0
type Options struct { // DryRunStrategy defines whether objects should actually be pruned or if // we should just print what would happen without actually doing it. DryRunStrategy common.DryRunStrategy PropagationPolicy metav1.DeletionPropagation // True if we are destroying, which deletes the inventory object // as well (possibly) the inventory namespace. Destroy bool }
Options defines a set of parameters that can be used to tune the behavior of the pruner.
type PruneEventFactory ¶ added in v0.26.0
type PruneEventFactory struct {
// contains filtered or unexported fields
}
PruneEventFactory implements EventFactory interface as a concrete representation of for prune events.
func (PruneEventFactory) CreateFailedEvent ¶ added in v0.26.0
func (pef PruneEventFactory) CreateFailedEvent(id object.ObjMetadata, err error) event.Event
func (PruneEventFactory) CreateSkippedEvent ¶ added in v0.26.0
func (pef PruneEventFactory) CreateSkippedEvent(obj *unstructured.Unstructured, reason string) event.Event
func (PruneEventFactory) CreateSuccessEvent ¶ added in v0.26.0
func (pef PruneEventFactory) CreateSuccessEvent(obj *unstructured.Unstructured) event.Event
type PruneOptions ¶
type PruneOptions struct { InvClient inventory.InventoryClient Client dynamic.Interface Mapper meta.RESTMapper }
PruneOptions encapsulates the necessary information to implement the prune functionality.
func NewPruneOptions ¶
func NewPruneOptions(factory util.Factory, invClient inventory.InventoryClient) (*PruneOptions, error)
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) GetObject ¶ added in v0.26.0
func (po *PruneOptions) GetObject(obj object.ObjMetadata) (*unstructured.Unstructured, error)
GetObject uses the passed object data to retrieve the object from the cluster (or an error if one occurs).
func (*PruneOptions) GetPruneObjs ¶ added in v0.26.0
func (po *PruneOptions) GetPruneObjs(inv inventory.InventoryInfo, localObjs object.UnstructuredSet, o Options) (object.UnstructuredSet, error)
GetPruneObjs calculates the set of prune objects, and retrieves them from the cluster. Set of prune objects equals the set of inventory objects minus the set of currently applied objects. Returns an error if one occurs.
func (*PruneOptions) Prune ¶
func (po *PruneOptions) Prune(pruneObjs object.UnstructuredSet, pruneFilters []filter.ValidationFilter, taskContext *taskrunner.TaskContext, taskName string, o Options, ) error
Prune deletes the set of passed pruneObjs. A prune skip/failure is captured in the TaskContext, so we do not lose track of these objects from the inventory. The passed prune filters are used to determine if permission exists to delete the object. An example of a prune filter is PreventDeleteFilter, which checks if an annotation exists on the object to ensure the objects is not deleted (e.g. a PersistentVolume that we do no want to automatically prune/delete).
Parameters:
pruneObjs - objects to prune (delete) pruneFilters - list of filters for deletion permission taskContext - task for apply/prune taskName - name of the parent task group, for events o - options for dry-run