Skip to content

Commit

Permalink
Rename exec-job -> run-job
Browse files Browse the repository at this point in the history
  • Loading branch information
moskyb committed Mar 2, 2023
1 parent 400a0a8 commit 351a916
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <command> --help" for more information about a command.
Expand Down
8 changes: 4 additions & 4 deletions clicommand/agent_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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")
Expand Down
32 changes: 16 additions & 16 deletions clicommand/exec-job.go → clicommand/run_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...]
Expand All @@ -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"`
Expand Down Expand Up @@ -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: "",
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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()
)
2 changes: 1 addition & 1 deletion job/integration/executor_tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions job/integration/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func main() {
},
},
clicommand.BootstrapCommand,
clicommand.ExecJobCommand,
clicommand.RunJobCommand,
}

app.ErrWriter = os.Stderr
Expand Down
2 changes: 1 addition & 1 deletion packaging/docker/alpine-k8s/buildkite-agent.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand Down
2 changes: 1 addition & 1 deletion packaging/docker/alpine/buildkite-agent.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand Down
2 changes: 1 addition & 1 deletion packaging/docker/sidecar/buildkite-agent.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand Down
2 changes: 1 addition & 1 deletion packaging/docker/ubuntu-18.04/buildkite-agent.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand Down
2 changes: 1 addition & 1 deletion packaging/docker/ubuntu-20.04/buildkite-agent.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand Down
2 changes: 1 addition & 1 deletion packaging/github/linux/buildkite-agent.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand Down
2 changes: 1 addition & 1 deletion packaging/github/windows/buildkite-agent.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand Down
4 changes: 2 additions & 2 deletions utils/path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 351a916

Please sign in to comment.