Documentation
¶
Overview ¶
Package runnerproto is the wire protocol between ward and a check runner: the lease that carries a check request, the result that a runner posts and the tokens that authorize both. ward, `ward runner` and a runner of another author share this definition. runner.schema.json describes the JSON bodies.
Index ¶
- Constants
- func MintCheckToken(kid string, key ed25519.PrivateKey, repo, subject string, exp time.Time) (string, error)
- func MintRunnerToken(kid string, key ed25519.PrivateKey, subject string, exp time.Time) (string, error)
- func PostResult(ctx context.Context, c *http.Client, baseURL, tok string, res Result) error
- func RenewPath(leaseID string) string
- type Check
- type Isolation
- type Lease
- type LeaseRequest
- type Renewal
- type Request
- type Result
- type Status
- type StatusError
Constants ¶
const ( // LeasesPath is the route that a pull runner polls for a lease. The bearer credential is a runner token. LeasesPath = "/v1/runner/leases" // LeaseWait is the longest time that ward holds a poll open before it answers 204. LeaseWait = 20 * time.Second )
const ( // ResultsPath is the route of ward that takes a result, with a check token as the bearer credential. ResultsPath = "/v1/results" MaxSummary = 4096 MaxLogURL = 2048 )
Variables ¶
This section is empty.
Functions ¶
func MintCheckToken ¶
func MintCheckToken(kid string, key ed25519.PrivateKey, repo, subject string, exp time.Time) (string, error)
MintCheckToken signs a check token for repo. A runner sends it as the bearer credential of PostResult.
func MintRunnerToken ¶
func MintRunnerToken(kid string, key ed25519.PrivateKey, subject string, exp time.Time) (string, error)
MintRunnerToken signs a runner token. A pull runner sends it as the bearer credential of a poll and of a renewal.
func PostResult ¶
PostResult posts res to the ward at baseURL with a check token.
Types ¶
type Check ¶
type Check struct {
Name string `json:"name"`
Run []string `json:"run"`
TimeoutSeconds int `json:"timeout_seconds"`
}
Check is one required check. The runner runs Run at the root of the tree.
type Isolation ¶
type Isolation string
Isolation is the strength of the sandbox that a runner reports. A larger rank isolates more.
type Lease ¶
type Lease struct {
LeaseID string `json:"lease_id"`
TTLSeconds int `json:"ttl_seconds"`
Request Request `json:"request"`
}
Lease is the answer to a poll: one check request that the runner holds for TTLSeconds, and renews until it posts a result.
type LeaseRequest ¶
type LeaseRequest struct {
Isolation Isolation `json:"isolation"`
}
LeaseRequest is the body of a poll. Isolation is the sandbox that the runner uses for every check.
type Renewal ¶
type Renewal struct {
TTLSeconds int `json:"ttl_seconds"`
}
Renewal is the answer to a renewal.
type Request ¶
type Request struct {
RequestID string `json:"request_id"`
Repo string `json:"repo"`
Tree string `json:"tree"`
Commit string `json:"commit"`
Check Check `json:"check"`
CheckHash string `json:"check_hash"`
Env string `json:"env"`
}
Request is the check request that a lease carries. Commit is a commit of motte whose tree is Tree.
type Result ¶
type Result struct {
RequestID string `json:"request_id"`
Status Status `json:"status"`
Summary string `json:"summary"`
LogURL string `json:"log_url"`
}
Result is the body that a runner posts to ResultsPath.
type StatusError ¶
type StatusError struct{ Code int }
StatusError is a refusal of ward. A 4xx code other than 429 is final: the runner must not repeat the post.
func (*StatusError) Error ¶
func (e *StatusError) Error() string
func (*StatusError) Final ¶
func (e *StatusError) Final() bool
Final reports whether the post cannot succeed on a repeat.