prune

package
v0.37.2 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

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, err error) 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, err error) 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, err error) event.Event

func (PruneEventFactory) CreateSuccessEvent added in v0.26.0

func (pef PruneEventFactory) CreateSuccessEvent(obj *unstructured.Unstructured) event.Event

type Pruner added in v0.27.0

type Pruner struct {
	InvClient inventory.Client
	Client    dynamic.Interface
	Mapper    meta.RESTMapper
}

Pruner implements GetPruneObjs to calculate which objects to prune and Prune to delete them.

func NewPruner added in v0.27.0

func NewPruner(factory util.Factory, invClient inventory.Client) (*Pruner, error)

NewPruner returns a new Pruner. Returns an error if dependency injection fails using the factory.

func (*Pruner) GetPruneObjs added in v0.27.0

func (p *Pruner) GetPruneObjs(
	inv inventory.Info,
	objs object.UnstructuredSet,
	opts 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 (*Pruner) Prune added in v0.27.0

func (p *Pruner) Prune(
	objs object.UnstructuredSet,
	pruneFilters []filter.ValidationFilter,
	taskContext *taskrunner.TaskContext,
	taskName string,
	opts Options,
) error

Prune deletes the set of passed objects. 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:

objs - 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
opts - options for dry-run

Jump to

Keyboard shortcuts

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