Documentation ¶
Index ¶
- Constants
- Variables
- func StringToInterposer(from, to reflect.Type, data any) (any, error)
- type AgentConfig
- func (a *AgentConfig) ApplyToAgentStart(ctr *corev1.Container)
- func (a *AgentConfig) ApplyToCheckout(ctr *corev1.Container)
- func (a *AgentConfig) ApplyToCommand(ctr *corev1.Container)
- func (a *AgentConfig) ApplyVolumesTo(podSpec *corev1.PodSpec)
- func (a *AgentConfig) ControllerOptions() []agentcore.ControllerOption
- type CheckoutParams
- type CommandParams
- type Config
- type GitMirrorsParams
- type Interposer
- type Metadata
- type SidecarParams
Constants ¶
const ( UUIDLabel = "buildkite.com/job-uuid" BuildURLAnnotation = "buildkite.com/build-url" JobURLAnnotation = "buildkite.com/job-url" DefaultNamespace = "default" DefaultStaleJobDataTimeout = 10 * time.Second DefaultImagePullBackOffGracePeriod = 30 * time.Second DefaultJobCancelCheckerPollInterval = 5 * time.Second DefaultEmptyJobGracePeriod = 30 * time.Second DefaultJobCreationConcurrency = 5 )
Variables ¶
var AllowedInterposers = []Interposer{ "", InterposerBuildkite, InterposerVector, InterposerLegacy, }
Accepted values for Interposer.
var DefaultAgentImage = "ghcr.io/buildkite/agent:" + version.Version()
Functions ¶
Types ¶
type AgentConfig ¶
type AgentConfig struct { // Applies to agents within the k8s controller and within the pod Endpoint *string `json:"endpoint,omitempty"` // BUILDKITE_AGENT_ENDPOINT NoHTTP2 *bool `json:"no-http2,omitempty"` // BUILDKITE_NO_HTTP2 // Only applies to agents within the pod Experiments []string `json:"experiment,omitempty"` // BUILDKITE_AGENT_EXPERIMENT Shell *string `json:"shell,omitempty"` // BUILDKITE_SHELL NoColor *bool `json:"no-color,omitempty"` // BUILDKITE_AGENT_NO_COLOR StrictSingleHooks *bool `json:"strict-single-hooks,omitempty"` // BUILDKITE_STRICT_SINGLE_HOOKS NoMultipartArtifactUpload *bool `json:"no-multipart-artifact-upload,omitempty"` // BUILDKITE_NO_MULTIPART_ARTIFACT_UPLOAD TraceContextEncoding *string `json:"trace-context-encoding,omitempty"` // BUILDKITE_TRACE_CONTEXT_ENCODING DisableWarningsFor []string `json:"disable-warnings-for,omitempty"` // BUILDKITE_AGENT_DISABLE_WARNINGS_FOR DebugSigning *bool `json:"debug-signing,omitempty"` // BUILDKITE_AGENT_DEBUG_SIGNING // Applies differently depending on the container // // agent start / bootstrap NoPTY *bool `json:"no-pty,omitempty"` // BUILDKITE_NO_PTY / BUILDKITE_PTY NoCommandEval *bool `json:"no-command-eval,omitempty"` // BUILDKITE_NO_COMMAND_EVAL / BUILDKITE_COMMAND_EVAL NoLocalHooks *bool `json:"no-local-hooks,omitempty"` // BUILDKITE_NO_LOCAL_HOOKS / BUILDKITE_LOCAL_HOOKS_ENABLED NoPlugins *bool `json:"no-plugins,omitempty"` // BUILDKITE_NO_PLUGINS / BUILDKITE_PLUGINS_ENABLED PluginValidation *bool `json:"plugin-validation,omitempty"` // BUILDKITE_NO_PLUGIN_VALIDATION / BUILDKITE_PLUGIN_VALIDATION // Like the above, but signing keys can be supplied directly to the command container. // // agent start / pipeline upload or agent tool sign SigningJWKSFile *string `json:"signing-jwks-file,omitempty"` // BUILDKITE_AGENT_SIGNING_JWKS_FILE / BUILDKITE_AGENT_JWKS_FILE SigningJWKSKeyID *string `json:"signing-jwks-key-id,omitempty"` // BUILDKITE_AGENT_SIGNING_JWKS_KEY_ID / BUILDKITE_AGENT_JWKS_KEY_ID SigningJWKSVolume *corev1.Volume `json:"signingJWKSVolume,omitempty"` // Hooks and plugins can be supplied with a volume source. HooksPath *string `json:"hooks-path,omitempty"` // BUILDKITE_HOOKS_PATH HooksVolume *corev1.Volume `json:"hooksVolume,omitempty"` PluginsPath *string `json:"plugins-path,omitempty"` // BUILDKITE_PLUGINS_PATH PluginsVolume *corev1.Volume `json:"pluginsVolume,omitempty"` // Applies only to the "buildkite-agent start" container. // Keys can be supplied with a volume. VerificationJWKSFile *string `json:"verification-jwks-file,omitempty"` // BUILDKITE_AGENT_VERIFICATION_JWKS_FILE VerificationFailureBehavior *string `json:"verification-failure-behavior,omitempty"` // BUILDKITE_AGENT_JOB_VERIFICATION_NO_SIGNATURE_BEHAVIOR VerificationJWKSVolume *corev1.Volume `json:"verificationJWKSVolume,omitempty"` }
AgentConfig stores shared parameters for things that run buildkite-agent in one form or another. They should correspond to the flags for `buildkite-agent start`. Note that not all agent flags make sense as config options for agents running within a pod.
func (*AgentConfig) ApplyToAgentStart ¶
func (a *AgentConfig) ApplyToAgentStart(ctr *corev1.Container)
ApplyToAgentStart adds env vars assuming ctr is the agent "server" container.
func (*AgentConfig) ApplyToCheckout ¶
func (a *AgentConfig) ApplyToCheckout(ctr *corev1.Container)
ApplyToCheckout adds env vars assuming ctr is a checkout container.
func (*AgentConfig) ApplyToCommand ¶
func (a *AgentConfig) ApplyToCommand(ctr *corev1.Container)
ApplyToCommand adds env vars assuming ctr is a command container.
func (*AgentConfig) ApplyVolumesTo ¶
func (a *AgentConfig) ApplyVolumesTo(podSpec *corev1.PodSpec)
ApplyVolumesTo adds volumes based on the agent config to the podSpec.
func (*AgentConfig) ControllerOptions ¶
func (a *AgentConfig) ControllerOptions() []agentcore.ControllerOption
type CheckoutParams ¶
type CheckoutParams struct { Skip *bool `json:"skip,omitempty"` CleanFlags *string `json:"cleanFlags,omitempty"` CloneFlags *string `json:"cloneFlags,omitempty"` FetchFlags *string `json:"fetchFlags,omitempty"` NoSubmodules *bool `json:"noSubmodules,omitempty"` SubmoduleCloneConfig []string `json:"submoduleCloneConfig,omitempty"` GitMirrors *GitMirrorsParams `json:"gitMirrors,omitempty"` GitCredentialsSecret *corev1.SecretVolumeSource `json:"gitCredentialsSecret,omitempty"` EnvFrom []corev1.EnvFromSource `json:"envFrom,omitempty"` }
CheckoutParams contains parameters that provide additional control over the checkout container.
func (*CheckoutParams) ApplyTo ¶
func (co *CheckoutParams) ApplyTo(podSpec *corev1.PodSpec, ctr *corev1.Container)
func (*CheckoutParams) GitCredsSecret ¶
func (co *CheckoutParams) GitCredsSecret() *corev1.SecretVolumeSource
type CommandParams ¶
type CommandParams struct { Interposer Interposer `json:"interposer,omitempty"` EnvFrom []corev1.EnvFromSource `json:"envFrom,omitempty"` }
CommandParams contains parameters that provide additional control over all command container(s).
func (*CommandParams) ApplyTo ¶
func (cmd *CommandParams) ApplyTo(ctr *corev1.Container)
func (*CommandParams) Command ¶
func (cmd *CommandParams) Command(command, args []string) string
Command interprets the command and args fields of the container into a BUILDKITE_COMMAND value.
type Config ¶
type Config struct { Debug bool `json:"debug"` JobTTL time.Duration `json:"job-ttl"` PollInterval time.Duration `json:"poll-interval"` StaleJobDataTimeout time.Duration `json:"stale-job-data-timeout" validate:"omitempty"` JobCreationConcurrency int `json:"job-creation-concurrency" validate:"omitempty"` AgentTokenSecret string `json:"agent-token-secret" validate:"required"` BuildkiteToken string `json:"buildkite-token" validate:"required"` Image string `json:"image" validate:"required"` MaxInFlight int `json:"max-in-flight" validate:"min=0"` Namespace string `json:"namespace" validate:"required"` Org string `json:"org" validate:"required"` Tags stringSlice `json:"tags" validate:"min=1"` PrometheusPort uint16 `json:"prometheus-port" validate:"omitempty"` ProfilerAddress string `json:"profiler-address" validate:"omitempty,hostname_port"` GraphQLEndpoint string `json:"graphql-endpoint" validate:"omitempty"` // ClusterUUID field is mandatory for most new orgs. // Some old orgs allows unclustered setup. ClusterUUID string `json:"cluster-uuid" validate:"omitempty"` AdditionalRedactedVars stringSlice `json:"additional-redacted-vars" validate:"omitempty"` PodSpecPatch *corev1.PodSpec `json:"pod-spec-patch" validate:"omitempty"` ImagePullBackOffGracePeriod time.Duration `json:"image-pull-backoff-grace-period" validate:"omitempty"` JobCancelCheckerPollInterval time.Duration `json:"job-cancel-checker-poll-interval" validate:"omitempty"` EmptyJobGracePeriod time.Duration `json:"empty-job-grace-period" validate:"omitempty"` // WorkspaceVolume allows supplying a volume for /workspace. By default // an EmptyDir volume is created for it. WorkspaceVolume *corev1.Volume `json:"workspace-volume" validate:"omitempty"` AgentConfig *AgentConfig `json:"agent-config" validate:"omitempty"` DefaultCheckoutParams *CheckoutParams `json:"default-checkout-params" validate:"omitempty"` DefaultCommandParams *CommandParams `json:"default-command-params" validate:"omitempty"` DefaultSidecarParams *SidecarParams `json:"default-sidecar-params" validate:"omitempty"` DefaultMetadata Metadata `json:"default-metadata" validate:"omitempty"` DefaultImagePullPolicy corev1.PullPolicy `json:"default-image-pull-policy" validate:"omitempty"` DefaultImageCheckPullPolicy corev1.PullPolicy `json:"default-image-check-pull-policy" validate:"omitempty"` // ProhibitKubernetesPlugin can be used to prevent alterations to the pod // from the job (the kubernetes "plugin" in pipeline.yml). If enabled, // jobs with a "kubernetes" plugin will fail. ProhibitKubernetesPlugin bool `json:"prohibit-kubernetes-plugin" validate:"omitempty"` }
viper requires mapstructure struct tags, but the k8s types only have json struct tags. mapstructure (the module) supports switching the struct tag to "json", viper does not. So we have to have the `mapstructure` tag for viper and the `json` tag is used by the mapstructure!
func (Config) MarshalLogObject ¶
func (c Config) MarshalLogObject(enc zapcore.ObjectEncoder) error
type GitMirrorsParams ¶
type GitMirrorsParams struct { Path *string `json:"path,omitempty"` Volume *corev1.Volume `json:"volume,omitempty"` CloneFlags *string `json:"cloneFlags,omitempty"` LockTimeout int `json:"lockTimeout,omitempty"` SkipUpdate *bool `json:"skipUpdate,omitempty"` }
GitMirrorsParams configures git mirrors functions of the agent.
type Interposer ¶
type Interposer string
Interposer is a string-flavoured "enum" of command interposers. These configure the conversion from podSpec/command and podSpec/args into BUILDKITE_COMMAND.
const ( // InterposerBuildkite forms BUILDKITE_COMMAND by joining podSpec/command // with newlines, and appends podSpec/args to the last line joined with // spaces and additional shell quoting as needed. // This is intended to mimic how a pipeline.yaml steps/command works: as a // list of one or more commands. But note that: // 1. this is not "correct" as far as Kubernetes would interpret a pod spec // 2. per the pod spec schema, it must be a list. Unlike pipeline.yaml a // single command string (not within a list) is not accepted. // // Example: // // command: // - echo 'hello world' // - ls -halt // - touch // args: // - example file.txt // // becomes: // // BUILDKITE_COMMAND="echo 'hello world'\nls -halt\ntouch 'example file.txt'" InterposerBuildkite Interposer = "buildkite" // InterposerVector forms BUILDKITE_COMMAND by joining podSpec/command // and podSpec/args with spaces, and adds shell quoting around individual // items as needed. // This is intended to mach how Kubernetes interprets command and args: as // a 'vector' specifying a single command. // // Example: // // command: ['echo'] // args: ['hello world'] // // becomes: // // BUILDKITE_COMMAND="echo 'hello world'" InterposerVector Interposer = "vector" // InterposerLegacy forms BUILDKITE_COMMAND by joining podSpec/command // and podSpec/args directly with spaces and no shell quoting. // This interposer should be avoided, but was the old default, and is // provided as an escape hatch for users with pipelines that stop working on // upgrade to the new default (CmdInterposerBuildkite). // // Example: // // command: ['echo'] // args: ['hello world'] // // becomes: // // BUILDKITE_COMMAND="echo hello world" // // (note the lack of quotes around "hello world" in the output). InterposerLegacy Interposer = "legacy" )
Interposer values.
type Metadata ¶
Metadata contains k8s job metadata to apply when creating pods. It can be set as a default within the config, or per step using the kubernetes plugin.
type SidecarParams ¶
type SidecarParams struct {
EnvFrom []corev1.EnvFromSource `json:"envFrom,omitempty"`
}
SidecarParams contains parameters that provide additional control over all sidecar container(s).
func (*SidecarParams) ApplyTo ¶
func (sc *SidecarParams) ApplyTo(ctr *corev1.Container)