Return error for lxc-conf when using native driver

Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
Michael Crosby 2014-02-25 17:13:00 -08:00
Родитель 5c67d2e634
Коммит bfdf07ac98
1 изменённых файлов: 14 добавлений и 0 удалений

Просмотреть файл

@ -67,6 +67,9 @@ func NewDriver(root string) (*driver, error) {
}
func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallback execdriver.StartCallback) (int, error) {
if err := d.validateCommand(c); err != nil {
return -1, err
}
var (
term nsinit.Terminal
container = createContainer(c)
@ -192,6 +195,17 @@ func (d *driver) removeContainerRoot(id string) error {
return os.RemoveAll(filepath.Join(d.root, id))
}
func (d *driver) validateCommand(c *execdriver.Command) error {
// we need to check the Config of the command to make sure that we
// do not have any of the lxc-conf variables
for _, conf := range c.Config {
if strings.Contains(conf, "lxc") {
return fmt.Errorf("%s is not supported by the native driver", conf)
}
}
return nil
}
func getEnv(key string, env []string) string {
for _, pair := range env {
parts := strings.Split(pair, "=")