mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Enable auto-creation of host-path on Windows
Auto-creation of host-paths has been un-deprecated, so to have feature-parity between Linux and Windows, this feature should also be present on Windows. This enables auto-creation on Windows. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
926725b470
commit
4e080347af
1 changed files with 14 additions and 14 deletions
|
@ -3,10 +3,10 @@ package volume
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/stringid"
|
"github.com/docker/docker/pkg/stringid"
|
||||||
|
"github.com/docker/docker/pkg/system"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DefaultDriverName is the driver name used for the driver
|
// DefaultDriverName is the driver name used for the driver
|
||||||
|
@ -80,20 +80,20 @@ func (m *MountPoint) Setup() (string, error) {
|
||||||
}
|
}
|
||||||
return m.Volume.Mount(m.ID)
|
return m.Volume.Mount(m.ID)
|
||||||
}
|
}
|
||||||
if len(m.Source) > 0 {
|
if len(m.Source) == 0 {
|
||||||
if _, err := os.Stat(m.Source); err != nil {
|
return "", fmt.Errorf("Unable to setup mount point, neither source nor volume defined")
|
||||||
if !os.IsNotExist(err) {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
if runtime.GOOS != "windows" { // Windows does not have deprecation issues here
|
|
||||||
if err := os.MkdirAll(m.Source, 0755); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return m.Source, nil
|
|
||||||
}
|
}
|
||||||
return "", fmt.Errorf("Unable to setup mount point, neither source nor volume defined")
|
// system.MkdirAll() produces an error if m.Source exists and is a file (not a directory),
|
||||||
|
// so first check if the path does not exist
|
||||||
|
if _, err := os.Stat(m.Source); err != nil {
|
||||||
|
if !os.IsNotExist(err) {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if err := system.MkdirAll(m.Source, 0755); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return m.Source, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Path returns the path of a volume in a mount point.
|
// Path returns the path of a volume in a mount point.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue