Documentation
¶
Index ¶
- type Applier
- type ApplierInterface
- type ApplyAttempt
- type Filtered
- type Result
- func (r *Result) Duration() float64
- func (r *Result) Filter(filteredBy string) Filtered
- func (r *Result) Finish() time.Time
- func (r *Result) FormattedDuration() string
- func (r *Result) FormattedFinish() string
- func (r *Result) FormattedStart() string
- func (r *Result) LastCommitLink() string
- func (r *Result) Start() time.Time
- func (r *Result) TotalModules() int
- type Runner
- type Scheduler
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) FormattedDuration ¶
FormattedDuration returns the total duration as a string, truncated to 3 decimal places.
func (*Result) FormattedFinish ¶
FormattedFinish returns the Finish time in the format "YYYY-MM-DD hh:mm:ss -0000 GMT"
func (*Result) FormattedStart ¶
FormattedStart returns the Start time in the format "YYYY-MM-DD hh:mm:ss -0000 GMT"
func (*Result) LastCommitLink ¶
LastCommitLink returns a URL for the most recent commit if the envar $DIFF_URL_FORMAT is specified, otherwise it returns empty string.
func (*Result) TotalModules ¶
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.
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.