runner

package
v0.0.0-...-d8ef078 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultJobs = 4
)

Variables

View Source
var (
	ErrRunInProgress = errors.New("run is already in progress")
	ErrRunSkipped    = errors.New("cannot run skipped module")
)

Functions

func ExtraArgs

func ExtraArgs(extraArgs []string) func(r *TerraRunOpts)

func FromOpts

func FromOpts(opts TerraRunOpts) func(r *TerraRunOpts)

func Jobs

func Jobs(jobs int) func(r *TerraRunOpts)

func Output

func Output(out io.Writer) func(r *TerraRunOpts)

func RunApply

func RunApply() func(r *TerraRunOpts)

func RunBuild

func RunBuild() func(r *TerraRunOpts)

func RunInit

func RunInit() func(r *TerraRunOpts)

func RunInitUpgrade

func RunInitUpgrade() func(r *TerraRunOpts)

func RunPlan

func RunPlan() func(r *TerraRunOpts)

func RunShow

func RunShow() func(r *TerraRunOpts)

func RunShowPlan

func RunShowPlan() func(r *TerraRunOpts)

func RunValidate

func RunValidate() func(r *TerraRunOpts)

Types

type Drift

type Drift struct {
	AddResources     []*tfjson.ResourceChange
	ChangeResources  []*tfjson.ResourceChange
	DestroyResources []*tfjson.ResourceChange
}

func (*Drift) Diff

func (d *Drift) Diff() string

func (*Drift) HasDrift

func (d *Drift) HasDrift() bool

type OutputLevel

type OutputLevel string
const (
	OutputLevelAll   OutputLevel = "all"
	OutputLevelDrift OutputLevel = "drift"
)

func (OutputLevel) ShowAll

func (o OutputLevel) ShowAll() bool

func (OutputLevel) ShowDrift

func (o OutputLevel) ShowDrift() bool

func (OutputLevel) ShowError

func (o OutputLevel) ShowError() bool

func (OutputLevel) Validate

func (o OutputLevel) Validate() (OutputLevel, error)

type RootModule

type RootModule struct {
	// Terrafile is the terrafile for which this run was executed
	Terrafile *parser.Terrafile
	Opts      TerraRunOpts

	// Run stores the current run, if one has been scheduled
	Run *TerraRun
	// contains filtered or unexported fields
}

func (*RootModule) HasRun

func (r *RootModule) HasRun() bool

func (*RootModule) IsRunning

func (r *RootModule) IsRunning() bool

func (*RootModule) ScheduleRun

func (r *RootModule) ScheduleRun(runQueue chan *TerraRun) error

ScheduleRun schedules a run on the RootModule by setting the state and adding to the waitgroup. If a run is already in progress an error is returned and the state is unchanged

func (*RootModule) ScheduleRunWithOpts

func (r *RootModule) ScheduleRunWithOpts(runQueue chan *TerraRun, opts TerraRunOpts) error

ScheduleRun schedules a run on the RootModule by setting the state and adding to the waitgroup. If a run is already in progress an error is returned and the state is unchanged

func (*RootModule) Skip

func (r *RootModule) Skip() bool

func (*RootModule) Wait

func (r *RootModule) Wait()

type Runner

type Runner struct {
	Opts    TerraRunOpts
	Modules []*RootModule
	// contains filtered or unexported fields
}

func New

func New(config *parser.TerraConfig, opts ...func(r *TerraRunOpts)) *Runner

func Run

func Run(config *parser.TerraConfig, opts ...func(r *TerraRunOpts)) *Runner

func (*Runner) Errors

func (r *Runner) Errors() error

Errors returns a multierror with any errors found in any tasks within the runs

func (*Runner) HasDrift

func (r *Runner) HasDrift() bool

HasDrift returns true if any drift was detected in any of the runs

func (*Runner) HasError

func (r *Runner) HasError() bool

func (*Runner) Log

