Merge pull request #11538 from duglin/EmptyVolume
Check volume path to make sure its not the empty string
This commit is contained in:
commit
ded0ada9b4
2 changed files with 20 additions and 0 deletions
|
@ -427,6 +427,10 @@ func volume(b *Builder, args []string, attributes map[string]bool, original stri
|
|||
b.Config.Volumes = map[string]struct{}{}
|
||||
}
|
||||
for _, v := range args {
|
||||
v = strings.TrimSpace(v)
|
||||
if v == "" {
|
||||
return fmt.Errorf("Volume specified can not be an empty string")
|
||||
}
|
||||
b.Config.Volumes[v] = struct{}{}
|
||||
}
|
||||
if err := b.commit("", b.Config.Cmd, fmt.Sprintf("VOLUME %v", args)); err != nil {
|
||||
|
|
|
@ -5540,3 +5540,19 @@ func TestBuildResourceConstraintsAreUsed(t *testing.T) {
|
|||
|
||||
logDone("build - resource constraints applied")
|
||||
}
|
||||
|
||||
func TestBuildEmptyStringVolume(t *testing.T) {
|
||||
name := "testbuildemptystringvolume"
|
||||
defer deleteImages(name)
|
||||
|
||||
_, err := buildImage(name, `
|
||||
FROM busybox
|
||||
ENV foo=""
|
||||
VOLUME $foo
|
||||
`, false)
|
||||
if err == nil {
|
||||
t.Fatal("Should have failed to build")
|
||||
}
|
||||
|
||||
logDone("build - empty string volume")
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue