From 400a0a87234a57cb439d66338394a051b63fe73e Mon Sep 17 00:00:00 2001 From: Ben Moskovitz Date: Mon, 27 Feb 2023 11:09:37 +1300 Subject: [PATCH] Deprecate existing bootstrap command --- README.md | 3 ++- clicommand/agent_start.go | 4 ++-- clicommand/exec-job.go | 35 ++++++++++++++++++------------ job/integration/executor_tester.go | 2 +- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 931e72a04e..5286232a76 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,8 @@ Available commands are: meta-data Get/set data from Buildkite jobs pipeline Make changes to the pipeline of the currently running build step Make changes to a step (this includes any jobs that were created from the step) - bootstrap Run a Buildkite job locally + bootstrap [DEPRECATED] Run a Buildkite job locally + exec-job Run a Buildkite job locally help Shows a list of commands or help for one command Use "buildkite-agent --help" for more information about a command. diff --git a/clicommand/agent_start.go b/clicommand/agent_start.go index 6832f3f4af..6e661840c6 100644 --- a/clicommand/agent_start.go +++ b/clicommand/agent_start.go @@ -418,7 +418,7 @@ var AgentStartCommand = cli.Command{ cli.StringFlag{ Name: "bootstrap-script", Value: "", - Usage: "The command that is executed for bootstrapping a job, defaults to the exec-job sub-command of this binary", + Usage: "[DEPRECATED] The command that is executed for bootstrapping a job, defaults to the exec-job sub-command of this binary", EnvVar: "BUILDKITE_BOOTSTRAP_SCRIPT_PATH", }, cli.StringFlag{ @@ -656,7 +656,7 @@ var AgentStartCommand = cli.Command{ cfg.NoPTY = true } - // Set a useful default for the bootstrap script + // Set a useful default for the job exec script if cfg.JobExecutorScript == "" { exePath, err := os.Executable() if err != nil { diff --git a/clicommand/exec-job.go b/clicommand/exec-job.go index 2b667ba46a..b91d8b885a 100644 --- a/clicommand/exec-job.go +++ b/clicommand/exec-job.go @@ -87,7 +87,8 @@ type ExecJobConfig struct { Debug bool `cli:"debug"` Shell string `cli:"shell"` Experiments []string `cli:"experiment" normalize:"list"` - Phases []string `cli:"phases" normalize:"list"` + Phases []string `cli:"phases" normalize:"list" deprecated-and-renamed-to:"exec-phases"` + ExecPhases []string `cli:"exec-phases" normalize:"list"` Profile string `cli:"profile"` CancelSignal string `cli:"cancel-signal"` RedactedVars []string `cli:"redacted-vars" normalize:"list"` @@ -322,6 +323,11 @@ var execJobFlags = []cli.Flag{ }, cli.StringSliceFlag{ Name: "phases", + Usage: "[DEPRECATED] The specific phases to execute. The order they're defined is irrelevant.", + EnvVar: "BUILDKITE_BOOTSTRAP_PHASES", + }, + cli.StringSliceFlag{ + Name: "exec-phases", Usage: "The specific phases to execute. The order they're defined is irrelevant.", EnvVar: "BUILDKITE_BOOTSTRAP_PHASES", }, @@ -509,16 +515,12 @@ func execJobAction(c *cli.Context) { os.Exit(exitCode) } -var ( - BootstrapCommand = genBootstrap() - ExecJobCommand = genExecJob() -) - func genBootstrap() cli.Command { var help strings.Builder help.WriteString("⚠️ ⚠️ ⚠️\n") help.WriteString("DEPRECATED: Use `buildkite-agent exec-job` instead\n") help.WriteString("⚠️ ⚠️ ⚠️\n\n") + err := execJobHelpTpl.Execute(&help, "bootstrap") if err != nil { // This can only hapen if we've mangled the template or its parsing @@ -532,7 +534,13 @@ func genBootstrap() cli.Command { Usage: "[DEPRECATED] Run a Buildkite job locally", Description: help.String(), Flags: execJobFlags, - Action: execJobAction, + Action: func(c *cli.Context) { + fmt.Println("⚠️ WARNING ⚠️") + fmt.Println("This command (`buildkite-agent bootstrap`) is deprecated and will be removed in a future release") + fmt.Println("Please use `buildkite-agent exec-job` instead") + fmt.Println("") + execJobAction(c) + }, } } @@ -551,12 +559,11 @@ func genExecJob() cli.Command { Usage: "Run a Buildkite job locally", Description: help.String(), Flags: execJobFlags, - Action: func(c *cli.Context) { - fmt.Println("⚠️ WARNING ⚠️") - fmt.Println("This command (`buildkite-agent bootstrap`) is deprecated and will be removed in a future release") - fmt.Println("Please use `buildkite-agent exec-job` instead.") - fmt.Println("") - execJobAction(c) - }, + Action: execJobAction, } } + +var ( + BootstrapCommand = genBootstrap() + ExecJobCommand = genExecJob() +) diff --git a/job/integration/executor_tester.go b/job/integration/executor_tester.go index 0440653406..230a550e7b 100644 --- a/job/integration/executor_tester.go +++ b/job/integration/executor_tester.go @@ -263,7 +263,7 @@ func (b *ExecutorTester) Run(t *testing.T, env ...string) error { buf := &buffer{} - if os.Getenv("DEBUG_BOOTSTRAP") == "1" { + if os.Getenv("DEBUG_JOB_EXEC") == "1" { w := newTestLogWriter(t) b.cmd.Stdout = io.MultiWriter(buf, w) b.cmd.Stderr = io.MultiWriter(buf, w)