Merge pull request #36407 from agawish/36395-mount-print
36395 mount print
This commit is contained in:
commit
8830ef804f
|
@ -1713,7 +1713,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *check.C) {
|
||||||
Type: "bind",
|
Type: "bind",
|
||||||
Source: notExistPath,
|
Source: notExistPath,
|
||||||
Target: destPath}}},
|
Target: destPath}}},
|
||||||
msg: "bind source path does not exist",
|
msg: "bind mount source path does not exist: " + notExistPath,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
config: containertypes.Config{
|
config: containertypes.Config{
|
||||||
|
|
|
@ -83,7 +83,7 @@ func (p *linuxParser) validateMountConfigImpl(mnt *mount.Mount, validateBindSour
|
||||||
if validateBindSourceExists {
|
if validateBindSourceExists {
|
||||||
exists, _, _ := currentFileInfoProvider.fileInfo(mnt.Source)
|
exists, _, _ := currentFileInfoProvider.fileInfo(mnt.Source)
|
||||||
if !exists {
|
if !exists {
|
||||||
return &errMountConfig{mnt, errBindNotExist}
|
return &errMountConfig{mnt, errBindSourceDoesNotExist(mnt.Source)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,6 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
var errBindNotExist = errors.New("bind source path does not exist")
|
|
||||||
|
|
||||||
type errMountConfig struct {
|
type errMountConfig struct {
|
||||||
mount *mount.Mount
|
mount *mount.Mount
|
||||||
err error
|
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())
|
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 {
|
func errExtraField(name string) error {
|
||||||
return errors.Errorf("field %s must not be specified", name)
|
return errors.Errorf("field %s must not be specified", name)
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ func TestValidateMount(t *testing.T) {
|
||||||
|
|
||||||
{mount.Mount{Type: mount.TypeBind, Source: testDir, Target: testDestinationPath}, nil},
|
{mount.Mount{Type: mount.TypeBind, Source: testDir, Target: testDestinationPath}, nil},
|
||||||
{mount.Mount{Type: "invalid", Target: testDestinationPath}, errors.New("mount type unknown")},
|
{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 {
|
lcowCases := []struct {
|
||||||
|
@ -44,7 +44,7 @@ func TestValidateMount(t *testing.T) {
|
||||||
{mount.Mount{Type: mount.TypeBind}, errMissingField("Target")},
|
{mount.Mount{Type: mount.TypeBind}, errMissingField("Target")},
|
||||||
{mount.Mount{Type: mount.TypeBind, Target: "/foo"}, errMissingField("Source")},
|
{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, 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: mount.TypeBind, Source: testDir, Target: "/foo"}, nil},
|
||||||
{mount.Mount{Type: "invalid", Target: "/foo"}, errors.New("mount type unknown")},
|
{mount.Mount{Type: "invalid", Target: "/foo"}, errors.New("mount type unknown")},
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ func TestParseMountRaw(t *testing.T) {
|
||||||
`c:\:d:\:xyzzy`: "invalid volume specification: ",
|
`c:\:d:\:xyzzy`: "invalid volume specification: ",
|
||||||
`c:`: "cannot be `c:`",
|
`c:`: "cannot be `c:`",
|
||||||
`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`,
|
`c:\windows\system32\ntdll.dll:d:`: `source path must be a directory`,
|
||||||
`name<:d:`: `invalid volume specification`,
|
`name<:d:`: `invalid volume specification`,
|
||||||
`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: ",
|
`c:\:/foo:xyzzy`: "invalid volume specification: ",
|
||||||
`/`: "destination can't be '/'",
|
`/`: "destination can't be '/'",
|
||||||
`/..`: "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`,
|
`c:\windows\system32\ntdll.dll:/foo`: `source path must be a directory`,
|
||||||
`name<:/foo`: `invalid volume specification`,
|
`name<:/foo`: `invalid volume specification`,
|
||||||
`name>:/foo`: `invalid volume specification`,
|
`name>:/foo`: `invalid volume specification`,
|
||||||
|
|
|
@ -252,7 +252,7 @@ func (p *windowsParser) validateMountConfigReg(mnt *mount.Mount, destRegex strin
|
||||||
return &errMountConfig{mnt, err}
|
return &errMountConfig{mnt, err}
|
||||||
}
|
}
|
||||||
if !exists {
|
if !exists {
|
||||||
return &errMountConfig{mnt, errBindNotExist}
|
return &errMountConfig{mnt, errBindSourceDoesNotExist(mnt.Source)}
|
||||||
}
|
}
|
||||||
if !isdir {
|
if !isdir {
|
||||||
return &errMountConfig{mnt, fmt.Errorf("source path must be a directory")}
|
return &errMountConfig{mnt, fmt.Errorf("source path must be a directory")}
|
||||||
|
|
Loading…
Reference in New Issue