From ae97477284fade20520b5991709d6b65d5fd4442 Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Fri, 26 Apr 2013 10:48:33 -0700 Subject: [PATCH] Remove -command in CmdCommit and make -config use Json --- commands.go | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/commands.go b/commands.go index 8e0a351728..3349a1aa27 100644 --- a/commands.go +++ b/commands.go @@ -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") flComment := cmd.String("m", "", "Commit message") flAuthor := cmd.String("author", "", "Author (eg. \"John Hannibal Smith \"") - flConfig := cmd.String("config", "", "Config automatically applied when the image is run. This option must be the last one.") - flCommand := cmd.String("command", "", "Command to run when starting the image") + flConfig := cmd.String("config", "", "Config automatically applied when the image is run. "+`(ex: -config '{"Cmd": ["cat", "/world"], "PortSpecs": ["22"]}')`) if err := cmd.Parse(args); err != nil { return nil } @@ -737,21 +736,14 @@ func (srv *Server) CmdCommit(stdin io.ReadCloser, stdout io.Writer, args ...stri return nil } - var config []string + config := &Config{} if *flConfig != "" { - config = strings.Split(*flConfig, " ") - } - 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 + if err := json.Unmarshal([]byte(*flConfig), config); err != nil { + 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 { return err }