goterraform

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: LGPL-3.0 Imports: 8 Imported by: 0

README

go-terraform

Library to encapsulate the terraform utility to be called as a golang library

Why does this exist?

Between the unreliability of the internal interfaces in the terraform library and then need to communicate with providers, we'll wrap the terraform command in bash, rather than importing the github.com/hashicorp/terraform library and calling methods directly. See https://github.com/hashicorp/terraform/issues/12582 for more info.

Documentation

Index

Constants

View Source
const (
	STDERR = "stderr"
	STDOUT = "stdout"
)

Variables

This section is empty.

Functions

func BoolPtr

func BoolPtr(a bool) *bool

func FalsePtr

func FalsePtr() *bool

func IntPtr

func IntPtr(a int) *int

func StringMapPtr

func StringMapPtr(a map[string]string) *map[string]string

func StringPtr

func StringPtr(a string) *string

func StringSlice

func StringSlice(a []*string) (o []string)

func TruePtr

func TruePtr() *bool

Types

type OutputLog

type OutputLog struct {
	Entries []*OutputLogEntry `json:"entries"`
}

func NewOutputLogs

func NewOutputLogs() *OutputLog

func (*OutputLog) Append

func (ol *OutputLog) Append(ole *OutputLogEntry) *OutputLogEntry

func (*OutputLog) Error

func (ol *OutputLog) Error(err error) *OutputLogEntry

func (*OutputLog) Stderr

func (ol *OutputLog) Stderr(message string) *OutputLogEntry

func (*OutputLog) StderrWithTags

func (ol *OutputLog) StderrWithTags(message string, tags []string) *OutputLogEntry

func (*OutputLog) Stdout

func (ol *OutputLog) Stdout(message string) *OutputLogEntry

func (*OutputLog) StdoutWithTags

func (ol *OutputLog) StdoutWithTags(message string, tags []string) *OutputLogEntry

func (*OutputLog) String

func (ol *OutputLog) String() (output string)

type OutputLogEntry

type OutputLogEntry struct {
	Type    string   `json:"type"`
	Content string   `json:"content"`
	Tags    []string `json:"prefix"`
}

func (*OutputLogEntry) String

func (ole *OutputLogEntry) String() string

type TerraformAction

type TerraformAction struct {
	Cmd *exec.Cmd
	Dir string
	// contains filtered or unexported fields
}

func (*TerraformAction) InitLogger

func (a *TerraformAction) InitLogger(log *OutputLog) (err error)

func (*TerraformAction) Initialise

func (a *TerraformAction) Initialise() *TerraformAction

func (*TerraformAction) Run

func (a *TerraformAction) Run() (err error)

Run the terraform command

type TerraformActionParams

type TerraformActionParams interface {
	Opts() map[string][]string
	OptsString() string
	OptsStringSlice() []string
}

type TerraformCli

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

func NewTerraformClient

func NewTerraformClient() *TerraformCli

NewTerraformClient return a struct which behaves like the cli terraform client.

Between the unreliability of the internal interfaces in the terraform library and then need to communicate with providers, we'll wrap the terraform command in bash, rather than importing the `github.com/hashicorp/terraform` library and calling methods directly. See https://github.com/hashicorp/terraform/issues/12582 for more info.

func NewTerraformClientWithBinPath

func NewTerraformClientWithBinPath(binPath string) *TerraformCli

func (*TerraformCli) Apply

func (t *TerraformCli) Apply() *TerraformAction

func (*TerraformCli) Get

func (*TerraformCli) Init

func (*TerraformCli) Plan

func (*TerraformCli) WithWorkingDirectory

func (client *TerraformCli) WithWorkingDirectory(workingDirectory string) *TerraformCli

type TerraformGetParams

type TerraformGetParams struct {
	Directory string
}

func (TerraformGetParams) Opts

func (t TerraformGetParams) Opts() map[string][]string

func (TerraformGetParams) OptsString

func (t TerraformGetParams) OptsString() string

func (TerraformGetParams) OptsStringSlice

func (t TerraformGetParams) OptsStringSlice() []string

type TerraformInitParams

type TerraformInitParams struct {
	Backend       *bool
	BackendConfig string
	ForceCopy     bool
	FromModule    string
	Get           *bool
	GetPlugins    *bool

	Input       *bool
	Lock        *bool
	LockTimeout int
	NoColor     bool

	PluginDir     string
	Reconfigure   bool
	Upgrade       *bool
	VerifyPlugins *bool
}

func NewTerraformInitParams

func NewTerraformInitParams() *TerraformInitParams

func (*TerraformInitParams) Opts

func (p *TerraformInitParams) Opts() map[string][]string

func (*TerraformInitParams) OptsString

func (p *TerraformInitParams) OptsString() string

func (*TerraformInitParams) OptsStringSlice

func (p *TerraformInitParams) OptsStringSlice() []string

type TerraformOutput

type TerraformOutput struct {
	Stderr io.ReadCloser
	Stdout io.ReadCloser
}

type TerraformPlanParams

type TerraformPlanParams struct {
	Destroy          bool
	DetailedExitcode bool

	Input       *bool
	Lock        *bool
	LockTimeout int
	NoColor     bool

	ModuleDepth *int
	Out         *string
	Parallelism *int
	Refresh     *bool
	State       *string
	Target      []*string
	Var         map[string]string
	VarFile     []*string
}

func NewTerraformPlanParams

func NewTerraformPlanParams() *TerraformPlanParams

func (*TerraformPlanParams) Opts

func (p *TerraformPlanParams) Opts() map[string][]string

func (*TerraformPlanParams) OptsString

func (p *TerraformPlanParams) OptsString() string

func (*TerraformPlanParams) OptsStringSlice

func (p *TerraformPlanParams) OptsStringSlice() []string

Jump to

Keyboard shortcuts

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