Skip to content

Commit

Permalink
run,job: Pass task param as environmental var to container
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Jung <a.jung@lancs.ac.uk>
  • Loading branch information
nderjung committed Dec 31, 2020
1 parent 32c7bd0 commit 43f4b95
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions job/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ func (atr *ActiveTaskRun) Start() (int, time.Duration, error) {
os.MkdirAll(workDir, os.ModePerm)
}

var env []string
for _, param := range atr.Task.Params {
env = append(env, fmt.Sprintf("%s=%s", param.Name, param.Value))
}

config := &run.RunnerConfig{
Log: atr.log,
CacheDir: atr.Task.cacheDir,
Expand All @@ -179,6 +184,7 @@ func (atr *ActiveTaskRun) Start() (int, time.Duration, error) {
Devices: atr.run.Devices,
Inputs: atr.Task.Inputs,
Outputs: atr.Task.Outputs,
Env: env,
}
if atr.run.Path != "" {
config.Path = atr.run.Path
Expand Down
1 change: 1 addition & 0 deletions run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type RunnerConfig struct {
AllowOverride bool
Inputs *[]Input
Outputs *[]Output
Env []string
}

type Runner interface {
Expand Down
2 changes: 1 addition & 1 deletion run/runc.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func (r *RuncRunner) Run() (int, time.Duration, error) {

taskProcess := &libcontainer.Process{
Cwd: "/",
Env: defaultEnvironment,
Env: append(defaultEnvironment, r.Config.Env...),
User: "root",
Stdout: r.log,
Stderr: r.log,
Expand Down

0 comments on commit 43f4b95

Please sign in to comment.