Back to godoc.org

Package deleter

v0.11.0
Latest Go to latest
Published: Jul 24, 2020 | License: Apache-2.0 | Module: github.com/tektoncd/cli

Index

Package Files

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(streams *cli.Stream, 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(streams *cli.Stream, 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.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier