step

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2021 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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 empty 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 node pool upgrade for a cluster.

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 addon apply for a cluster.

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

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

InfraStep performs a terraform init, plan and apply.

func (*InfraStep) Execute

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

Run a step.

type InfraValues

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

InfraValues hold the Specs that are needed during template expansion.

type KubeconfigStep

type KubeconfigStep struct {
	Metaa

	// TFPath is the path to the directory containing terraform code.
	TFPath string
	// ClusterName is the name of the k8s cluster to create a kube config for.
	ClusterName string
	// KCPath is the place were the kube config file is written.
	KCPath string
	// Access is the token access terraform state with.
	Access string

	// Cloud provides generic cloud functionality.
	Cloud cloud.Cloud
	// Terraform is the terraform implementation to use.
	Terraform terraform.Terraformer
	// Kubectl is the kubectl implementation to use.
	Kubectl kubectl.Kubectrler

	// Values are key-values like k8sEnvironment, k8sCluster, k8sDomain, k8sProvider
	Values map[string]string

	// Client is used to access the cluster envop is running in.
	Client cluster.Client
}

KubeconfigStep reads data from terraform, creates a kubeconfig file and syncs Secrets containing kubeconfigs.

func (*KubeconfigStep) Execute

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

Run a step.

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"
	TypeKubeconfig        Type = "Kubeconfig"
	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