Documentation ¶
Index ¶
- Constants
- Variables
- func ColorNames() []string
- type BinaryConfig
- type Cluster
- type ClusterGroup
- type ClusterGroupState
- type ClusterState
- func (cs ClusterState) AddNodes(group Color, count int) ClusterState
- func (cs ClusterState) Clone() ClusterState
- func (cs ClusterState) EqualNodeCount(other ClusterState) bool
- func (cs ClusterState) EqualStep(step Step) bool
- func (cs ClusterState) Group() (Color, error)
- func (cs ClusterState) IsCleanState() bool
- func (cs ClusterState) IsEmpty() bool
- func (cs ClusterState) String() string
- type Color
- type Errors
- type MultiError
- type RunnableError
- type Step
- type StepError
- type ValuePair
Constants ¶
const Unknown = Color(-1)
Variables ¶
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 )
func ParseColor ¶
ParseColor attempts to convert a string to a Color
func (Color) MarshalText ¶
MarshalText implements the text marshaller method
func (*Color) UnmarshalText ¶
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.
type MultiError ¶
type MultiError interface {
Errors() []error
}
MultiError is an interface that provides a list of errors.
type RunnableError ¶
func (RunnableError) Error ¶
func (e RunnableError) Error() string
func (*RunnableError) Unwrap ¶
func (e *RunnableError) Unwrap() error
type Step ¶
Step is the equivalent to the arguments of a single terraform command. (aka -var versionBlueCount=10 -var versionGreenCount=5)
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"` }
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