From 491eb1f68a3ecd47b8dd5c173daf859954e450a2 Mon Sep 17 00:00:00 2001 From: Akhyar Amarullah Date: Wed, 5 Feb 2025 20:11:59 +0700 Subject: [PATCH] feat: allow overriding entrypoint in runJob --- core/runjob.go | 2 ++ core/runjob_test.go | 2 ++ docs/jobs.md | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/core/runjob.go b/core/runjob.go index 6022c51c8..4070d8d1c 100644 --- a/core/runjob.go +++ b/core/runjob.go @@ -33,6 +33,7 @@ type RunJob struct { Network string Hostname string Container string + Entrypoint string Volume []string VolumesFrom []string `gcfg:"volumes-from" mapstructure:"volumes-from,"` Environment []string @@ -170,6 +171,7 @@ func (j *RunJob) buildContainer() (*docker.Container, error) { AttachStdout: true, AttachStderr: true, Tty: j.TTY, + Entrypoint: args.GetArgs(j.Entrypoint), Cmd: args.GetArgs(j.Command), User: j.User, Env: j.Environment, diff --git a/core/runjob_test.go b/core/runjob_test.go index 802d0feb0..92dc57580 100644 --- a/core/runjob_test.go +++ b/core/runjob_test.go @@ -35,6 +35,7 @@ func (s *SuiteRunJob) SetUpTest(c *C) { func (s *SuiteRunJob) TestRun(c *C) { job := &RunJob{Client: s.client} job.Image = ImageFixture + job.Entrypoint = "/bin/bash -c" job.Command = `echo -a "foo bar"` job.User = "foo" job.TTY = true @@ -62,6 +63,7 @@ func (s *SuiteRunJob) TestRun(c *C) { time.Sleep(200 * time.Millisecond) container, err := job.getContainer() c.Assert(err, IsNil) + c.Assert(container.Config.Entrypoint, DeepEquals, []string{"/bin/bash", "-c"}) c.Assert(container.Config.Cmd, DeepEquals, []string{"echo", "-a", "foo bar"}) c.Assert(container.Config.User, Equals, job.User) c.Assert(container.Config.Image, Equals, job.Image) diff --git a/docs/jobs.md b/docs/jobs.md index 0686d0d6f..121f514fc 100644 --- a/docs/jobs.md +++ b/docs/jobs.md @@ -80,6 +80,10 @@ This job can be used in 2 situations: - *description*: When the job should be executed. E.g. every 10 seconds or every night at 1 AM. - *value*: String, see [Scheduling format](https://godoc.org/github.com/robfig/cron) of the Go implementation of `cron`. E.g. `@every 10s` or `0 0 1 * * *` (every night at 1 AM). **Note**: the format starts with seconds, instead of minutes. - *default*: Required field, no default. +- **Entrypoint** (1) + - *description*: Override container default entrypoint. + - *value*: String, e.g. `/bin/bash -c` + - *default*: Default container entrypoint - **Command** (1) - *description*: Command you want to run inside the container. - *value*: String, e.g. `touch /tmp/example`