Skip to content

Commit

Permalink
Don't override existing env
Browse files Browse the repository at this point in the history
This would interfere with how the k8s stack operates. See comment.
  • Loading branch information
DrJosh9000 committed Jun 26, 2024
1 parent bb2c945 commit b166629
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions clicommand/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,20 @@ var BootstrapCommand = cli.Command{
if err != nil {
return fmt.Errorf("error connecting to kubernetes runner: %w", err)
}

// Set our environment vars based on the registration response.
// But note that the k8s stack interprets the job definition itself,
// and sets a variety of env vars (e.g. BUILDKITE_COMMAND) that
// *could* be different to the ones the agent normally supplies.
// A prime example is: the command container could be passed a
// specific BUILDKITE_COMMAND that is computed from the command+args
// podSpec attributes (in the kubernetes "plugin"), instead of the
// "command" attribute of the step.
// So we should skip setting any vars that are already set.
for n, v := range env.FromSlice(regResp.Env).Dump() {
if _, set := os.LookupEnv(n); set {
continue
}
if err := os.Setenv(n, v); err != nil {
return err
}
Expand Down

0 comments on commit b166629

Please sign in to comment.