Documentation
¶
Overview ¶
Package runnerconfig renders the YAML a CircleCI self-hosted runner needs to start, for each runner product.
The three products do not share a schema, which is why this package renders three different documents rather than one parameterised template:
- Machine runner 3 reads a circleci-runner-config.yaml, passed to the agent as "circleci-runner machine -c <file>". Keys are snake_case.
- Container runner has no agent config file at all. Its agent is configured by flags and environment variables supplied by the container-agent Helm chart, so the file a user authors is a Helm values.yaml.
- Runner provisioner is likewise Helm-configured, under a different top-level key, and renders its own ConfigMap and Secret from those values.
Output is deterministic: struct field order controls layout and yaml.v3 sorts map keys alphabetically.
Index ¶
Constants ¶
const DefaultWorkingDirectory = "/var/lib/circleci-runner/workdir"
DefaultWorkingDirectory matches the working directory in the packaged agent config that the deb and rpm install to /etc/circleci-runner, so a generated file behaves the same as a package install.
Variables ¶
var Products = []string{string(Machine), string(Container), string(Provisioner)}
Products are the accepted --product values. Machine is first so it is both the flag default and the preselected entry in the interactive prompt.
Functions ¶
func DefaultName ¶
func DefaultName() string
DefaultName derives a runner name from the local hostname, the same source the deb and rpm postinstall scripts use. It returns "" when there is no hostname or nothing survives sanitising, leaving the caller to report that --name is needed.
func SanitizeName ¶
SanitizeName coerces s into something the agent accepts: disallowed characters become "-", the result is truncated to the agent's 64-character limit, and leading and trailing punctuation is dropped. It returns "" if nothing usable is left.
func ValidateName ¶
ValidateName reports whether name is one the agent will start on. It rejects the same values the agent's own validation does, so the failure surfaces here rather than on the runner host.
Types ¶
type Options ¶
type Options struct {
// ResourceClass is the runner resource class, as "namespace/name".
ResourceClass string
// Token is the resource class token the agent authenticates with.
Token string
// Name becomes runner.name. Required for Machine; callers that have no
// explicit name should use DefaultName.
Name string
// WorkingDirectory becomes runner.working_directory. Defaults to
// DefaultWorkingDirectory when empty.
WorkingDirectory string
}
Options is the input to Render. Name and WorkingDirectory apply to Machine only; the Helm products take nothing but the resource class and its token.