Merge pull request #36407 from agawish/36395-mount-print

36395 mount print
Upstream-commit: 8830ef804fec52f3087d9c24a8583ca9954e0967
Component: engine
This commit is contained in:
Akihiro Suda
2018-03-06 02:31:21 +09:00
committed by GitHub
6 changed files with 11 additions and 9 deletions
@@ -1713,7 +1713,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *check.C) {
Type: "bind",
Source: notExistPath,
Target: destPath}}},
msg: "bind source path does not exist",
msg: "bind mount source path does not exist: " + notExistPath,
},
{
config: containertypes.Config{
+1 -1
View File
@@ -83,7 +83,7 @@ func (p *linuxParser) validateMountConfigImpl(mnt *mount.Mount, validateBindSour
if validateBindSourceExists {
exists, _, _ := currentFileInfoProvider.fileInfo(mnt.Source)
if !exists {
return &errMountConfig{mnt, errBindNotExist}
return &errMountConfig{mnt, errBindSourceDoesNotExist(mnt.Source)}
}
}
+4 -2
View File
@@ -7,8 +7,6 @@ import (
"github.com/pkg/errors"
)
var errBindNotExist = errors.New("bind source path does not exist")
type errMountConfig struct {
mount *mount.Mount
err error
@@ -18,6 +16,10 @@ func (e *errMountConfig) Error() string {
return fmt.Sprintf("invalid mount config for type %q: %v", e.mount.Type, e.err.Error())
}
func errBindSourceDoesNotExist(path string) error {
return errors.Errorf("bind mount source path does not exist: %s", path)
}
func errExtraField(name string) error {
return errors.Errorf("field %s must not be specified", name)
}
+2 -2
View File
@@ -31,7 +31,7 @@ func TestValidateMount(t *testing.T) {
{mount.Mount{Type: mount.TypeBind, Source: testDir, Target: testDestinationPath}, nil},
{mount.Mount{Type: "invalid", Target: testDestinationPath}, errors.New("mount type unknown")},
{mount.Mount{Type: mount.TypeBind, Source: testSourcePath, Target: testDestinationPath}, errBindNotExist},
{mount.Mount{Type: mount.TypeBind, Source: testSourcePath, Target: testDestinationPath}, errBindSourceDoesNotExist(testSourcePath)},
}
lcowCases := []struct {
@@ -44,7 +44,7 @@ func TestValidateMount(t *testing.T) {
{mount.Mount{Type: mount.TypeBind}, errMissingField("Target")},
{mount.Mount{Type: mount.TypeBind, Target: "/foo"}, errMissingField("Source")},
{mount.Mount{Type: mount.TypeBind, Target: "/foo", Source: "c:\\foo", VolumeOptions: &mount.VolumeOptions{}}, errExtraField("VolumeOptions")},
{mount.Mount{Type: mount.TypeBind, Source: "c:\\foo", Target: "/foo"}, errBindNotExist},
{mount.Mount{Type: mount.TypeBind, Source: "c:\\foo", Target: "/foo"}, errBindSourceDoesNotExist("c:\\foo")},
{mount.Mount{Type: mount.TypeBind, Source: testDir, Target: "/foo"}, nil},
{mount.Mount{Type: "invalid", Target: "/foo"}, errors.New("mount type unknown")},
}
+2 -2
View File
@@ -120,7 +120,7 @@ func TestParseMountRaw(t *testing.T) {
`c:\:d:\:xyzzy`: "invalid volume specification: ",
`c:`: "cannot be `c:`",
`c:\`: "cannot be `c:`",
`c:\notexist:d:`: `source path does not exist`,
`c:\notexist:d:`: `bind mount source path does not exist: c:\notexist`,
`c:\windows\system32\ntdll.dll:d:`: `source path must be a directory`,
`name<:d:`: `invalid volume specification`,
`name>:d:`: `invalid volume specification`,
@@ -189,7 +189,7 @@ func TestParseMountRaw(t *testing.T) {
`c:\:/foo:xyzzy`: "invalid volume specification: ",
`/`: "destination can't be '/'",
`/..`: "destination can't be '/'",
`c:\notexist:/foo`: `source path does not exist`,
`c:\notexist:/foo`: `bind mount source path does not exist: c:\notexist`,
`c:\windows\system32\ntdll.dll:/foo`: `source path must be a directory`,
`name<:/foo`: `invalid volume specification`,
`name>:/foo`: `invalid volume specification`,
+1 -1
View File
@@ -252,7 +252,7 @@ func (p *windowsParser) validateMountConfigReg(mnt *mount.Mount, destRegex strin
return &errMountConfig{mnt, err}
}
if !exists {
return &errMountConfig{mnt, errBindNotExist}
return &errMountConfig{mnt, errBindSourceDoesNotExist(mnt.Source)}
}
if !isdir {
return &errMountConfig{mnt, fmt.Errorf("source path must be a directory")}