mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add verify config to verifyContainerSettings
Signed-off-by: Lei Jitang <leijitang@huawei.com>
This commit is contained in:
parent
422fa7f0a6
commit
b37832e353
4 changed files with 13 additions and 11 deletions
|
@ -19,18 +19,11 @@ func (daemon *Daemon) ContainerCreate(name string, config *runconfig.Config, hos
|
|||
return "", nil, fmt.Errorf("Config cannot be empty in order to create a container")
|
||||
}
|
||||
|
||||
warnings, err := daemon.verifyContainerSettings(hostConfig)
|
||||
warnings, err := daemon.verifyContainerSettings(hostConfig, config)
|
||||
if err != nil {
|
||||
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)
|
||||
if err != nil {
|
||||
if daemon.Graph().IsNotExist(err, config.Image) {
|
||||
|
|
|
@ -112,9 +112,18 @@ func checkKernel() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (daemon *Daemon) verifyContainerSettings(hostConfig *runconfig.HostConfig) ([]string, error) {
|
||||
func (daemon *Daemon) verifyContainerSettings(hostConfig *runconfig.HostConfig, config *runconfig.Config) ([]string, error) {
|
||||
var warnings []string
|
||||
|
||||
if config != nil {
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
|
||||
if hostConfig == nil {
|
||||
return warnings, nil
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ func checkKernel() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (daemon *Daemon) verifyContainerSettings(hostConfig *runconfig.HostConfig) ([]string, error) {
|
||||
func (daemon *Daemon) verifyContainerSettings(hostConfig *runconfig.HostConfig, config *runconfig.HostConfig) ([]string, error) {
|
||||
// TODO Windows. Verifications TBC
|
||||
return nil, nil
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ func (daemon *Daemon) ContainerStart(name string, hostConfig *runconfig.HostConf
|
|||
return fmt.Errorf("Container already started")
|
||||
}
|
||||
|
||||
if _, err = daemon.verifyContainerSettings(hostConfig); err != nil {
|
||||
if _, err = daemon.verifyContainerSettings(hostConfig, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue