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

Remove -command in CmdCommit and make -config use Json

This commit is contained in:
Guillaume J. Charmes 2013-04-26 10:48:33 -07:00
parent 30d327d37e
commit ae97477284

View file

@ -726,8 +726,7 @@ func (srv *Server) CmdCommit(stdin io.ReadCloser, stdout io.Writer, args ...stri
"Create a new image from a container's changes") "Create a new image from a container's changes")
flComment := cmd.String("m", "", "Commit message") flComment := cmd.String("m", "", "Commit message")
flAuthor := cmd.String("author", "", "Author (eg. \"John Hannibal Smith <hannibal@a-team.com>\"") flAuthor := cmd.String("author", "", "Author (eg. \"John Hannibal Smith <hannibal@a-team.com>\"")
flConfig := cmd.String("config", "", "Config automatically applied when the image is run. This option must be the last one.") flConfig := cmd.String("config", "", "Config automatically applied when the image is run. "+`(ex: -config '{"Cmd": ["cat", "/world"], "PortSpecs": ["22"]}')`)
flCommand := cmd.String("command", "", "Command to run when starting the image")
if err := cmd.Parse(args); err != nil { if err := cmd.Parse(args); err != nil {
return nil return nil
} }
@ -737,21 +736,14 @@ func (srv *Server) CmdCommit(stdin io.ReadCloser, stdout io.Writer, args ...stri
return nil return nil
} }
var config []string config := &Config{}
if *flConfig != "" { if *flConfig != "" {
config = strings.Split(*flConfig, " ") if err := json.Unmarshal([]byte(*flConfig), config); err != nil {
}
if *flCommand != "" {
config = append(config, "", "/bin/sh", "-c", *flCommand)
} else if *flConfig != "" {
config = append(config, "", "")
}
c, err := ParseRun(config, stdout, srv.runtime.capabilities)
if err != nil {
return err return err
} }
}
img, err := srv.runtime.Commit(containerName, repository, tag, *flComment, *flAuthor, c) img, err := srv.runtime.Commit(containerName, repository, tag, *flComment, *flAuthor, config)
if err != nil { if err != nil {
return err return err
} }