terraform

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: Apache-2.0 Imports: 27 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// AzureUserAgentEnvVar is the environment variable used by the azure provider to set
	// the user agent string sent to Azure.
	AzureUserAgentEnvVar = "AZURE_HTTP_USER_AGENT"

	// UserAgentOptOutEnvVar is the name of the environment variable that disables
	// user agent reporting.
	UserAgentOptOutEnvVar = "PORTER_TERRAFORM_MIXIN_USER_AGENT_OPT_OUT"
)
View Source
const (
	// DefaultWorkingDir is the default working directory for Terraform.
	DefaultWorkingDir = "terraform"

	// DefaultClientVersion is the default version of the terraform cli.
	DefaultClientVersion = "1.2.9"

	// DefaultInitFile is the default file used to initialize terraform providers during build.
	DefaultInitFile = ""
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Name  string
	Steps []Step // using UnmarshalYAML so that we don't need a custom type per action
}

func (Action) GetSteps

func (a Action) GetSteps() []builder.ExecutableStep

func (Action) MakeSteps

func (a Action) MakeSteps() interface{}

MakeSteps builds a slice of Steps for data to be unmarshaled into.

func (*Action) UnmarshalYAML

func (a *Action) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML takes any yaml in this form ACTION: - terraform: ... and puts the steps into the Action.Steps field

type BuildInput

type BuildInput struct {
	Config *MixinConfig
}

BuildInput represents stdin passed to the mixin for the build command.

type Instruction

type Instruction struct {
	Name            string        `yaml:"name"`
	Description     string        `yaml:"description"`
	Arguments       []string      `yaml:"arguments,omitempty"`
	Flags           builder.Flags `yaml:"flags,omitempty"`
	Outputs         []Output      `yaml:"outputs,omitempty"`
	TerraformFields `yaml:",inline"`
}

type InvokeOptions

type InvokeOptions struct {
	Action string
}

type Mixin

type Mixin struct {
	runtime.RuntimeConfig
	// contains filtered or unexported fields
}

Mixin is the logic behind the terraform mixin

func New

func New() *Mixin

New terraform mixin client, initialized with useful defaults.

func NewFor added in v1.0.1

func NewFor(cfg runtime.RuntimeConfig) *Mixin

func (*Mixin) Build

func (m *Mixin) Build(ctx context.Context) error

func (*Mixin) GetMixinUserAgent added in v1.0.1

func (m *Mixin) GetMixinUserAgent() string

GetMixinUserAgent returns the portion of the user agent string for the mixin.

func (*Mixin) Init

func (m *Mixin) Init(ctx context.Context, backendConfig map[string]interface{}) error

Init runs terraform init with the provided backendConfig, if supplied

func (*Mixin) Install

func (m *Mixin) Install(ctx context.Context) error

Install runs a terraform apply

func (*Mixin) Invoke

func (m *Mixin) Invoke(ctx context.Context, opts InvokeOptions) error

Invoke runs a custom terraform action

func (*Mixin) PrintSchema

func (m *Mixin) PrintSchema()

func (*Mixin) PrintVersion

func (m *Mixin) PrintVersion(opts version.Options) error

func (*Mixin) SetUserAgent added in v1.0.1

func (m *Mixin) SetUserAgent()

SetUserAgent sets the AZURE_HTTP_USER_AGENT environment variable with the full user agent string, which includes both a portion for porter and the mixin.

func (*Mixin) Uninstall

func (m *Mixin) Uninstall(ctx context.Context) error

Uninstall runs a terraform destroy

func (*Mixin) Upgrade

func (m *Mixin) Upgrade(ctx context.Context) error

Upgrade runs a terraform apply, just like Install()

func (*Mixin) Version added in v1.0.1

func (m *Mixin) Version() mixin.Metadata

type MixinConfig

type MixinConfig struct {
	// ClientVersion is the version of the terraform CLI to install
	ClientVersion string `yaml:"clientVersion,omitempty"`

	// UserAgentOptOut allows a bundle author to opt out from adding porter and the mixin's version to the terraform user agent string.
	UserAgentOptOut bool `yaml:"userAgentOptOut,omitempty"`

	InitFile   string `yaml:"initFile,omitempty"`
	WorkingDir string `yaml:"workingDir,omitempty"`
}

MixinConfig represents configuration that can be set on the terraform mixin in porter.yaml mixins:

  • terraform: version: 0.12.17

type Output

type Output struct {
	Name string `yaml:"name"`
	// Write the output to the specified file
	DestinationFile string `yaml:"destinationFile,omitempty"`
}

func (Output) GetName

func (o Output) GetName() string

type Step

type Step struct {
	Instruction `yaml:"terraform"`
}

func (Step) GetArguments

func (s Step) GetArguments() []string

func (Step) GetCommand

func (s Step) GetCommand() string

func (Step) GetDashes

func (s Step) GetDashes() builder.Dashes

func (Step) GetFlags

func (s Step) GetFlags() builder.Flags

func (Step) GetOutputs

func (s Step) GetOutputs() []builder.Output

func (Step) GetWorkingDir added in v0.9.1

func (s Step) GetWorkingDir() string

type TerraformFields

type TerraformFields struct {
	Vars           map[string]interface{} `yaml:"vars,omitempty"`
	DisableVarFile bool                   `yaml:"disableVarFile,omitempty"`
	LogLevel       string                 `yaml:"logLevel,omitempty"`
	BackendConfig  map[string]interface{} `yaml:"backendConfig,omitempty"`
}

TerraformFields represent fields specific to Terraform

type TestMixin

type TestMixin struct {
	*Mixin
	TestContext *portercontext.TestContext
}

func NewTestMixin

func NewTestMixin(t *testing.T) *TestMixin

NewTestMixin initializes a terraform mixin, with the output buffered, and an in-memory file system.

Jump to

Keyboard shortcuts

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