apply

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2021 License: Apache-2.0 Imports: 22 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Applier

type Applier struct {
	PruneOptions *prune.PruneOptions
	StatusPoller poller.Poller
	// contains filtered or unexported fields
}

Applier performs the step of applying a set of resources into a cluster, conditionally waits for all of them to be fully reconciled and finally performs prune to clean up any resources that has been deleted. The applier performs its function by executing a list queue of tasks, each of which is one of the steps in the process of applying a set of resources to the cluster. The actual execution of these tasks are handled by a StatusRunner. So the taskqueue is effectively a specification that is executed by the StatusRunner. Based on input parameters and/or the set of resources that needs to be applied to the cluster, different sets of tasks might be needed.

func NewApplier

func NewApplier(provider provider.Provider) *Applier

newApplier returns a new Applier. It will set up the ApplyOptions and StatusOptions which are responsible for capturing any command line flags. It currently requires IOStreams, but this is a legacy from when the ApplyOptions were responsible for printing progress. This is now handled by a separate printer with the KubectlPrinterAdapter bridging between the two.

func (*Applier) Initialize

func (a *Applier) Initialize() error

Initialize sets up the Applier for actually doing an apply against a cluster. This involves validating command line inputs and configuring clients for communicating with the cluster.

func (*Applier) Run

func (a *Applier) Run(ctx context.Context, invInfo inventory.InventoryInfo, objects []*unstructured.Unstructured, options Options) <-chan event.Event

Run performs the Apply step. This happens asynchronously with updates on progress and any errors are reported back on the event channel. Cancelling the operation or setting timeout on how long to Wait for it complete can be done with the passed in context. Note: There sn't currently any way to interrupt the operation before all the given resources have been applied to the cluster. Any cancellation or timeout will only affect how long we Wait for the resources to become current.

type Destroyer

type Destroyer struct {
	PruneOptions *prune.PruneOptions

	DryRunStrategy common.DryRunStrategy
	// contains filtered or unexported fields
}

Destroyer performs the step of grabbing all the previous inventory objects and prune them. This also deletes all the previous inventory objects

func NewDestroyer

func NewDestroyer(provider provider.Provider) *Destroyer

NewDestroyer returns a new destroyer. It will set up the ApplyOptions and PruneOptions which are responsible for capturing any command line flags. It currently requires IOStreams, but this is a legacy from when the ApplyOptions were responsible for printing progress. This is now handled by a separate printer with the KubectlPrinterAdapter bridging between the two.

func (*Destroyer) Initialize

func (d *Destroyer) Initialize() error

Initialize sets up the Destroyer for actually doing an destroy against a cluster. This involves validating command line inputs and configuring clients for communicating with the cluster.

func (*Destroyer) Run

func (d *Destroyer) Run(inv inventory.InventoryInfo, option *DestroyerOption) <-chan event.Event

Run performs the destroy step. Passes the inventory object. This happens asynchronously on progress and any errors are reported back on the event channel.

type DestroyerOption added in v0.22.5

type DestroyerOption struct {
	InventoryPolicy inventory.InventoryPolicy
}

type Options added in v0.7.0

type Options struct {
	// Encapsulates the fields for server-side apply.
	ServerSideOptions common.ServerSideOptions

	// ReconcileTimeout defines whether the applier should wait
	// until all applied resources have been reconciled, and if so,
	// how long to wait.
	ReconcileTimeout time.Duration

	// PollInterval defines how often we should poll for the status
	// of resources.
	PollInterval time.Duration

	// EmitStatusEvents defines whether status events should be
	// emitted on the eventChannel to the caller.
	EmitStatusEvents bool

	// NoPrune defines whether pruning of previously applied
	// objects should happen after apply.
	NoPrune bool

	// DryRunStrategy defines whether changes should actually be performed,
	// or if it is just talk and no action.
	DryRunStrategy common.DryRunStrategy

	// PrunePropagationPolicy defines the deletion propagation policy
	// that should be used for pruning. If this is not provided, the
	// default is to use the Background policy.
	PrunePropagationPolicy metav1.DeletionPropagation

	// PruneTimeout defines whether we should wait for all resources
	// to be fully deleted after pruning, and if so, how long we should
	// wait.
	PruneTimeout time.Duration

	// InventoryPolicy defines the inventory policy of apply.
	InventoryPolicy inventory.InventoryPolicy
}

type ResourceObjects added in v0.10.0

type ResourceObjects struct {
	LocalInv  inventory.InventoryInfo
	Resources []*unstructured.Unstructured
	PruneIds  []object.ObjMetadata
	PrevInv   []object.ObjMetadata
}

ResourceObjects contains information about the resources that will be applied and the existing inventories used to determine resources that should be pruned.

func (*ResourceObjects) AllIds added in v0.10.0

func (r *ResourceObjects) AllIds() []object.ObjMetadata

AllIds returns the Ids for all resources that are relevant. This includes resources that will be applied or pruned.

func (*ResourceObjects) IdsForApply added in v0.10.0

func (r *ResourceObjects) IdsForApply() []object.ObjMetadata

IdsForApply returns the Ids for all resources that should be applied, including the inventory object.

func (*ResourceObjects) IdsForPrevInv added in v0.23.0

func (r *ResourceObjects) IdsForPrevInv() []object.ObjMetadata

IdsForPrevInv returns the Ids for the previous inventory. These Ids reference the objects managed by the inventory object which are already in the cluster.

func (*ResourceObjects) IdsForPrune added in v0.10.0

func (r *ResourceObjects) IdsForPrune() []object.ObjMetadata

IdsForPrune returns the Ids for all resources that should be pruned.

func (*ResourceObjects) Inventory added in v0.21.1

func (r *ResourceObjects) Inventory() inventory.InventoryInfo

Inventory returns the unstructured representation of the inventory object.

func (*ResourceObjects) ObjsForApply added in v0.21.0

func (r *ResourceObjects) ObjsForApply() []*unstructured.Unstructured

ObjsForApply returns the unstructured representation for all the resources that should be applied, not including the inventory object. The resources will be in sorted order.

Directories

Path Synopsis
The solver package is responsible for constructing a taskqueue based on the set of resources that should be applied.
The solver package is responsible for constructing a taskqueue based on the set of resources that should be applied.

Jump to

Keyboard shortcuts

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