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 FormatTerraformPlanFileAsArg(commandType string, outPath string) []string
- func GetExitCodeForAtmosCommand(t testing.TestingT, additionalOptions *Options, args ...string) int
- func GetExitCodeForAtmosCommandE(t testing.TestingT, additionalOptions *Options, additionalArgs ...string) (int, 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 testing.TestingT, additionalOptions *Options, args ...string) string
- func RunAtmosCommandAndGetStdoutE(t testing.TestingT, additionalOptions *Options, additionalArgs ...string) (string, error)
- func RunAtmosCommandE(t testing.TestingT, additionalOptions *Options, additionalArgs ...string) (string, error)
- type DescribeStacksComponent
- type DescribeStacksOutput
- type DescribeStacksTerraform
- type DescribeStacksTerraformComponent
- type Options
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 GetExitCodeForAtmosCommand ¶
GetExitCodeForAtmosCommand runs atmos with the given arguments and options and returns exit code
func GetExitCodeForAtmosCommandE ¶
func GetExitCodeForAtmosCommandE(t testing.TestingT, additionalOptions *Options, additionalArgs ...string) (int, error)
GetExitCodeForAtmosCommandE runs atmos with the given arguments and options and returns exit code
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.
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 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 }
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.