mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Use ContainerCommitResponse struct for Commit cmd
Signed-off-by: Jamie Hannaford <jamie.hannaford@rackspace.com>
This commit is contained in:
parent
61069d8b69
commit
8b795a05a8
3 changed files with 15 additions and 8 deletions
|
@ -5,7 +5,7 @@ import (
|
|||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"github.com/docker/docker/engine"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/opts"
|
||||
flag "github.com/docker/docker/pkg/mflag"
|
||||
"github.com/docker/docker/pkg/parsers"
|
||||
|
@ -57,9 +57,10 @@ func (cli *DockerCli) CmdCommit(args ...string) error {
|
|||
}
|
||||
|
||||
var (
|
||||
config *runconfig.Config
|
||||
env engine.Env
|
||||
config *runconfig.Config
|
||||
response types.ContainerCommitResponse
|
||||
)
|
||||
|
||||
if *flConfig != "" {
|
||||
config = &runconfig.Config{}
|
||||
if err := json.Unmarshal([]byte(*flConfig), config); err != nil {
|
||||
|
@ -70,10 +71,11 @@ func (cli *DockerCli) CmdCommit(args ...string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := env.Decode(stream); err != nil {
|
||||
|
||||
if err := json.NewDecoder(stream).Decode(&response); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Fprintf(cli.out, "%s\n", env.Get("Id"))
|
||||
fmt.Fprintln(cli.out, response.ID)
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -507,7 +507,6 @@ func postCommit(eng *engine.Engine, version version.Version, w http.ResponseWrit
|
|||
}
|
||||
var (
|
||||
config engine.Env
|
||||
env engine.Env
|
||||
job = eng.Job("commit", r.Form.Get("container"))
|
||||
stdoutBuffer = bytes.NewBuffer(nil)
|
||||
)
|
||||
|
@ -537,8 +536,9 @@ func postCommit(eng *engine.Engine, version version.Version, w http.ResponseWrit
|
|||
if err := job.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
env.Set("Id", engine.Tail(stdoutBuffer, 1))
|
||||
return writeJSONEnv(w, http.StatusCreated, env)
|
||||
return writeJSON(w, http.StatusCreated, &types.ContainerCommitResponse{
|
||||
ID: engine.Tail(stdoutBuffer, 1),
|
||||
})
|
||||
}
|
||||
|
||||
// Creates an image from Pull or from Import
|
||||
|
|
|
@ -30,3 +30,8 @@ type ContainerWaitResponse struct {
|
|||
// StatusCode is the status code of the wait job
|
||||
StatusCode int `json:"StatusCode"`
|
||||
}
|
||||
|
||||
// POST "/commit?container="+containerID
|
||||
type ContainerCommitResponse struct {
|
||||
ID string `json:"Id"`
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue