1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #12772 from Microsoft/10662-moveworkdirchecktoserver

Windows: Move workdir check daemon-side
This commit is contained in:
Tibor Vass 2015-05-01 00:24:40 -04:00
commit 79d086c47d
2 changed files with 9 additions and 8 deletions

View file

@ -2,6 +2,7 @@ package daemon
import ( import (
"fmt" "fmt"
"path/filepath"
"github.com/docker/docker/graph" "github.com/docker/docker/graph"
"github.com/docker/docker/image" "github.com/docker/docker/image"
@ -16,6 +17,13 @@ func (daemon *Daemon) ContainerCreate(name string, config *runconfig.Config, hos
return "", warnings, err return "", warnings, err
} }
// The check for a valid workdir path is made on the server rather than in the
// client. This is because we don't know the type of path (Linux or Windows)
// to validate on the client.
if config.WorkingDir != "" && !filepath.IsAbs(config.WorkingDir) {
return "", warnings, fmt.Errorf("The working directory '%s' is invalid. It needs to be an absolute path.", config.WorkingDir)
}
container, buildWarnings, err := daemon.Create(config, hostConfig, name) container, buildWarnings, err := daemon.Create(config, hostConfig, name)
if err != nil { if err != nil {
if daemon.Graph().IsNotExist(err, config.Image) { if daemon.Graph().IsNotExist(err, config.Image) {

View file

@ -2,7 +2,6 @@ package runconfig
import ( import (
"fmt" "fmt"
"path"
"strconv" "strconv"
"strings" "strings"
@ -15,7 +14,6 @@ import (
) )
var ( var (
ErrInvalidWorkingDirectory = fmt.Errorf("The working directory is invalid. It needs to be an absolute path.")
ErrConflictContainerNetworkAndLinks = fmt.Errorf("Conflicting options: --net=container can't be used with links. This would result in undefined behavior.") ErrConflictContainerNetworkAndLinks = fmt.Errorf("Conflicting options: --net=container can't be used with links. This would result in undefined behavior.")
ErrConflictContainerNetworkAndDns = fmt.Errorf("Conflicting options: --net=container can't be used with --dns. This configuration is invalid.") ErrConflictContainerNetworkAndDns = fmt.Errorf("Conflicting options: --net=container can't be used with --dns. This configuration is invalid.")
ErrConflictNetworkHostname = fmt.Errorf("Conflicting options: -h and the network mode (--net)") ErrConflictNetworkHostname = fmt.Errorf("Conflicting options: -h and the network mode (--net)")
@ -101,12 +99,7 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe
return nil, nil, cmd, err return nil, nil, cmd, err
} }
// Validate input params // Validate input params starting with the input mac address
if *flWorkingDir != "" && !path.IsAbs(*flWorkingDir) {
return nil, nil, cmd, ErrInvalidWorkingDirectory
}
// Validate the input mac address
if *flMacAddress != "" { if *flMacAddress != "" {
if _, err := opts.ValidateMACAddress(*flMacAddress); err != nil { if _, err := opts.ValidateMACAddress(*flMacAddress); err != nil {
return nil, nil, cmd, fmt.Errorf("%s is not a valid mac address", *flMacAddress) return nil, nil, cmd, fmt.Errorf("%s is not a valid mac address", *flMacAddress)