func (r *Runner) Log(level OutputLevel) string

Log returns a string of the runs and tasks to print to the console

func (*Runner) Run

func (r *Runner) Run(modules []*RootModule)

func (*Runner) RunAll

func (r *Runner) RunAll()

func (*Runner) Runs

func (r *Runner) Runs() []*TerraRun

Runs returns the list of latest runs for the root modules

func (*Runner) RunsWithDrift

func (r *Runner) RunsWithDrift() []*TerraRun

func (*Runner) RunsWithError

func (r *Runner) RunsWithError() []*TerraRun

func (*Runner) Start

func (r *Runner) Start(modules []*RootModule)

func (*Runner) StartWithOpts

func (r *Runner) StartWithOpts(modules []*RootModule, opts TerraRunOpts)

func (*Runner) Summary

func (r *Runner) Summary(level OutputLevel) string

Summary returns a string summary to show after a plan

func (*Runner) Wait

func (r *Runner) Wait()

func (*Runner) WorkingDirectory

func (r *Runner) WorkingDirectory() string

type TaskResult

type TaskResult struct {
	ExecCmd  *exec.Cmd
	TerraCmd terraCmd

	Output  bytes.Buffer
	Error   error
	Skipped bool
}

func (*TaskResult) HasError

func (t *TaskResult) HasError() bool

func (*TaskResult) Log

func (t *TaskResult) Log() string

type TerraRun

type TerraRun struct {
	// Terrafile is the terrafile for which this run was executed
	Terrafile *parser.Terrafile
	Opts      TerraRunOpts

	Tasks     []*TaskResult
	Cancelled bool

	Plan     *tfjson.Plan
	PlanText []byte
	// contains filtered or unexported fields
}

func (*TerraRun) Drift

func (r *TerraRun) Drift() *Drift

Drift returns the drift from a Terraform Run. To avoid re-calculating it multiple times, store the drift in a local member and only calculate it once

func (*TerraRun) Errors

func (r *TerraRun) Errors() []error

func (*TerraRun) HasError

func (r *TerraRun) HasError() bool

func (*TerraRun) HasPlan

func (r *TerraRun) HasPlan() bool

func (*TerraRun) HasRelevantTasks

func (r *TerraRun) HasRelevantTasks(level OutputLevel) bool

func (*TerraRun) IsApplied

func (r *TerraRun) IsApplied() bool

func (*TerraRun) IsBuilt

func (r *TerraRun) IsBuilt() bool

func (*TerraRun) IsInitd

func (r *TerraRun) IsInitd() bool

func (*TerraRun) IsPlanned

func (r *TerraRun) IsPlanned() bool

func (*TerraRun) IsRunning

func (r *TerraRun) IsRunning() bool

func (*TerraRun) Log

func (r *TerraRun) Log(fullLog bool) string

Log returns the log output of a TerraRun as a string. Tasks are logged either if the fullLog parameter is true or if the task is considered relevant

func (*TerraRun) ProcessPlan

func (r *TerraRun) ProcessPlan(task *TaskResult) error

ProcessPlanText takes a TaskResult from a terraform show (with -json option) which makes for a compact human-readable output which we can show instead of the raw output from terraform plan

func (*TerraRun) Run

func (r *TerraRun) Run()

Run performs a blocking run for this TerraRun i.e. invoking Terraform

func (*TerraRun) Start

func (r *TerraRun) Start()

Start performs a non-blocking run for this TerraRun i.e. invoking Terraform

func (*TerraRun) Summary

func (r *TerraRun) Summary() string

Summary returns a string summary to show after a plan

func (*TerraRun) Wait

func (r *TerraRun) Wait()

Wait blocks and waits for the run to be finished

type TerraRunOpts

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

TerraRunOpts handles running Terraform over the root modules

func NewOpts

func NewOpts(opts ...func(r *TerraRunOpts)) TerraRunOpts

Jump to

Keyboard shortcuts

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