summaryrefslogtreecommitdiff
path: root/integration/internal
diff options
context:
space:
mode:
authorBrian Goff <cpuguy83@gmail.com>2020-02-03 12:28:19 -0800
committerBrian Goff <cpuguy83@gmail.com>2020-02-04 10:12:05 -0800
commitf464c31668db6fe781b3195f23dc786ee09e91c0 (patch)
tree9256045febbb83a0edbf9694d7bf56492e060ea8 /integration/internal
parent46ec8731fbce9b13e41bd85d6cea691406bba852 (diff)
downloaddocker-f464c31668db6fe781b3195f23dc786ee09e91c0.tar.gz
Check tmpfs mounts before create anon volume
This makes sure that things like `--tmpfs` mounts over an anonymous volume don't create volumes uneccessarily. One method only checks mountpoints, the other checks both mountpoints and tmpfs... the usage of these should likely be consolidated. Ideally, processing for `--tmpfs` mounts would get merged in with the rest of the mount parsing. I opted not to do that for this change so the fix is minimal and can potentially be backported with fewer changes of breaking things. Merging the mount processing for tmpfs can be handled in a followup. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Diffstat (limited to 'integration/internal')
-rw-r--r--integration/internal/container/ops.go21
1 files changed, 19 insertions, 2 deletions
diff --git a/integration/internal/container/ops.go b/integration/internal/container/ops.go
index c829ad1717..57275587ac 100644
--- a/integration/internal/container/ops.go
+++ b/integration/internal/container/ops.go
@@ -2,6 +2,7 @@ package container
import (
"fmt"
+ "strings"
containertypes "github.com/docker/docker/api/types/container"
mounttypes "github.com/docker/docker/api/types/mount"
@@ -77,12 +78,12 @@ func WithMount(m mounttypes.Mount) func(*TestContainerConfig) {
}
// WithVolume sets the volume of the container
-func WithVolume(name string) func(*TestContainerConfig) {
+func WithVolume(target string) func(*TestContainerConfig) {
return func(c *TestContainerConfig) {
if c.Config.Volumes == nil {
c.Config.Volumes = map[string]struct{}{}
}
- c.Config.Volumes[name] = struct{}{}
+ c.Config.Volumes[target] = struct{}{}
}
}
@@ -93,6 +94,22 @@ func WithBind(src, target string) func(*TestContainerConfig) {
}
}
+// WithTmpfs sets a target path in the container to a tmpfs
+func WithTmpfs(target string) func(config *TestContainerConfig) {
+ return func(c *TestContainerConfig) {
+ if c.HostConfig.Tmpfs == nil {
+ c.HostConfig.Tmpfs = make(map[string]string)
+ }
+
+ spec := strings.SplitN(target, ":", 2)
+ var opts string
+ if len(spec) > 1 {
+ opts = spec[1]
+ }
+ c.HostConfig.Tmpfs[spec[0]] = opts
+ }
+}
+
// WithIPv4 sets the specified ip for the specified network of the container
func WithIPv4(network, ip string) func(*TestContainerConfig) {
return func(c *TestContainerConfig) {