model

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const Unknown = Color(-1)

Variables

View Source
var ValidColors = []Color{Blue, Green}

ValidColors is an Array of Valid Color Groups

Functions

func ColorNames

func ColorNames() []string

ColorNames returns a list of possible string values of Color.

Types

type BinaryConfig

type BinaryConfig struct {
	// Binary is the path to the binary to be Ran.
	// This will will search the PATH for which binary to use.
	// For more information refer to https://golang.org/pkg/os/exec/#LookPath
	// If empty `terraform` will be used.
	Binary string

	// Args are optional arguments to be supplied to the binary. Note this will show up in plain text.
	Args []ValuePair

	// PrivateArgs are arguments that will supplied to the binary via Environment Variables with the Prefix TF_VAR_.
	// Refer to https://www.terraform.io/docs/cli/config/environment-variables.html#tf_var_name for more information.
	PrivateArgs []ValuePair

	// Environment is additional environment variables to give the binary to run on top of the current environment.
	Environment []ValuePair

	// WorkingDirectory is the working directory to run the specified Binary.
	// If empty the current directory will be used.
	WorkingDirectory string
}

BinaryConfig represent the configuration in order to execute a terraform command.

type Cluster

type Cluster map[Color]ClusterGroup

Cluster is a representation of how Cluster is by the hostnames and version deployed. Note the Color Groups MUST be the same in both Hosts and Version.

func NewCluster

func NewCluster() Cluster

NewCluster creates a new Cluster with all the ValidColors set to an empty version with no Nodes.

func (Cluster) AsClusterState

func (c Cluster) AsClusterState() ClusterState

AsClusterState returns a ClusterState struct from a given Cluster

type ClusterGroup

type ClusterGroup struct {
	Hosts   []string       `json:"hosts"`
	Version semver.Version `json:"version"`
}

type ClusterGroupState

type ClusterGroupState struct {
	Count   int            `json:"count"`
	Version semver.Version `json:"version"`
}

type ClusterState

type ClusterState map[Color]ClusterGroupState

ClusterState is a simplified representation of Cluster where NodeCount equals the number of servers in the Color Group.

func NewClusterState

func NewClusterState() ClusterState

NewClusterState creates a new ClusterState with all the ValidColors set to an empty version with no Nodes.

func (ClusterState) AddNodes

func (cs ClusterState) AddNodes(group Color, count int) ClusterState

AddNodes creates a new ClusterState with the addition of nodes to the Color Group.

func (ClusterState) Clone

func (cs ClusterState) Clone() ClusterState

func (ClusterState) EqualNodeCount

func (cs ClusterState) EqualNodeCount(other ClusterState) bool

EqualNodeCount returns true if both structs have the same NodeCount map

func (ClusterState) EqualStep

func (cs ClusterState) EqualStep(step Step) bool

func (ClusterState) Group

func (cs ClusterState) Group() (Color, error)

Group returns the Color Group if the ClusterState is in a clean state, (see IsCleanState) otherwise returns the Unknown Color Group.

func (ClusterState) IsCleanState

func (cs ClusterState) IsCleanState() bool

IsCleanState returns true if only one Color Group has nodes.

func (ClusterState) IsEmpty

func (cs ClusterState) IsEmpty() bool

IsEmpty returns true if all the Color Groups have zero nodes.

func (ClusterState) String

func (cs ClusterState) String() string

type Color

type Color int

Color is simple type that serves to group deployment groups In our case, only two groups should be needed

ENUM( blue green )

const (
	// Blue is a Color of type Blue.
	Blue Color = iota
	// Green is a Color of type Green.
	Green
)

func ParseColor

func ParseColor(name string) (Color, error)

ParseColor attempts to convert a string to a Color

func (Color) MarshalText

func (x Color) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method

func (Color) Other

func (c Color) Other() Color

Other returns the complement color between Green and Blue

func (Color) String

func (x Color) String() string

String implements the Stringer interface.

func (*Color) UnmarshalText

func (x *Color) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method

type Errors

type Errors []error

Errors is a Multierror that also acts as an error, so that a log-friendly string can be returned but each error in the list can also be accessed.

func (Errors) Error

func (e Errors) Error() string

Error concatenates the list of error strings to provide a single string that can be used to represent the errors that occurred.

func (Errors) Errors

func (e Errors) Errors() []error

Errors returns the list of errors.

type MultiError

type MultiError interface {
	Errors() []error
}

MultiError is an interface that provides a list of errors.

type RunnableError

type RunnableError struct {
	Output    []byte
	ResultErr error
}

func (RunnableError) Error

func (e RunnableError) Error() string

func (*RunnableError) Unwrap

func (e *RunnableError) Unwrap() error

type Step

type Step map[Color]int

Step is the equivalent to the arguments of a single terraform command. (aka -var versionBlueCount=10 -var versionGreenCount=5)

func (Step) String

func (s Step) String() string

type StepError

type StepError struct {
	Cause              error        `json:"-"`
	TODO               []Step       `json:"todo"`
	OriginalCluster    Cluster      `json:"original_cluster"`
	StartingColorGroup Color        `json:"starting_group"`
	GoalClusterState   ClusterState `json:"goal_state"`
}

func (StepError) Error

func (e StepError) Error() string

func (*StepError) Unwrap

func (e *StepError) Unwrap() error

type ValuePair

type ValuePair struct {
	// Key is the case sensitive argument or environment name.
	Key string

	// Value is the associated value.
	Value string
}

ValuePair represents a key value pair and is a workaround for viper converting all keys to lower case. https://github.com/spf13/viper/issues/371

Jump to

Keyboard shortcuts

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