run

package
v1.0.0 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: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Applier

type Applier struct {
	Clock             sysutil.ClockInterface
	DryRun            bool
	Errors            chan<- error
	Metrics           metrics.PrometheusInterface
	TerraformExecPath string
}

Applier inits, plans and applies terraform modules

func (*Applier) Apply

func (a *Applier) Apply(modulesPath string, modules []string) ([]ApplyAttempt, []ApplyAttempt)

Apply runs terraform for each of the modules and reports the successes and failures

type ApplierInterface

type ApplierInterface interface {
	Apply(string, []string) ([]ApplyAttempt, []ApplyAttempt)
}

ApplierInterface allows for mocking out the functionality of Applier when testing the full process of an apply run.

type ApplyAttempt

type ApplyAttempt struct {
	DryRun bool
	Finish time.Time
	Output string
	Module string
	Start  time.Time
}

ApplyAttempt stores the data from an attempt at applying a single module

func (*ApplyAttempt) Duration

func (a *ApplyAttempt) Duration() float64

Duration returns the duration of the module run in seconds

func (*ApplyAttempt) FormattedDuration

func (a *ApplyAttempt) FormattedDuration() string

FormattedDuration returns the duration of the module run in seconds, truncated to 3 decimal places.

func (*ApplyAttempt) FormattedFinish

func (a *ApplyAttempt) FormattedFinish() string

FormattedFinish returns the Finish time in the format "YYYY-MM-DD hh:mm:ss -0000 GMT"

func (*ApplyAttempt) FormattedStart

func (a *ApplyAttempt) FormattedStart() string

FormattedStart returns the Start time in the format "YYYY-MM-DD hh:mm:ss -0000 GMT"

type Filtered added in v0.5.5

type Filtered struct {
	FilteredBy string
	Total      int
	Modules    []ApplyAttempt
}

type Result

type Result struct {
	Successes     []ApplyAttempt
	Failures      []ApplyAttempt
	CommitHash    string
	FullCommit    string
	DiffURLFormat string
}

Result stores the data from a single run of the apply loop. The functions associated with Result convert raw data into the desired formats for insertion into the status page template.

func (*Result) Duration

func (r *Result) Duration() float64

Duration returns the total duration for all the modules summed in seconds

func (*Result) Filter added in v0.5.5

func (r *Result) Filter(filteredBy string) Filtered

func (*Result) Finish

func (r *Result) Finish() time.Time

Finish returns the finish time for the last apply attempt

func (*Result) FormattedDuration

func (r *Result) FormattedDuration() string

FormattedDuration returns the total duration as a string, truncated to 3 decimal places.

func (*Result) FormattedFinish

func (r *Result) FormattedFinish() string

FormattedFinish returns the Finish time in the format "YYYY-MM-DD hh:mm:ss -0000 GMT"

func (*Result) FormattedStart

func (r *Result) FormattedStart() string

FormattedStart returns the Start time in the format "YYYY-MM-DD hh:mm:ss -0000 GMT"

func (r *Result) LastCommitLink() string

LastCommitLink returns a URL for the most recent commit if the envar $DIFF_URL_FORMAT is specified, otherwise it returns empty string.

func (*Result) Start

func (r *Result) Start() time.Time

Start returns the start time for the first apply attempt

func (*Result) TotalModules

func (r *Result) TotalModules() int

TotalModules returns the total count of apply attempts, both successes and failures.

type Runner

type Runner struct {
	Applier            ApplierInterface
	Clock              sysutil.ClockInterface
	DiffURLFormat      string
	Errors             chan<- error
	GitUtil            git.UtilInterface
	Metrics            metrics.PrometheusInterface
	ModulesPath        string
	ModulesPathFilters []string
	RunResults         chan<- Result
	RunQueue           <-chan bool
	// contains filtered or unexported fields
}

Runner manages the full process of an apply run, including getting the appropriate files, running apply commands on them, and handling the results.

func (*Runner) Applying

func (r *Runner) Applying() bool

func (*Runner) Start

func (r *Runner) Start()

Start runs a continuous loop that starts a new run when a request comes into the queue channel.

type Scheduler

type Scheduler struct {
	Errors             chan<- error
	FullRunInterval    time.Duration
	GitUtil            git.UtilInterface
	PollInterval       time.Duration
	ModulesPathFilters []string
	RunQueue           chan<- bool
}

Scheduler handles queueing apply runs at a given time interval and upon every new Git commit.

func (*Scheduler) Start

func (s *Scheduler) Start()

Start runs a continuous loop with two tickers for queueing runs. One ticker queues a new run every X seconds, where X is the value from $FULL_RUN_INTERVAL_SECONDS. The other ticker queues a new run upon every new Git commit, checking the repo every Y seconds where Y is the value from $POLL_INTERVAL_SECONDS.

Jump to

Keyboard shortcuts

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