opentofu

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

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_OPENTOFU_MIXIN_USER_AGENT_OPT_OUT"
)
View Source
const (
	// DefaultWorkingDir is the default working directory for Opentofu.
	DefaultWorkingDir = "terraform"

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

	// DefaultInitFile is the default file used to initialize opentofu 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: - opentofu: ... 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"`
	TofuFields  `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 opentofu mixin

func New

func New() *Mixin

New opentofu mixin client, initialized with useful defaults.

func NewFor

func NewFor(cfg runtime.RuntimeConfig) *Mixin

func (*Mixin) Build

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

func (*Mixin) GetMixinUserAgent

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 opentofu init with the provided backendConfig, if supplied

func (*Mixin) Install

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

Install runs a tofu apply

func (*Mixin) Invoke

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

Invoke runs a custom opentofu action

func (*Mixin) PrintSchema

func (m *Mixin) PrintSchema()

func (*Mixin) PrintVersion

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

func (*Mixin) SetUserAgent

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 opentofu destroy

func (*Mixin) Upgrade

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

Upgrade runs a tofu apply, just like Install()

func (*Mixin) Version

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

type MixinConfig

type MixinConfig struct {
	// ClientVersion is the version of the tofu 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 tofu 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 tofu mixin in porter.yaml mixins:

  • opentofu: version: v0.0.0

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:"opentofu"`
}

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

func (s Step) GetWorkingDir() string

type TestMixin

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

func NewTestMixin

func NewTestMixin(t *testing.T) *TestMixin

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

type TofuFields

type TofuFields 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"`
}

TofuFields represent fields specific to tofu

Jump to

Keyboard shortcuts

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