tfexec

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2020 License: MPL-2.0 Imports: 17 Imported by: 241

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllowMissingConfigOption

type AllowMissingConfigOption struct {
	// contains filtered or unexported fields
}

AllowMissingConfigOption represents the -allow-missing-config flag.

func AllowMissingConfig

func AllowMissingConfig(allowMissingConfig bool) *AllowMissingConfigOption

AllowMissingConfig represents the -allow-missing-config flag.

type ApplyOption

type ApplyOption interface {
	// contains filtered or unexported methods
}

ApplyOption represents options used in the Apply method.

type BackendConfigOption

type BackendConfigOption struct {
	// contains filtered or unexported fields
}

BackendConfigOption represents the -backend-config flag.

func BackendConfig

func BackendConfig(backendConfig string) *BackendConfigOption

BackendConfig represents the -backend-config flag.

type BackendOption

type BackendOption struct {
	// contains filtered or unexported fields
}

BackendOption represents the -backend flag.

func Backend

func Backend(backend bool) *BackendOption

Backend represents the -backend flag.

type BackupOption

type BackupOption struct {
	// contains filtered or unexported fields
}

BackupOption represents the -backup flag.

func Backup

func Backup(path string) *BackupOption

Backup represents the -backup flag.

func DisableBackup added in v0.3.0

func DisableBackup() *BackupOption

DisableBackup is a convenience method for Backup("-"), indicating backup state should be disabled.

type ConfigOption

type ConfigOption struct {
	// contains filtered or unexported fields
}

ConfigOption represents the -config flag.

func Config

func Config(path string) *ConfigOption

Config represents the -config flag.

type CopyStateOption added in v0.8.0

type CopyStateOption struct {
	// contains filtered or unexported fields
}

CopyStateOption represents the -state flag for terraform workspace new. This flag is used to copy an existing state file in to the new workspace.

func CopyState added in v0.8.0

func CopyState(path string) *CopyStateOption

CopyState represents the -state flag for terraform workspace new. This flag is used to copy an existing state file in to the new workspace.

type DestroyFlagOption

type DestroyFlagOption struct {
	// contains filtered or unexported fields
}

func Destroy

func Destroy(destroy bool) *DestroyFlagOption

Destroy represents the -destroy flag.

type DestroyOption

type DestroyOption interface {
	// contains filtered or unexported methods
}

DestroyOption represents options used in the Destroy method.

type DirOption added in v0.7.0

type DirOption struct {
	// contains filtered or unexported fields
}

func Dir added in v0.7.0

func Dir(path string) *DirOption

type DirOrPlanOption

type DirOrPlanOption struct {
	// contains filtered or unexported fields
}

func DirOrPlan

func DirOrPlan(path string) *DirOrPlanOption

type ErrCLIUsage

type ErrCLIUsage struct {
	// contains filtered or unexported fields
}

ErrCLIUsage is returned when the combination of flags or arguments is incorrect.

CLI indicates usage errors in three different ways: either

1. Exit 1, with a custom error message on stderr. 2. Exit 1, with command usage logged to stderr. 3. Exit 127, with command usage logged to stdout. Currently cases 1 and 2 are handled. TODO KEM: Handle exit 127 case. How does this work on non-Unix platforms?

func (*ErrCLIUsage) Error

func (e *ErrCLIUsage) Error() string

type ErrManualEnvVar added in v0.4.0

type ErrManualEnvVar struct {
	// contains filtered or unexported fields
}

ErrManualEnvVar is returned when an env var that should be set programatically via an option or method is set via the manual environment passing functions.

func (*ErrManualEnvVar) Error added in v0.4.0

func (err *ErrManualEnvVar) Error() string

type ErrMissingVar added in v0.7.0

type ErrMissingVar struct {
	VariableName string
}

func (*ErrMissingVar) Error added in v0.7.0

func (err *ErrMissingVar) Error() string

type ErrNoConfig

type ErrNoConfig struct {
	// contains filtered or unexported fields
}

func (*ErrNoConfig) Error

func (e *ErrNoConfig) Error() string

type ErrNoInit

type ErrNoInit struct {
	// contains filtered or unexported fields
}

func (*ErrNoInit) Error

func (e *ErrNoInit) Error() string

type ErrNoSuitableBinary

type ErrNoSuitableBinary struct {
	// contains filtered or unexported fields
}

func (*ErrNoSuitableBinary) Error

func (e *ErrNoSuitableBinary) Error() string

type ErrNoWorkspace added in v0.8.0

type ErrNoWorkspace struct {
	Name string
}

func (*ErrNoWorkspace) Error added in v0.8.0

func (err *ErrNoWorkspace) Error() string

type ErrVersionMismatch

type ErrVersionMismatch struct {
	MinInclusive string
	MaxExclusive string
	Actual       string
}

ErrVersionMismatch is returned when the detected Terraform version is not compatible with the command or flags being used in this invocation.

