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

Make the commit configuration to be a typed struct rather than accepting a string.

Signed-off-by: David Calavera <david.calavera@gmail.com>
This commit is contained in:
David Calavera 2015-12-09 12:03:09 -05:00
parent 57b6796304
commit 2ec468e284
3 changed files with 15 additions and 16 deletions

View file

@ -1,6 +1,7 @@
package client
import (
"encoding/json"
"errors"
"fmt"
@ -10,6 +11,7 @@ import (
"github.com/docker/docker/opts"
flag "github.com/docker/docker/pkg/mflag"
"github.com/docker/docker/registry"
"github.com/docker/docker/runconfig"
)
// CmdCommit creates a new image from a container's changes.
@ -56,6 +58,14 @@ func (cli *DockerCli) CmdCommit(args ...string) error {
}
}
var config *runconfig.Config
if *flConfig != "" {
config = &runconfig.Config{}
if err := json.Unmarshal([]byte(*flConfig), config); err != nil {
return err
}
}
options := types.ContainerCommitOptions{
ContainerID: name,
RepositoryName: repositoryName,
@ -64,7 +74,7 @@ func (cli *DockerCli) CmdCommit(args ...string) error {
Author: *flAuthor,
Changes: flChanges.GetAll(),
Pause: *flPause,
JSONConfig: *flConfig,
Config: config,
}
response, err := cli.client.ContainerCommit(options)

View file

@ -5,7 +5,6 @@ import (
"net/url"
"github.com/docker/docker/api/types"
"github.com/docker/docker/runconfig"
)
// ContainerCommit applies changes into a container and creates a new tagged image.
@ -23,19 +22,8 @@ func (cli *Client) ContainerCommit(options types.ContainerCommitOptions) (types.
query.Set("pause", "0")
}
var (
config *runconfig.Config
response types.ContainerCommitResponse
)
if options.JSONConfig != "" {
config = &runconfig.Config{}
if err := json.Unmarshal([]byte(options.JSONConfig), config); err != nil {
return response, err
}
}
resp, err := cli.post("/commit", query, config, nil)
var response types.ContainerCommitResponse
resp, err := cli.post("/commit", query, options.Config, nil)
if err != nil {
return response, err
}

View file

@ -8,6 +8,7 @@ import (
"github.com/docker/docker/cliconfig"
"github.com/docker/docker/pkg/parsers/filters"
"github.com/docker/docker/pkg/ulimit"
"github.com/docker/docker/runconfig"
)
// ContainerAttachOptions holds parameters to attach to a container.
@ -28,7 +29,7 @@ type ContainerCommitOptions struct {
Author string
Changes []string
Pause bool
JSONConfig string
Config *runconfig.Config
}
// ContainerExecInspect holds information returned by exec inspect.