Documentation
¶
Overview ¶
Package cigate holds a deploy until the CI checks on a commit conclude.
Index ¶
Constants ¶
const ( EnvTimeout = "APP_CI_GATE_TIMEOUT" EnvPollInterval = "APP_CI_GATE_POLL_INTERVAL" EnvNoChecksWait = "APP_CI_GATE_NO_CHECKS_WAIT" )
Environment variables that tune the gate.
const ( DefaultTimeout = 15 * time.Minute DefaultPollInterval = 15 * time.Second DefaultNoChecksWait = time.Minute )
Defaults used when the environment leaves a value unset or invalid.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Timeout time.Duration
PollInterval time.Duration
NoChecksWait time.Duration
Sleep func(ctx context.Context, d time.Duration) error
Now func() time.Time
}
Config tunes polling. Sleep is replaceable so tests need no real time.
func ConfigFromEnv ¶
func ConfigFromEnv() Config
ConfigFromEnv reads the gate settings, falling back to the defaults.
type GitHub ¶
type GitHub struct {
HTTP *http.Client
BaseURL string
Token string
Owner string
Repo string
Now func() time.Time
}
GitHub reads check runs and commit statuses from the GitHub REST API.
type GitLab ¶
type GitLab struct {
// Client should come from gitlabapp.NewClient so the SSRF guard and timeout apply.
Client *gitlabapp.Client
InstanceURL string
Token string
// ProjectPath is "namespace/project" or "namespace/subgroup/project".
ProjectPath string
// Ref scopes the read to one branch or tag; empty reads every ref on the SHA.
Ref string
}
GitLab reads job and commit statuses from the GitLab REST API. Every read goes to the API for the pushed SHA; a webhook body is never consulted.
type Policy ¶
type Policy struct {
// Required names the checks that must pass; empty means every check seen.
Required []string
// IgnorePrefixes drops checks the platform posts itself, which would deadlock the gate.
IgnorePrefixes []string
}
Policy picks which checks the gate waits for.
type RateLimitError ¶
RateLimitError tells the gate to wait before the next read.
func (*RateLimitError) Error ¶
func (e *RateLimitError) Error() string
type Result ¶
Result carries the verdict and the checks that decided it.
type TerminalError ¶
type TerminalError struct{ Reason string }
TerminalError marks a read failure that retrying cannot fix.
func (*TerminalError) Error ¶
func (e *TerminalError) Error() string