implement volume mount for container job (#1101)
* implement volume mount for container job * Update pkg/runner/run_context.go Co-authored-by: Ryan <me@hackerc.at> * add tests for container volume mount options * remove unused code * prefer if-else instead of if-continue * remove continue * add some tests Co-authored-by: Ryan <me@hackerc.at> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
@@ -102,6 +102,21 @@ func (rc *RunContext) GetBindsAndMounts() ([]string, map[string]string) {
|
||||
name + "-env": ActPath,
|
||||
}
|
||||
|
||||
if job := rc.Run.Job(); job != nil {
|
||||
if container := job.Container(); container != nil {
|
||||
for _, v := range container.Volumes {
|
||||
if !strings.Contains(v, ":") || filepath.IsAbs(v) {
|
||||
// Bind anonymous volume or host file.
|
||||
binds = append(binds, v)
|
||||
} else {
|
||||
// Mount existing volume.
|
||||
paths := strings.SplitN(v, ":", 2)
|
||||
mounts[paths[0]] = paths[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if rc.Config.BindWorkdir {
|
||||
bindModifiers := ""
|
||||
if runtime.GOOS == "darwin" {
|
||||
|
Reference in New Issue
Block a user