mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Make volumes opts more strict
This commit is contained in:
parent
c707c587c1
commit
c7661f40b6
1 changed files with 6 additions and 2 deletions
|
@ -1666,8 +1666,11 @@ func (opts PathOpts) String() string { return fmt.Sprintf("%v", map[string]struc
|
|||
func (opts PathOpts) Set(val string) error {
|
||||
var containerPath string
|
||||
|
||||
splited := strings.SplitN(val, ":", 2)
|
||||
if len(splited) == 1 {
|
||||
if strings.Count(val, ":") > 2 {
|
||||
return fmt.Errorf("bad format for volumes: %s", val)
|
||||
}
|
||||
|
||||
if splited := strings.SplitN(val, ":", 2); len(splited) == 1 {
|
||||
containerPath = splited[0]
|
||||
val = filepath.Clean(splited[0])
|
||||
} else {
|
||||
|
@ -1680,6 +1683,7 @@ func (opts PathOpts) Set(val string) error {
|
|||
return fmt.Errorf("%s is not an absolute path", containerPath)
|
||||
}
|
||||
opts[val] = struct{}{}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue