1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-09-15 18:57:01 +00:00

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:
Seunghyun Hwang 2022-04-05 03:01:13 +09:00 committed by GitHub
parent 19cddfbddd
commit c9298d0078
5 changed files with 82 additions and 0 deletions

View file

@ -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" {