func (*ErrVersionMismatch) Error added in v0.5.0

func (e *ErrVersionMismatch) Error() string

type ForceCopyOption

type ForceCopyOption struct {
	// contains filtered or unexported fields
}

func ForceCopy

func ForceCopy(forceCopy bool) *ForceCopyOption

type FromModuleOption

type FromModuleOption struct {
	// contains filtered or unexported fields
}

func FromModule

func FromModule(source string) *FromModuleOption

type GetOption

type GetOption struct {
	// contains filtered or unexported fields
}

func Get

func Get(get bool) *GetOption

type GetPluginsOption

type GetPluginsOption struct {
	// contains filtered or unexported fields
}

func GetPlugins

func GetPlugins(getPlugins bool) *GetPluginsOption

type ImportOption

type ImportOption interface {
	// contains filtered or unexported methods
}

ImportOption represents options used in the Import method.

type InitOption

type InitOption interface {
	// contains filtered or unexported methods
}

InitOption represents options used in the Init method.

type LockOption

type LockOption struct {
	// contains filtered or unexported fields
}

LockOption represents the -lock flag.

func Lock

func Lock(lock bool) *LockOption

Lock represents the -lock flag.

type LockTimeoutOption

type LockTimeoutOption struct {
	// contains filtered or unexported fields
}

LockTimeoutOption represents the -lock-timeout flag.

func LockTimeout

func LockTimeout(lockTimeout string) *LockTimeoutOption

LockTimeout represents the -lock-timeout flag.

type OutOption

type OutOption struct {
	// contains filtered or unexported fields
}

func Out

func Out(path string) *OutOption

type OutputMeta

type OutputMeta struct {
	Sensitive bool            `json:"sensitive"`
	Type      json.RawMessage `json:"type"`
	Value     json.RawMessage `json:"value"`
}

OutputMeta represents the JSON output of 'terraform output -json', which resembles state format version 3 due to a historical accident. Please see hashicorp/terraform/command/output.go. TODO KEM: Should this type be in terraform-json?

type OutputOption

type OutputOption interface {
	// contains filtered or unexported methods
}

type ParallelismOption

type ParallelismOption struct {
	// contains filtered or unexported fields
}

func Parallelism

func Parallelism(n int) *ParallelismOption

type PlanOption

type PlanOption interface {
	// contains filtered or unexported methods
}

type PluginDirOption

type PluginDirOption struct {
	// contains filtered or unexported fields
}

func PluginDir

func PluginDir(pluginDir string) *PluginDirOption

type ReconfigureOption

type ReconfigureOption struct {
	// contains filtered or unexported fields
}

func Reconfigure

func Reconfigure(reconfigure bool) *ReconfigureOption

type RefreshCmdOption added in v0.7.0

type RefreshCmdOption interface {
	// contains filtered or unexported methods
}

type RefreshOption

type RefreshOption struct {
	// contains filtered or unexported fields
}

func Refresh

func Refresh(refresh bool) *RefreshOption

type StateOption

type StateOption struct {
	// contains filtered or unexported fields
}

func State deprecated

func State(path string) *StateOption

State represents the -state flag.

Deprecated: The -state CLI flag is a legacy flag and should not be used. If you need a different state file for every run, you can instead use the local backend. See https://github.com/hashicorp/terraform/issues/25920#issuecomment-676560799

type StateOutOption

type StateOutOption struct {
	// contains filtered or unexported fields
}

func StateOut

func StateOut(path string) *StateOutOption

type TargetOption

type TargetOption struct {
	// contains filtered or unexported fields
}

func Target

func Target(resource string) *TargetOption

type Terraform

type Terraform struct {
	// contains filtered or unexported fields
}

func NewTerraform

func NewTerraform(workingDir string, execPath string) (*Terraform, error)

NewTerraform returns a Terraform struct with default values for all fields. If a blank execPath is supplied, NewTerraform will attempt to locate an appropriate binary on the system PATH.

func (*Terraform) Apply

func (tf *Terraform) Apply(ctx context.Context, opts ...ApplyOption) error

func (*Terraform) Destroy

func (tf *Terraform) Destroy(ctx context.Context, opts ...DestroyOption) error

func (*Terraform) ExecPath added in v0.5.0

func (tf *Terraform) ExecPath() string

ExecPath returns the path to the Terraform executable.

func (*Terraform) Import added in v0.2.0

func (tf *Terraform) Import(ctx context.Context, address, id string, opts ...ImportOption) error

func (*Terraform) Init

func (tf *Terraform) Init(ctx context.Context, opts ...InitOption) error

func (*Terraform) Output

func (tf *Terraform) Output(ctx context.Context, opts ...OutputOption) (map[string]OutputMeta, error)

func (*Terraform) Plan

func (tf *Terraform) Plan(ctx context.Context, opts ...PlanOption) (bool, error)

Plan executes `terraform plan` with the specified options and waits for it to complete.

The returned boolean is false when the plan diff is empty (no changes) and true when the plan diff is non-empty (changes present).

