prune

package
v0.36.0-flux.11 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeleteEventFactory

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

DeleteEventFactory implements EventFactory interface as a concrete representation of for delete events.

func (DeleteEventFactory) CreateFailedEvent

func (def DeleteEventFactory) CreateFailedEvent(id object.ObjMetadata, err error) event.Event

func (DeleteEventFactory) CreateSkippedEvent

func (def DeleteEventFactory) CreateSkippedEvent(obj *unstructured.Unstructured, err error) event.Event

func (DeleteEventFactory) CreateSuccessEvent

func (def DeleteEventFactory) CreateSuccessEvent(obj *unstructured.Unstructured) event.Event

type EventFactory

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

func CreateEventFactory(isDelete bool, groupName string) EventFactory

CreateEventFactory returns the correct concrete version of an EventFactory based on the passed boolean.

type Options

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

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

PruneEventFactory implements EventFactory interface as a concrete representation of for prune events.

func (PruneEventFactory) CreateFailedEvent

func (pef PruneEventFactory) CreateFailedEvent(id object.ObjMetadata, err error) event.Event

func (PruneEventFactory) CreateSkippedEvent

func (pef PruneEventFactory) CreateSkippedEvent(obj *unstructured.Unstructured, err error) event.Event

func (PruneEventFactory) CreateSuccessEvent

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

type Pruner

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

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

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

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