From 351a916647fb31c666214b5be065e8010dce1a75 Mon Sep 17 00:00:00 2001 From: Ben Moskovitz Date: Thu, 2 Mar 2023 19:51:04 +1300 Subject: [PATCH] Rename exec-job -> run-job --- README.md | 2 +- clicommand/agent_start.go | 8 ++--- clicommand/{exec-job.go => run_job.go} | 32 +++++++++---------- job/integration/executor_tester.go | 2 +- job/integration/main_test.go | 6 ++-- main.go | 2 +- .../docker/alpine-k8s/buildkite-agent.cfg | 2 +- packaging/docker/alpine/buildkite-agent.cfg | 2 +- packaging/docker/sidecar/buildkite-agent.cfg | 2 +- .../docker/ubuntu-18.04/buildkite-agent.cfg | 2 +- .../docker/ubuntu-20.04/buildkite-agent.cfg | 2 +- packaging/github/linux/buildkite-agent.cfg | 2 +- packaging/github/windows/buildkite-agent.cfg | 2 +- utils/path_test.go | 4 +-- 14 files changed, 35 insertions(+), 35 deletions(-) rename clicommand/{exec-job.go => run_job.go} (96%) diff --git a/README.md b/README.md index 5286232a76..d566c12e72 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Available commands are: 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 [DEPRECATED] Run a Buildkite job locally - exec-job Run a Buildkite job locally + run-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 6e661840c6..ff0e01f16f 100644 --- a/clicommand/agent_start.go +++ b/clicommand/agent_start.go @@ -55,7 +55,7 @@ Example: // - The AgentStartConfig struct with a cli parameter // - As a flag in the AgentStartCommand (with matching env) // - Into an env to be passed to the job executor in agent/job_runner.go, createEnvironment() -// - Into clicommand/exec-job.go to read it from the env into the job executor config +// - Into clicommand/run_job.go to read it from the env into the job executor config type AgentStartConfig struct { Config string `cli:"config"` @@ -418,13 +418,13 @@ var AgentStartCommand = cli.Command{ cli.StringFlag{ Name: "bootstrap-script", Value: "", - Usage: "[DEPRECATED] 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 run-job sub-command of this binary", EnvVar: "BUILDKITE_BOOTSTRAP_SCRIPT_PATH", }, cli.StringFlag{ Name: "job-executor-script", Value: "", - Usage: "The command that is executed for running a job, defaults to the exec-job sub-command of this binary", + Usage: "The command that is executed for running a job, defaults to the run-job sub-command of this binary", EnvVar: "BUILDKITE_JOB_EXECUTOR_SCRIPT_PATH", }, cli.StringFlag{ @@ -662,7 +662,7 @@ var AgentStartCommand = cli.Command{ if err != nil { l.Fatal("Unable to find our executable path to construct the job executor script: %v", err) } - cfg.JobExecutorScript = fmt.Sprintf("%s exec-job", shellwords.Quote(exePath)) + cfg.JobExecutorScript = fmt.Sprintf("%s run-job", shellwords.Quote(exePath)) } isSetNoPlugins := c.IsSet("no-plugins") diff --git a/clicommand/exec-job.go b/clicommand/run_job.go similarity index 96% rename from clicommand/exec-job.go rename to clicommand/run_job.go index b91d8b885a..5623ce225d 100644 --- a/clicommand/exec-job.go +++ b/clicommand/run_job.go @@ -18,7 +18,7 @@ import ( "github.com/urfave/cli" ) -var execJobHelpTpl = template.Must(template.New("execJobHelp").Parse(`Usage: +var runJobHelpTpl = template.Must(template.New("runJobHelp").Parse(`Usage: buildkite-agent {{.}} [options...] @@ -44,7 +44,7 @@ Example: "https://api.buildkite.com/v2/organizations/[org]/pipelines/[proj]/builds/[build]/jobs/[job]/env.txt" | sed 's/^/export /') $ buildkite-agent {{.}} --build-path builds`)) -type ExecJobConfig struct { +type RunJobConfig struct { Command string `cli:"command"` JobID string `cli:"job" validate:"required"` Repository string `cli:"repository" validate:"required"` @@ -96,7 +96,7 @@ type ExecJobConfig struct { TracingServiceName string `cli:"tracing-service-name"` } -var execJobFlags = []cli.Flag{ +var runJobFlags = []cli.Flag{ cli.StringFlag{ Name: "command", Value: "", @@ -360,9 +360,9 @@ var execJobFlags = []cli.Flag{ ProfileFlag, } -func execJobAction(c *cli.Context) { +func runJobAction(c *cli.Context) { // The configuration will be loaded into this struct - cfg := ExecJobConfig{} + cfg := RunJobConfig{} loader := cliconfig.Loader{CLI: c, Config: &cfg} warnings, err := loader.Load() @@ -518,10 +518,10 @@ func execJobAction(c *cli.Context) { func genBootstrap() cli.Command { var help strings.Builder help.WriteString("⚠️ ⚠️ ⚠️\n") - help.WriteString("DEPRECATED: Use `buildkite-agent exec-job` instead\n") + help.WriteString("DEPRECATED: Use `buildkite-agent run-job` instead\n") help.WriteString("⚠️ ⚠️ ⚠️\n\n") - err := execJobHelpTpl.Execute(&help, "bootstrap") + err := runJobHelpTpl.Execute(&help, "bootstrap") if err != nil { // This can only hapen if we've mangled the template or its parsing // and will be caught by tests and local usage @@ -533,20 +533,20 @@ func genBootstrap() cli.Command { Name: "bootstrap", Usage: "[DEPRECATED] Run a Buildkite job locally", Description: help.String(), - Flags: execJobFlags, + Flags: runJobFlags, 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("Please use `buildkite-agent run-job` instead") fmt.Println("") - execJobAction(c) + runJobAction(c) }, } } -func genExecJob() cli.Command { +func genRunJob() cli.Command { var help strings.Builder - err := execJobHelpTpl.Execute(&help, "exec-job") + err := runJobHelpTpl.Execute(&help, "run-job") if err != nil { // This can only hapen if we've mangled the template or its parsing // and will be caught by tests and local usage @@ -555,15 +555,15 @@ func genExecJob() cli.Command { } return cli.Command{ - Name: "exec-job", + Name: "run-job", Usage: "Run a Buildkite job locally", Description: help.String(), - Flags: execJobFlags, - Action: execJobAction, + Flags: runJobFlags, + Action: runJobAction, } } var ( BootstrapCommand = genBootstrap() - ExecJobCommand = genExecJob() + RunJobCommand = genRunJob() ) diff --git a/job/integration/executor_tester.go b/job/integration/executor_tester.go index 230a550e7b..440efd9509 100644 --- a/job/integration/executor_tester.go +++ b/job/integration/executor_tester.go @@ -76,7 +76,7 @@ func NewExecutorTester() (*ExecutorTester, error) { bt := &ExecutorTester{ Name: os.Args[0], - Args: []string{"exec-job"}, + Args: []string{"run-job"}, Repo: repo, Env: []string{ "HOME=" + homeDir, diff --git a/job/integration/main_test.go b/job/integration/main_test.go index d5fcd86469..8db0ec50f1 100644 --- a/job/integration/main_test.go +++ b/job/integration/main_test.go @@ -13,13 +13,13 @@ import ( ) func TestMain(m *testing.M) { - // If we are passed "exec-job", execute like the exec-job cli - if len(os.Args) > 1 && os.Args[1] == "exec-job" { + // If we are passed "run-job", execute like the run-job cli + if len(os.Args) > 1 && os.Args[1] == "run-job" { app := cli.NewApp() app.Name = "buildkite-agent" app.Version = version.Version() app.Commands = []cli.Command{ - clicommand.ExecJobCommand, + clicommand.RunJobCommand, } if err := app.Run(os.Args); err != nil { diff --git a/main.go b/main.go index 516ae04abe..0c3b1ea8ad 100644 --- a/main.go +++ b/main.go @@ -122,7 +122,7 @@ func main() { }, }, clicommand.BootstrapCommand, - clicommand.ExecJobCommand, + clicommand.RunJobCommand, } app.ErrWriter = os.Stderr diff --git a/packaging/docker/alpine-k8s/buildkite-agent.cfg b/packaging/docker/alpine-k8s/buildkite-agent.cfg index 5073031373..890ed6a690 100644 --- a/packaging/docker/alpine-k8s/buildkite-agent.cfg +++ b/packaging/docker/alpine-k8s/buildkite-agent.cfg @@ -25,7 +25,7 @@ name="%hostname-%spawn" # Include the host's Google Cloud instance labels as tags # tags-from-gcp-labels=true -# Path to a custom job execution command to run. By default this is `buildkite-agent exec-job`. +# Path to a custom job execution command to run. By default this is `buildkite-agent run-job`. # This allows you to override the entire execution of a job. Generally you should use hooks instead! # See https://buildkite.com/docs/agent/hooks # job-executor-script="" diff --git a/packaging/docker/alpine/buildkite-agent.cfg b/packaging/docker/alpine/buildkite-agent.cfg index 5073031373..890ed6a690 100644 --- a/packaging/docker/alpine/buildkite-agent.cfg +++ b/packaging/docker/alpine/buildkite-agent.cfg @@ -25,7 +25,7 @@ name="%hostname-%spawn" # Include the host's Google Cloud instance labels as tags # tags-from-gcp-labels=true -# Path to a custom job execution command to run. By default this is `buildkite-agent exec-job`. +# Path to a custom job execution command to run. By default this is `buildkite-agent run-job`. # This allows you to override the entire execution of a job. Generally you should use hooks instead! # See https://buildkite.com/docs/agent/hooks # job-executor-script="" diff --git a/packaging/docker/sidecar/buildkite-agent.cfg b/packaging/docker/sidecar/buildkite-agent.cfg index 5073031373..890ed6a690 100644 --- a/packaging/docker/sidecar/buildkite-agent.cfg +++ b/packaging/docker/sidecar/buildkite-agent.cfg @@ -25,7 +25,7 @@ name="%hostname-%spawn" # Include the host's Google Cloud instance labels as tags # tags-from-gcp-labels=true -# Path to a custom job execution command to run. By default this is `buildkite-agent exec-job`. +# Path to a custom job execution command to run. By default this is `buildkite-agent run-job`. # This allows you to override the entire execution of a job. Generally you should use hooks instead! # See https://buildkite.com/docs/agent/hooks # job-executor-script="" diff --git a/packaging/docker/ubuntu-18.04/buildkite-agent.cfg b/packaging/docker/ubuntu-18.04/buildkite-agent.cfg index 5073031373..890ed6a690 100644 --- a/packaging/docker/ubuntu-18.04/buildkite-agent.cfg +++ b/packaging/docker/ubuntu-18.04/buildkite-agent.cfg @@ -25,7 +25,7 @@ name="%hostname-%spawn" # Include the host's Google Cloud instance labels as tags # tags-from-gcp-labels=true -# Path to a custom job execution command to run. By default this is `buildkite-agent exec-job`. +# Path to a custom job execution command to run. By default this is `buildkite-agent run-job`. # This allows you to override the entire execution of a job. Generally you should use hooks instead! # See https://buildkite.com/docs/agent/hooks # job-executor-script="" diff --git a/packaging/docker/ubuntu-20.04/buildkite-agent.cfg b/packaging/docker/ubuntu-20.04/buildkite-agent.cfg index 5073031373..890ed6a690 100644 --- a/packaging/docker/ubuntu-20.04/buildkite-agent.cfg +++ b/packaging/docker/ubuntu-20.04/buildkite-agent.cfg @@ -25,7 +25,7 @@ name="%hostname-%spawn" # Include the host's Google Cloud instance labels as tags # tags-from-gcp-labels=true -# Path to a custom job execution command to run. By default this is `buildkite-agent exec-job`. +# Path to a custom job execution command to run. By default this is `buildkite-agent run-job`. # This allows you to override the entire execution of a job. Generally you should use hooks instead! # See https://buildkite.com/docs/agent/hooks # job-executor-script="" diff --git a/packaging/github/linux/buildkite-agent.cfg b/packaging/github/linux/buildkite-agent.cfg index 88d0baec6b..3de9a212df 100644 --- a/packaging/github/linux/buildkite-agent.cfg +++ b/packaging/github/linux/buildkite-agent.cfg @@ -25,7 +25,7 @@ name="%hostname-%spawn" # Include the host's Google Cloud instance labels as tags # tags-from-gcp-labels=true -# Path to a custom job execution command to run. By default this is `buildkite-agent exec-job`. +# Path to a custom job execution command to run. By default this is `buildkite-agent run-job`. # This allows you to override the entire execution of a job. Generally you should use hooks instead! # See https://buildkite.com/docs/agent/hooks # job-executor-script="" diff --git a/packaging/github/windows/buildkite-agent.cfg b/packaging/github/windows/buildkite-agent.cfg index 20c4c7ba6a..23ae62bc64 100644 --- a/packaging/github/windows/buildkite-agent.cfg +++ b/packaging/github/windows/buildkite-agent.cfg @@ -13,7 +13,7 @@ name="%hostname-%spawn" # Tags for the agent (default is "queue=default") # tags="key1=val2,key2=val2" -# Path to a custom job execution command to run. By default this is `buildkite-agent exec-job`. +# Path to a custom job execution command to run. By default this is `buildkite-agent run-job`. # This allows you to override the entire execution of a job. Generally you should use hooks instead! # See https://buildkite.com/docs/agent/hooks # job-executor-script="" diff --git a/utils/path_test.go b/utils/path_test.go index ddf45fab66..f0fac2b89f 100644 --- a/utils/path_test.go +++ b/utils/path_test.go @@ -47,9 +47,9 @@ func TestNormalizingCommands(t *testing.T) { usr, err := user.Current() assert.NoError(t, err) - c, err := NormalizeCommand(filepath.Join("~/", "buildkite-agent", "exec-job")) + c, err := NormalizeCommand(filepath.Join("~/", "buildkite-agent", "run-job")) assert.NoError(t, err) - assert.Equal(t, filepath.Join(usr.HomeDir, "buildkite-agent", "exec-job"), c) + assert.Equal(t, filepath.Join(usr.HomeDir, "buildkite-agent", "run-job"), c) c, err = NormalizeCommand("cat test.log") assert.NoError(t, err)