The returned error is nil if `terraform plan` has been executed and exits with either 0 or 2.

func (*Terraform) ProvidersSchema

func (tf *Terraform) ProvidersSchema(ctx context.Context) (*tfjson.ProviderSchemas, error)

func (*Terraform) Refresh added in v0.7.0

func (tf *Terraform) Refresh(ctx context.Context, opts ...RefreshCmdOption) error

func (*Terraform) SetAppendUserAgent added in v0.8.0

func (tf *Terraform) SetAppendUserAgent(ua string)

SetAppendUserAgent sets the TF_APPEND_USER_AGENT environment variable for Terraform CLI execution.

func (*Terraform) SetEnv

func (tf *Terraform) SetEnv(env map[string]string) error

SetEnv allows you to override environment variables, this should not be used for any well known Terraform environment variables that are already covered in options. Pass nil to copy the values from os.Environ. Attempting to set environment variables that should be managed manually will result in ErrManualEnvVar being returned.

func (*Terraform) SetLogPath added in v0.4.0

func (tf *Terraform) SetLogPath(path string) error

SetLogPath sets the TF_LOG_PATH environment variable for Terraform CLI execution.

func (*Terraform) SetLogger

func (tf *Terraform) SetLogger(logger printfer)

SetLogger specifies a logger for tfexec to use.

func (*Terraform) SetStderr added in v0.6.0

func (tf *Terraform) SetStderr(w io.Writer)

SetStderr specifies a writer to stream stderr to for every command.

This should be used for information or logging purposes only, not control flow. Any parsing necessary should be added as functionality to this package.

func (*Terraform) SetStdout added in v0.6.0

func (tf *Terraform) SetStdout(w io.Writer)

SetStdout specifies a writer to stream stdout to for every command.

This should be used for information or logging purposes only, not control flow. Any parsing necessary should be added as functionality to this package.

func (*Terraform) Show added in v0.3.0

func (tf *Terraform) Show(ctx context.Context) (*tfjson.State, error)

Show reads the default state path and outputs the state. To read a state or plan file, ShowState or ShowPlan must be used instead.

func (*Terraform) ShowPlanFile added in v0.7.0

func (tf *Terraform) ShowPlanFile(ctx context.Context, planPath string) (*tfjson.Plan, error)

ShowPlanFile reads a given plan file and outputs the plan.

func (*Terraform) ShowStateFile added in v0.7.0

func (tf *Terraform) ShowStateFile(ctx context.Context, statePath string) (*tfjson.State, error)

ShowStateFile reads a given state file and outputs the state.

func (*Terraform) Version added in v0.4.0

func (tf *Terraform) Version(ctx context.Context, skipCache bool) (tfVersion *version.Version, providerVersions map[string]*version.Version, err error)

Version returns structured output from the terraform version command including both the Terraform CLI version and any initialized provider versions. This will read cached values when present unless the skipCache parameter is set to true.

func (*Terraform) WorkingDir added in v0.5.0

func (tf *Terraform) WorkingDir() string

WorkingDir returns the working directory for Terraform.

func (*Terraform) WorkspaceList added in v0.8.0

func (tf *Terraform) WorkspaceList(ctx context.Context) ([]string, string, error)

WorkspaceList represents the workspace list subcommand to the Terraform CLI.

func (*Terraform) WorkspaceNew added in v0.8.0

func (tf *Terraform) WorkspaceNew(ctx context.Context, workspace string, opts ...WorkspaceNewCmdOption) error

WorkspaceNew represents the workspace new subcommand to the Terraform CLI.

func (*Terraform) WorkspaceSelect added in v0.8.0

func (tf *Terraform) WorkspaceSelect(ctx context.Context, workspace string) error

WorkspaceSelect represents the workspace select subcommand to the Terraform CLI.

type UpgradeOption

type UpgradeOption struct {
	// contains filtered or unexported fields
}

func Upgrade

func Upgrade(upgrade bool) *UpgradeOption

type VarFileOption

type VarFileOption struct {
	// contains filtered or unexported fields
}

func VarFile

func VarFile(path string) *VarFileOption

type VarOption

type VarOption struct {
	// contains filtered or unexported fields
}

func Var

func Var(assignment string) *VarOption

type VerifyPluginsOption

type VerifyPluginsOption struct {
	// contains filtered or unexported fields
}

func VerifyPlugins

func VerifyPlugins(verifyPlugins bool) *VerifyPluginsOption

type WorkspaceNewCmdOption added in v0.8.0

type WorkspaceNewCmdOption interface {
	// contains filtered or unexported methods
}

WorkspaceNewCmdOption represents options that are applicable to the WorkspaceNew method.

Directories

Path Synopsis
internal
e2etest
Package e2etest contains end-to-end acceptance tests for the tfexec package.
Package e2etest contains end-to-end acceptance tests for the tfexec package.

Jump to

Keyboard shortcuts

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