Documentation ¶
Index ¶
- Constants
- Variables
- func Apply(t testing.TestingT, options *Options) string
- func ApplyAndIdempotent(t testing.TestingT, options *Options) string
- func ApplyAndIdempotentE(t testing.TestingT, options *Options) (string, error)
- func ApplyE(t testing.TestingT, options *Options) (string, error)
- func Destroy(t testing.TestingT, options *Options) string
- func DestroyE(t testing.TestingT, options *Options) (string, error)
- func FormatArgs(options *Options, args ...string) []string
- func FormatAtmosTerraformArgs(options *Options, args ...string) []string
- func FormatAtmosVendorArgs(options *Options, args ...string) []string
- func FormatTerraformPlanFileAsArg(commandType string, outPath string) []string
- func GetExitCodeForAtmosCommand(t tt.TestingT, additionalOptions *Options, args ...string) int
- func GetExitCodeForAtmosCommandE(t tt.TestingT, additionalOptions *Options, additionalArgs ...string) (int, error)
- func Output(t testing.TestingT, options *Options, key string) string
- func OutputAll(t testing.TestingT, options *Options) map[string]interface{}
- func OutputAllE(t testing.TestingT, options *Options) (map[string]interface{}, error)
- func OutputE(t testing.TestingT, options *Options, key string) (string, error)
- func OutputForKeys(t testing.TestingT, options *Options, keys []string) map[string]interface{}
- func OutputForKeysE(t testing.TestingT, options *Options, keys []string) (map[string]interface{}, error)
- func OutputJson(t testing.TestingT, options *Options, key string) string
- func OutputJsonE(t testing.TestingT, options *Options, key string) (string, error)
- func OutputList(t testing.TestingT, options *Options, key string) []string
- func OutputListE(t testing.TestingT, options *Options, key string) ([]string, error)
- func OutputListOfObjects(t testing.TestingT, options *Options, key string) []map[string]interface{}
- func OutputListOfObjectsE(t testing.TestingT, options *Options, key string) ([]map[string]interface{}, error)
- func OutputMap(t testing.TestingT, options *Options, key string) map[string]string
- func OutputMapE(t testing.TestingT, options *Options, key string) (map[string]string, error)
- func OutputMapOfObjects(t testing.TestingT, options *Options, key string) map[string]interface{}
- func OutputMapOfObjectsE(t testing.TestingT, options *Options, key string) (map[string]interface{}, error)
- func OutputRequired(t testing.TestingT, options *Options, key string) string
- func OutputRequiredE(t testing.TestingT, options *Options, key string) (string, error)
- func OutputStruct(t testing.TestingT, options *Options, key string, v interface{})
- func OutputStructE(t testing.TestingT, options *Options, key string, v interface{}) error
- func Plan(t testing.TestingT, options *Options) string
- func PlanE(t testing.TestingT, options *Options) (string, error)
- func PlanExitCode(t testing.TestingT, options *Options) int
- func PlanExitCodeE(t testing.TestingT, options *Options) (int, error)
- func RunAtmosCommand(t tt.TestingT, additionalOptions *Options, args ...string) string
- func RunAtmosCommandAndGetStdoutE(t tt.TestingT, additionalOptions *Options, additionalArgs ...string) (string, error)
- func RunAtmosCommandE(t tt.TestingT, additionalOptions *Options, additionalArgs ...string) (string, error)
- func VendorPull(t testing.TestingT, options *Options) string
- func VendorPullE(t testing.TestingT, options *Options) (string, error)
- type DescribeStacksComponent
- type DescribeStacksOutput
- type DescribeStacksTerraform
- type DescribeStacksTerraformComponent
- type EmptyOutput
- type InputFileKeyNotFound
- type Options
- type OutputKeyNotFound
- type OutputValueNotList
- type OutputValueNotMap
- type PanicWhileParsingVarFile
- type UnexpectedOutputType
- type UnsupportedDefaultWorkspaceDeletion
- type VarFileNotFound
- type WorkspaceDoesNotExist
Constants ¶
const (
// AtmosDefaultPath command to run atmos
AtmosDefaultPath = "atmos"
)
const DefaultErrorExitCode = 1
DefaultErrorExitCode is the exit code returned when atmos command fails
const DefaultSuccessExitCode = 0
DefaultSuccessExitCode is the exit code returned when atmos command succeeds
const TerraformPlanChangesPresentExitCode = 2
TerraformPlanChangesPresentExitCode is the exit code returned by atmos terraform plan detailed exitcode when changes are present
Variables ¶
var ( ErrorComponentRequired = fmt.Errorf("you must set Component on options struct to use this function") ErrorPlanFilePathRequired = fmt.Errorf("you must set PlanFilePath on options struct to use this function") ErrorStackRequired = fmt.Errorf("you must set Stack on options struct to use this function") )
Custom errors
var DefaultExecutable = defaultAtmosExecutable()
var (
DefaultRetryableAtmosErrors = map[string]string{
".*read: connection reset by peer.*": "Failed to reach helm charts repository.",
".*transport is closing.*": "Failed to reach Kubernetes API.",
".*unable to verify signature.*": "Failed to retrieve plugin due to transient network error.",
".*unable to verify checksum.*": "Failed to retrieve plugin due to transient network error.",
".*no provider exists with the given name.*": "Failed to retrieve plugin due to transient network error.",
".*registry service is unreachable.*": "Failed to retrieve plugin due to transient network error.",
".*Error installing provider.*": "Failed to retrieve plugin due to transient network error.",
".*Failed to query available provider packages.*": "Failed to retrieve plugin due to transient network error.",
".*timeout while waiting for plugin to start.*": "Failed to retrieve plugin due to transient network error.",
".*timed out waiting for server handshake.*": "Failed to retrieve plugin due to transient network error.",
"could not query provider registry for": "Failed to retrieve plugin due to transient network error.",
".*Provider produced inconsistent result after apply.*": "Provider eventual consistency error.",
}
)
var TerraformCommandsWithPlanFileSupport = []string{
"plan",
"apply",
"show",
"graph",
}
TerraformCommandsWithPlanFileSupport is a list of all the Terraform commands that support interacting with plan files.
Functions ¶
func Apply ¶
Apply runs atmos terraform apply with the given options and return stdout/stderr. Note that this method does NOT call destroy and assumes the caller is responsible for cleaning up any resources created by running apply.
func ApplyAndIdempotent ¶
ApplyAndIdempotent runs atmos terraform apply with the given options and return stdout/stderr from the apply command. It then runs plan again and will fail the test if plan requires additional changes. Note that this method does NOT call destroy and assumes the caller is responsible for cleaning up any resources created by running apply.
func ApplyAndIdempotentE ¶
ApplyAndIdempotentE runs atmos terraform apply with the given options and return stdout/stderr from the apply command. It then runs plan again and will fail the test if plan requires additional changes. Note that this method does NOT call destroy and assumes the caller is responsible for cleaning up any resources created by running apply.
func ApplyE ¶
ApplyE runs atmos terraform apply with the given options and return stdout/stderr. Note that this method does NOT call destroy and assumes the caller is responsible for cleaning up any resources created by running apply.
func Destroy ¶
Destroy runs atmos terraform destroy with the given options and return stdout/stderr.
func DestroyE ¶
DestroyE runs atmos terraform destroy with the given options and return stdout/stderr.
func FormatArgs ¶
func FormatAtmosTerraformArgs ¶
FormatTerraformArgs converts the inputs to a format palatable to terraform. This includes converting the given vars to the format the Terraform CLI expects (-var key=value).
func FormatAtmosVendorArgs ¶
FormatAtmosVendorArgs converts the inputs to a format palatable to atmos vendor.
func GetExitCodeForAtmosCommand ¶
GetExitCodeForAtmosCommand runs atmos with the given arguments and options and returns exit code
func GetExitCodeForAtmosCommandE ¶
func GetExitCodeForAtmosCommandE(t tt.TestingT, additionalOptions *Options, additionalArgs ...string) (int, error)
GetExitCodeForAtmosCommandE runs atmos with the given arguments and options and returns exit code
func Output ¶
Output calls atmos terraform output for the given variable and return its string value representation. It only designed to work with primitive terraform types: string, number and bool. Please use OutputStruct for anything else.
func OutputAll ¶
OutputAll calls terraform output returns all values as a map. If there is error fetching the output, fails the test
func OutputAllE ¶
OutputAllE calls terraform and returns all the outputs as a map
func OutputE ¶
OutputE calls atmos terraform output for the given variable and return its string value representation. It only designed to work with primitive terraform types: string, number and bool. Please use OutputStructE for anything else.
func OutputForKeys ¶
OutputForKeys calls terraform output for the given key list and returns values as a map. If keys not found in the output, fails the test
func OutputForKeysE ¶
func OutputForKeysE(t testing.TestingT, options *Options, keys []string) (map[string]interface{}, error)
OutputForKeysE calls terraform output for the given key list and returns values as a map. The returned values are of type interface{} and need to be type casted as necessary. Refer to output_test.go
func OutputJson ¶
OutputJson calls terraform output for the given variable and returns the result as the json string. If key is an empty string, it will return all the output variables.
func OutputJsonE ¶
OutputJsonE calls terraform output for the given variable and returns the result as the json string. If key is an empty string, it will return all the output variables.
func OutputList ¶
OutputList calls terraform output for the given variable and returns its value as a list. If the output value is not a list type, then it fails the test.
func OutputListE ¶
OutputListE calls terraform output for the given variable and returns its value as a list. If the output value is not a list type, then it returns an error.
func OutputListOfObjects ¶
OutputListOfObjects calls terraform output for the given variable and returns its value as a list of maps/lists. If the output value is not a list of maps/lists, then it fails the test.
func OutputListOfObjectsE ¶
func OutputListOfObjectsE(t testing.TestingT, options *Options, key string) ([]map[string]interface{}, error)
OutputListOfObjectsE calls terraform output for the given variable and returns its value as a list of maps/lists. Also returns an error object if an error was generated. If the output value is not a list of maps/lists, then it fails the test.
func OutputMap ¶
OutputMap calls terraform output for the given variable and returns its value as a map. If the output value is not a map type, then it fails the test.
func OutputMapE ¶
OutputMapE calls terraform output for the given variable and returns its value as a map. If the output value is not a map type, then it returns an error.
func OutputMapOfObjects ¶
OutputMapOfObjects calls terraform output for the given variable and returns its value as a map of lists/maps. If the output value is not a map of lists/maps, then it fails the test.
func OutputMapOfObjectsE ¶
func OutputMapOfObjectsE(t testing.TestingT, options *Options, key string) (map[string]interface{}, error)
OutputMapOfObjectsE calls terraform output for the given variable and returns its value as a map of lists/maps. Also returns an error object if an error was generated. If the output value is not a map of lists/maps, then it fails the test.
func OutputRequired ¶
OutputRequired calls atmos terraform output for the given variable and return its value. If the value is empty, fail the test.
func OutputRequiredE ¶
OutputRequiredE calls atmos terraform output for the given variable and return its value. If the value is empty, return an error.
func OutputStruct ¶
OutputStruct calls terraform output for the given variable and stores the result in the value pointed to by v. If v is nil or not a pointer, or if the value returned by Terraform is not appropriate for a given target type, it fails the test.
func OutputStructE ¶
OutputStructE calls terraform output for the given variable and stores the result in the value pointed to by v. If v is nil or not a pointer, or if the value returned by Terraform is not appropriate for a given target type, it returns an error.
func Plan ¶
Plan runs terraform plan with the given options and returns stdout/stderr. This will fail the test if there is an error in the command.
func PlanExitCode ¶
PlanExitCode runs terraform plan with the given options and returns the detailed exitcode. This will fail the test if there is an error in the command.
func PlanExitCodeE ¶
PlanExitCodeE runs terraform plan with the given options and returns the detailed exitcode.
func RunAtmosCommand ¶
RunAtmosCommand runs atmos with the given arguments and options and return stdout/stderr.
func RunAtmosCommandAndGetStdoutE ¶
func RunAtmosCommandAndGetStdoutE(t tt.TestingT, additionalOptions *Options, additionalArgs ...string) (string, error)
RunAtmosCommandAndGetStdoutE runs atmos with the given arguments and options and returns solely its stdout (but not stderr).
func RunAtmosCommandE ¶
func RunAtmosCommandE(t tt.TestingT, additionalOptions *Options, additionalArgs ...string) (string, error)
RunAtmosCommandE runs atmos with the given arguments and options and return stdout/stderr.
func VendorPull ¶
Vendor runs atmos vendor with the given options and return stdout/stderr.
Types ¶
type DescribeStacksComponent ¶
type DescribeStacksOutput ¶
type DescribeStacksOutput struct {
Stacks map[string]DescribeStacksComponent
}
type DescribeStacksTerraform ¶
type DescribeStacksTerraform struct {
Terraform map[string]DescribeStacksTerraformComponent `json:"terraform"`
}
type DescribeStacksTerraformComponent ¶
type DescribeStacksTerraformComponent struct { AtmosComponent string `json:"atmos_component"` AtmosStack string `json:"atmos_stack"` AtmosStackFile string `json:"atmos_stack_file"` Backend interface{} `json:"backend"` BackendType string `json:"backend_type"` Command string `json:"command"` Component string `json:"component"` Env interface{} `json:"env"` Inheritance interface{} `json:"inheritance"` Metadata interface{} `json:"metadata"` Overrides interface{} `json:"overrides"` RemoteStateBackend interface{} `json:"remote_state_backend"` RemoteStateBackendType string `json:"remote_state_backend_type"` Settings interface{} `json:"settings"` Vars interface{} `json:"vars"` Workspace string `json:"workspace"` }
type EmptyOutput ¶
type EmptyOutput string
EmptyOutput is an error that occurs when an output is empty.
func (EmptyOutput) Error ¶
func (outputName EmptyOutput) Error() string
type InputFileKeyNotFound ¶
InputFileKeyNotFound occurs when tfvar file does not contain a value for the key specified in the function call
func (InputFileKeyNotFound) Error ¶
func (err InputFileKeyNotFound) Error() string
type Options ¶
type Options struct { AtmosBinary string // Name of the binary that will be used AtmosBasePath string // The path of the atmos root for components and stacks // The vars to pass to Atmos commands using the -var option. Note that atmos does not support passing `null` // as a variable value through the command line. That is, if you use `map[string]interface{}{"foo": nil}` as `Vars`, // this will translate to the string literal `"null"` being assigned to the variable `foo`. However, nulls in // lists and maps/objects are supported. E.g., the following var will be set as expected (`{ bar = null }`: // map[string]interface{}{ // "foo": map[string]interface{}{"bar": nil}, // } Vars map[string]interface{} VarFiles []string // The var file paths to pass to Atmos commands using -var-file option. Stack string // The stack to pass to the atmos command with -stack Component string // The component to pass to the atmos terraform command Targets []string // The target resources to pass to the atmos command with -target Lock bool // The lock option to pass to the atmos command with -lock LockTimeout string // The lock timeout option to pass to the atmos command with -lock-timeout EnvVars map[string]string // Environment variables to set when running Atmos BackendConfig map[string]interface{} // The vars to pass to the atmos init command for extra configuration for the backend RetryableAtmosErrors map[string]string // If Atmos apply fails with one of these (transient) errors, retry. The keys are a regexp to match against the error and the message is what to display to a user if that error is matched. MaxRetries int // Maximum number of times to retry errors matching RetryableAtmosErrors TimeBetweenRetries time.Duration // The amount of time to wait between retries Upgrade bool // Whether the -upgrade flag of the atmos init command should be set to true or not Reconfigure bool // Set the -reconfigure flag to the atmos init command MigrateState bool // Set the -migrate-state and -force-copy (suppress 'yes' answer prompt) flag to the atmos init command NoColor bool // Whether the -no-color flag will be set for any Atmos command or not RedirectStrErrDestination string // The destination to redirect stderr to. If nil, stderr will not be redirected. SshAgent *ssh.SshAgent // Overrides local SSH agent with the given in-process agent NoStderr bool // Disable stderr redirection OutputMaxLineSize int // The max size of one line in stdout and stderr (in bytes) Logger *logger.Logger // Set a non-default logger that should be used. See the logger package for more info. Parallelism int // Set the parallelism setting for Atmos PlanFilePath string // The path to output a plan file to (for the plan command) or read one from (for the apply command) PluginDir string // The path of downloaded plugins to pass to the atmos init command (-plugin-dir) SetVarsAfterVarFiles bool // Pass -var options after -var-file options to Atmos commands WarningsAsErrors map[string]string // Terraform warning messages that should be treated as errors. The keys are a regexp to match against the warning and the value is what to display to a user if that warning is matched. VendorComponent string // The component to pass to the atmos vendor command, if not passed all components will be vendored VendorStack string // The stack to pass to the atmos vendor command, if not passed all stacks will be vendored VendorTags []string // The tags to pass to the atmos vendor command, if not passed all tags will be vendored VendorType string // The type of vendor to pass to the atmos vendor command, if not passed `terraform` will be used }
Options for running Atmos commands
func GetCommonOptions ¶
GetCommonOptions extracts commons atmos options
func WithDefaultRetryableErrors ¶
WithDefaultRetryableErrors makes a copy of the Options object and returns an updated object with sensible defaults for retryable errors. The included retryable errors are typical errors that most atmos modules encounter during testing, and are known to self resolve upon retrying. This will fail the test if there are any errors in the cloning process.
type OutputKeyNotFound ¶
type OutputKeyNotFound string
OutputKeyNotFound occurs when terraform output does not contain a value for the key specified in the function call
func (OutputKeyNotFound) Error ¶
func (err OutputKeyNotFound) Error() string
type OutputValueNotList ¶
type OutputValueNotList struct {
Value interface{}
}
OutputValueNotList occurs when casting a found output value to a list of interfaces fails
func (OutputValueNotList) Error ¶
func (err OutputValueNotList) Error() string
type OutputValueNotMap ¶
type OutputValueNotMap struct {
Value interface{}
}
OutputValueNotMap occures when casting a found output value to a map fails
func (OutputValueNotMap) Error ¶
func (err OutputValueNotMap) Error() string
type PanicWhileParsingVarFile ¶
type PanicWhileParsingVarFile struct { ConfigFile string RecoveredValue interface{} }
PanicWhileParsingVarFile is returned when the HCL parsing routine panics due to errors.
func (PanicWhileParsingVarFile) Error ¶
func (err PanicWhileParsingVarFile) Error() string
type UnexpectedOutputType ¶
UnexpectedOutputType is an error that occurs when the output is not of the type we expect
func (UnexpectedOutputType) Error ¶
func (err UnexpectedOutputType) Error() string
type UnsupportedDefaultWorkspaceDeletion ¶
type UnsupportedDefaultWorkspaceDeletion struct{}
UnsupportedDefaultWorkspaceDeletion is returned when user tries to delete the workspace "default"
func (*UnsupportedDefaultWorkspaceDeletion) Error ¶
func (err *UnsupportedDefaultWorkspaceDeletion) Error() string
type VarFileNotFound ¶
type VarFileNotFound struct {
Path string
}
VarFileNotFound is an error that occurs when a var file cannot be found in an option's VarFile list
func (VarFileNotFound) Error ¶
func (err VarFileNotFound) Error() string
type WorkspaceDoesNotExist ¶
type WorkspaceDoesNotExist string
WorkspaceDoesNotExist is returned when user tries to delete a workspace which does not exist
func (WorkspaceDoesNotExist) Error ¶
func (err WorkspaceDoesNotExist) Error() string