deleter

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deleter

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

Deleter encapsulates behaviour around deleting resources and their relations. While actually performing a deletion is left to calling code, this helper type standardizes the sequencing, messaging and error handling related to deletions.

func New

func New(kind string, deleteFunc func(string) error) *Deleter

New returns a Deleter that will delete resources of kind with the given delete func when Execute is called.

func (*Deleter) Delete

func (d *Deleter) Delete(resourceNames []string) []string

Delete performs the deletion of resources. Errors are printed to stderr of the passed in streams struct and are also aggregated for later access with d.Errors(). The names of successfully deleted resources are returned.

func (*Deleter) DeleteRelated

func (d *Deleter) DeleteRelated(resourceNames []string)

DeleteRelated performs the deletion of resources related to d's kind. Errors are aggregated and can be accessed with d.Errors().

func (*Deleter) Errors

func (d *Deleter) Errors() error

Errors returns any accumulated errors in the operation of this deleter.

func (*Deleter) PrintSuccesses

func (d *Deleter) PrintSuccesses(streams *cli.Stream)

PrintSuccesses writes success messages to the provided stdout stream.

func (*Deleter) WithRelated

func (d *Deleter) WithRelated(kind string, listFunc func(string) ([]string, error), deleteFunc func(string) error)

WithRelated tells this Deleter that it should also delete related resources when Execute is called. Related resources will be of given kind, the names of those resources must be provided by listFunc and each related resource will be passed to deleteFunc for deletion.

Jump to

Keyboard shortcuts

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