revision

package
v0.0.0-...-35b42f4 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxWorkers is the maximum number of go-routines to use for concurrent
	// actions.
	MaxWorkers = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeSet

type ChangeSet struct {
	Revision           *Revision
	AddedResources     resource.Slice
	UpdatedResources   resource.Slice
	UnchangedResources resource.Slice
	RemovedResources   resource.Slice

	Hooks hook.SliceMap
}

ChangeSet is a container for resources that are sorted into buckets. These buckets help in finding the best upgrade strategy for a given manifest.

func (*ChangeSet) HasResourceChanges

func (c *ChangeSet) HasResourceChanges() bool

HasResourceChanges returns true if there are resource changes waiting to be applied. Resource changes are resource additions, deletions and updates.

type Client

type Client interface {
	// ApplyManifest applies raw manifest bytes.
	ApplyManifest(context.Context, []byte) error

	// DeleteManifest deletes raw manifest bytes.
	DeleteManifest(context.Context, []byte) error

	// DeleteResource deletes a resource by its kind, name and namespace.
	DeleteResource(context.Context, resource.Head) error

	// Wait waits for a resource condition to be met.
	Wait(context.Context, kubernetes.WaitOptions) error
}

Client applies and deletes manifests from a cluster.

type Revision

type Revision struct {
	Current *manifest.Manifest
	Next    *manifest.Manifest
}

Revision is the step before applying the next version of a manifest and potentially deleting leftovers from the old version. A revision with nil Next is considered as a deletion of all resources defined in the manifest. Consequently, a revision with a nil Current is considered an initial resource creation and will apply all resources.

func (*Revision) ChangeSet

func (r *Revision) ChangeSet() *ChangeSet

ChangeSet creates a ChangeSet for r. The change set categorizes resources into buckets (e.g. added, updated, unchanged, removed) and also contains the most recent hooks for this revision.

func (*Revision) DiffOptions

func (r *Revision) DiffOptions() diff.Options

DiffOptions returns the diff.Options for this revision.

func (*Revision) IsInitial

func (r *Revision) IsInitial() bool

IsInitial returns true if r contains a new manifest, meaning that there is no current revision.

func (*Revision) IsRemoval

func (r *Revision) IsRemoval() bool

IsRemoval returns true if r does not have a next manifest. This denotes that the manifest should be deleted from the cluster using the current revision.

func (*Revision) IsUpgrade

func (r *Revision) IsUpgrade() bool

IsUpgrade returns true if the manifest still exists in the next revision.

func (*Revision) IsValid

func (r *Revision) IsValid() bool

IsValid returns true if there is at least a current or a next manifest in the revision.

func (*Revision) Manifest

func (r *Revision) Manifest() *manifest.Manifest

Manifest returns the most recent manifest in the revision. If Next is present it will be returned, Current otherwise.

type Slice

type Slice []*Revision

Slice is a slice of revisions.

func NewSlice

func NewSlice(current, next []*manifest.Manifest) Slice

NewSlice takes two slices of manifests and pairs matching manifests into revisions with current and next manifest.

func (Slice) Reverse

func (s Slice) Reverse() Slice

Reverse reverses the order of a slice of *Revision. This is necessary to allow iterating all revisions in reverse order while deleting all manifests.

type Upgrader

type Upgrader interface {
	// Upgrader takes a context and a revision and performs an upgrade.
	// Depending on the type of revision it will carry out a complete creation
	// or deletion of the revision's manifest resources or just do partial
	// updates of resources that have been changed. It also executes hooks
	// before and after processing the revision.
	Upgrade(context.Context, *Revision) error
}

Upgrader handles revision upgrades.

func NewUpgrader

func NewUpgrader(client Client, o *UpgraderOptions) Upgrader

NewUpgrader creates a new Upgrader with client and options.

type UpgraderOptions

type UpgraderOptions struct {
	DryRun           bool
	IncludeUnchanged bool
	NoHooks          bool
	NoSave           bool
	ManifestsDir     string
	FullDiff         bool
}

UpgraderOptions configure an Upgrader.

Jump to

Keyboard shortcuts

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