-
Notifications
You must be signed in to change notification settings - Fork 2
/
volumes.go
40 lines (34 loc) · 803 Bytes
/
volumes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package run
import (
"strings"
"github.com/containers/podman/v4/pkg/specgen"
"github.com/julioln/sandman/config"
specs "github.com/opencontainers/runtime-spec/specs-go"
)
func Volumes(spec *specgen.SpecGenerator, containerConfig config.ContainerConfig) {
// Mount additional volumes
for _, volume := range containerConfig.Run.Volumes {
v := strings.Split(volume, ":")
var dest string
var src string
var mountOptions []string
if len(v) < 2 {
// Shorthand
src = v[0]
dest = v[0]
} else {
src = v[0]
dest = v[1]
}
if len(v) > 2 {
// mount -o like arguments
mountOptions = strings.Split(v[2], ",")
}
spec.Mounts = append(spec.Mounts, specs.Mount{
Destination: dest,
Source: src,
Type: "bind",
Options: mountOptions,
})
}
}