Documentation ¶
Index ¶
- Constants
- Variables
- func ExtraArgs(extraArgs []string) func(r *TerraRunOpts)
- func FromOpts(opts TerraRunOpts) func(r *TerraRunOpts)
- func Jobs(jobs int) func(r *TerraRunOpts)
- func Output(out io.Writer) func(r *TerraRunOpts)
- func RunApply() func(r *TerraRunOpts)
- func RunBuild() func(r *TerraRunOpts)
- func RunInit() func(r *TerraRunOpts)
- func RunInitUpgrade() func(r *TerraRunOpts)
- func RunPlan() func(r *TerraRunOpts)
- func RunShow() func(r *TerraRunOpts)
- func RunShowPlan() func(r *TerraRunOpts)
- func RunValidate() func(r *TerraRunOpts)
- type Drift
- type OutputLevel
- type RootModule
- type Runner
- func (r *Runner) Errors() error
- func (r *Runner) HasDrift() bool
- func (r *Runner) HasError() bool
- func (r *Runner) Log(level OutputLevel) string
- func (r *Runner) Run(modules []*RootModule)
- func (r *Runner) RunAll()
- func (r *Runner) Runs() []*TerraRun
- func (r *Runner) RunsWithDrift() []*TerraRun
- func (r *Runner) RunsWithError() []*TerraRun
- func (r *Runner) Start(modules []*RootModule)
- func (r *Runner) StartWithOpts(modules []*RootModule, opts TerraRunOpts)
- func (r *Runner) Summary(level OutputLevel) string
- func (r *Runner) Wait()
- func (r *Runner) WorkingDirectory() string
- type TaskResult
- type TerraRun
- func (r *TerraRun) Drift() *Drift
- func (r *TerraRun) Errors() []error
- func (r *TerraRun) HasError() bool
- func (r *TerraRun) HasPlan() bool
- func (r *TerraRun) HasRelevantTasks(level OutputLevel) bool
- func (r *TerraRun) IsApplied() bool
- func (r *TerraRun) IsBuilt() bool
- func (r *TerraRun) IsInitd() bool
- func (r *TerraRun) IsPlanned() bool
- func (r *TerraRun) IsRunning() bool
- func (r *TerraRun) Log(fullLog bool) string
- func (r *TerraRun) ProcessPlan(task *TaskResult) error
- func (r *TerraRun) Run()
- func (r *TerraRun) Start()
- func (r *TerraRun) Summary() string
- func (r *TerraRun) Wait()
- type TerraRunOpts
Constants ¶
const (
DefaultJobs = 4
)
Variables ¶
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 }
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 ¶
Errors returns a multierror with any errors found in any tasks within the runs
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) RunsWithDrift ¶
func (*Runner) RunsWithError ¶
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) WorkingDirectory ¶
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 ¶
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) HasRelevantTasks ¶
func (r *TerraRun) HasRelevantTasks(level OutputLevel) bool
func (*TerraRun) Log ¶
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
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