mirror of
https://github.com/docker/cli.git
synced 2026-09-28 02:06:53 -04:00
Signed-off-by: John Howard <jhoward@microsoft.com>
Revert "Combine SetupWorkingDirectory for Linux and Windows" This reverts commit ec31741ca186278ea60faf49f85087c493e78806. Upstream-commit: 54320d8d187d8b33be4fd33cfb3f8e486c6c8d90 Component: engine
This commit is contained in:
@@ -22,7 +22,6 @@ import (
|
||||
"github.com/docker/docker/pkg/promise"
|
||||
"github.com/docker/docker/pkg/signal"
|
||||
"github.com/docker/docker/pkg/symlink"
|
||||
"github.com/docker/docker/pkg/system"
|
||||
"github.com/docker/docker/runconfig"
|
||||
"github.com/docker/docker/volume"
|
||||
containertypes "github.com/docker/engine-api/types/container"
|
||||
@@ -184,34 +183,6 @@ func (container *Container) WriteHostConfig() error {
|
||||
return json.NewEncoder(f).Encode(&container.HostConfig)
|
||||
}
|
||||
|
||||
// SetupWorkingDirectory sets up the container's working directory as set in container.Config.WorkingDir
|
||||
func (container *Container) SetupWorkingDirectory() error {
|
||||
if container.Config.WorkingDir == "" {
|
||||
return nil
|
||||
}
|
||||
container.Config.WorkingDir = filepath.Clean(container.Config.WorkingDir)
|
||||
|
||||
pth, err := container.GetResourcePath(container.Config.WorkingDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pthInfo, err := os.Stat(pth)
|
||||
if err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := system.MkdirAll(pth, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if pthInfo != nil && !pthInfo.IsDir() {
|
||||
return derr.ErrorCodeNotADir.WithArgs(container.Config.WorkingDir)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetResourcePath evaluates `path` in the scope of the container's BaseFS, with proper path
|
||||
// sanitisation. Symlinks are all scoped to the BaseFS of the container, as
|
||||
// though the container's BaseFS was `/`.
|
||||
|
||||
Reference in New Issue
Block a user