step

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2022 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

ClusterTypes is an enumeration of cluster specific types.

View Source
var InfraTypes = []Type{TypeInfra, TypeDestroy}

InfraTypes is an enumeration of types that apply to all clusters.

Types is an enumeration of all types.

Functions

func IsStateFinal

func IsStateFinal(state v1.StepState) bool

IsStateFinal returns true is state is a final state. A step in final state has stopped executing.

func IsStateLE

func IsStateLE(lhs, rhs v1.StepState) bool

IsStateLE returns true if lhs is less or equal to rhs assuming the ordering; "", Running, Ready | Error

func TypesFromString

func TypesFromString(s string) (map[Type]struct{}, error)

TypeFromString converts a comma separated list of type names to a set of Type. On empty input an nil set is returned.

Types

type AKSAddonPreflightStep

type AKSAddonPreflightStep struct {
	Metaa

	/* Parameters */
	// KCPath is the path of the kube config file.
	KCPath string

	// Kubectl is the kubectl implementation to use.
	Kubectl kubectl.Kubectrler
}

AKSAddonPreflightStep waits until all AKS specific preflight checks have been met.

func (*AKSAddonPreflightStep) Execute

func (st *AKSAddonPreflightStep) Execute(ctx context.Context, _ []string)

Execute runs preflight checks.

type AKSPoolStep

type AKSPoolStep struct {
	Metaa

	// ResourceGroup that contains Cluster.
	ResourceGroup string
	// Cluster is the name of the AKS cluster to upgrade the node pool(s) of.
	// NB. This is the AKS name (which is the short name with a prefix).
	Cluster string
	// Version is the Kubernetes version to upgrade the node pool(s) to.
	Version string

	// Azure is the azure cli implementation to use.
	Azure azure.AZer
}

AKSPoolStep can upgrade AKS node pools to the desired Kubernetes version.

func (*AKSPoolStep) Execute

func (st *AKSPoolStep) Execute(ctx context.Context, _ []string)

Execute node pool upgrade for a cluster.

type AddonStep

type AddonStep struct {
	Metaa

	Addon addon.Addonr

	// KCPath is the path of the kube config file.
	KCPath string
	// MasterVaultPath is the path to a directory containing the config of the Vault to use.
	MasterVaultPath string
	// SourcePath is the path to the directory containing the k8s resources.
	SourcePath string
	// JobPaths is collection of paths (relative to SourcePath) to job files.
	// kubectl-tmplt is run for each element in the collection.
	JobPaths []string
	// Values are passed with -set flag to kubectl-tmplt.
	Values map[string]string

	// The number of resources created, modified and deleted.
	Added, Changed, Deleted int
}

AddonStep performs a kubectl-tmplt apply.

func (*AddonStep) Execute

func (st *AddonStep) Execute(ctx context.Context, env []string)

Execute performs a kubectl-tmplt apply.

type DestroyStep

type DestroyStep struct {
	Metaa

	// Values to use for terraform input variables.
	Values InfraValues
	// SourcePath is the path to the directory containing terraform code.
	SourcePath string

	// Cloud provides generic cloud functionality.
	Cloud cloud.Cloud
	// Terraform is the terraform implementation to use.
	Terraform terraform.Terraformer
	// Azure is the azure cli implementation to use.
	Azure azure.AZer

	// The number of objects added, changed and deleted (destroyed) on terraform destroy completion.
	Added, Changed, Deleted int
}

DestroyStep performs a terraform destroy.

func (*DestroyStep) Execute

func (st *DestroyStep) Execute(ctx context.Context, env []string)

Execute terraform destroy.

type ID

type ID struct {
	// Type is the type of step, for example; Infra, Destroy, Addons.
	Type Type
	// Namespace Name identifies the plan to which the step belongs.
	Namespace, Name string
	// ClusterName (optional) is the name of the target cluster.
	ClusterName string
}

ID uniquely identifies a Step.

func (ID) ShortName

func (si ID) ShortName() string

ShortName returns a name that's unique within an environment.

type InfraStep

type InfraStep struct {
	Metaa

	// Values to use for terraform input variables.
	Values InfraValues
	// SourcePath is the path to the directory containing terraform code.
	SourcePath string
	// Cloud provides generic cloud functionality.
	Cloud cloud.Cloud
	// Azure provides Azure resource manager functionality.
	// (prefer to use Cloud instead of Azure)
	Azure azure.AZer
	// Terraform provides terraform functionality.
	Terraform terraform.Terraformer
	// Client is used to access the cluster envop is running in.
	Client cluster.Client
	// Kubectl is the kubectl implementation to use to access external clusters.
	Kubectl kubectl.Kubectrler
	// KubeconfigPathFn is a function that takes a cluster name and returns the path to the cluster kubeconfig file.
	KubeconfigPathFn func(string) (string, error)

	// Added, Changed, Deleted are then number of infrastructure objects affected.
	Added, Changed, Deleted int
}

InfraStep performs a terraform init, plan, apply and creates cluster credentials.

func (*InfraStep) Execute

func (st *InfraStep) Execute(ctx context.Context, env []string)

Execute performs the terraform commands.

type InfraValues

type InfraValues struct {
	Infra    v1.InfraSpec
	Clusters []v1.ClusterSpec
}

InfraValues hold the Specs that are needed during template expansion.

type Meta

type Meta interface {
	GetID() ID
	GetHash() string
	GetState() v1.StepState
	GetMsg() string
	GetLastUpdate() time.Time
	GetLastError() error
	SetOnUpdate(fn MetaUpdateFn)
}

Meta is behaviour that all steps have in common.

type MetaUpdateFn

type MetaUpdateFn func(Meta)

type Metaa

type Metaa struct {
	// ID uniquely identifies a step.
	ID ID
	// Hash is unique for the config/parameters applied by a step.
	Hash string
	// State indicates if a step is running, ready or is in error.
	State v1.StepState
	// Msg helps explaining the state. Mandatory for StepStateError.
	Msg string
	// LastUpdate is the time of the last state change.
	LastUpdate time.Time
	// contains filtered or unexported fields
}

Metaa is the data that all steps have in common. (it is embedded in all Steps types)

func (*Metaa) GetHash

func (m *Metaa) GetHash() string

func (*Metaa) GetID

func (m *Metaa) GetID() ID

func (*Metaa) GetLastError

func (m *Metaa) GetLastError() error

func (*Metaa) GetLastUpdate

func (m *Metaa) GetLastUpdate() time.Time

func (*Metaa) GetMsg

func (m *Metaa) GetMsg() string

func (*Metaa) GetState

func (m *Metaa) GetState() v1.StepState

func (*Metaa) SetOnUpdate

func (m *Metaa) SetOnUpdate(fn MetaUpdateFn)

type Step

type Step interface {
	Meta
	// Execute a step.
	Execute(context.Context, []string)
}

Step is an unit of execution.

type Type

type Type string

Type of step.

const (
	TypeInfra             Type = "Infra"
	TypeDestroy           Type = "Destroy"
	TypeAKSPool           Type = "AKSPool"
	TypeAKSAddonPreflight Type = "AKSAddonPreflight"
	TypeAddons            Type = "Addons"
)

type Updater

type Updater interface {
	Update(Meta)
}

Updater is a third party that wants to know about Step state changes.

Jump to

Keyboard shortcuts

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