Signed-off-by: Antonio Murdaca <runcom@linux.com>
| ... | ... |
@@ -659,7 +659,7 @@ func (s *Server) postCommit(version version.Version, w http.ResponseWriter, r *h |
| 659 | 659 |
return err |
| 660 | 660 |
} |
| 661 | 661 |
|
| 662 |
- cont := r.Form.Get("container")
|
|
| 662 |
+ cname := r.Form.Get("container")
|
|
| 663 | 663 |
|
| 664 | 664 |
pause := boolValue(r, "pause") |
| 665 | 665 |
if r.FormValue("pause") == "" && version.GreaterThanOrEqualTo("1.13") {
|
| ... | ... |
@@ -671,7 +671,7 @@ func (s *Server) postCommit(version version.Version, w http.ResponseWriter, r *h |
| 671 | 671 |
return err |
| 672 | 672 |
} |
| 673 | 673 |
|
| 674 |
- containerCommitConfig := &daemon.ContainerCommitConfig{
|
|
| 674 |
+ commitCfg := &builder.BuilderCommitConfig{
|
|
| 675 | 675 |
Pause: pause, |
| 676 | 676 |
Repo: r.Form.Get("repo"),
|
| 677 | 677 |
Tag: r.Form.Get("tag"),
|
| ... | ... |
@@ -681,7 +681,7 @@ func (s *Server) postCommit(version version.Version, w http.ResponseWriter, r *h |
| 681 | 681 |
Config: c, |
| 682 | 682 |
} |
| 683 | 683 |
|
| 684 |
- imgID, err := builder.Commit(s.daemon, cont, containerCommitConfig) |
|
| 684 |
+ imgID, err := builder.Commit(cname, s.daemon, commitCfg) |
|
| 685 | 685 |
if err != nil {
|
| 686 | 686 |
return err |
| 687 | 687 |
} |
| ... | ... |
@@ -107,8 +107,14 @@ func (b *Builder) commit(id string, autoCmd *runconfig.Command, comment string) |
| 107 | 107 |
autoConfig := *b.Config |
| 108 | 108 |
autoConfig.Cmd = autoCmd |
| 109 | 109 |
|
| 110 |
+ commitCfg := &daemon.ContainerCommitConfig{
|
|
| 111 |
+ Author: b.maintainer, |
|
| 112 |
+ Pause: true, |
|
| 113 |
+ Config: &autoConfig, |
|
| 114 |
+ } |
|
| 115 |
+ |
|
| 110 | 116 |
// Commit the container |
| 111 |
- image, err := b.Daemon.Commit(container, "", "", "", b.maintainer, true, &autoConfig) |
|
| 117 |
+ image, err := b.Daemon.Commit(container, commitCfg) |
|
| 112 | 118 |
if err != nil {
|
| 113 | 119 |
return err |
| 114 | 120 |
} |
| ... | ... |
@@ -215,7 +215,17 @@ func BuildFromConfig(d *daemon.Daemon, c *runconfig.Config, changes []string) (* |
| 215 | 215 |
return builder.Config, nil |
| 216 | 216 |
} |
| 217 | 217 |
|
| 218 |
-func Commit(d *daemon.Daemon, name string, c *daemon.ContainerCommitConfig) (string, error) {
|
|
| 218 |
+type BuilderCommitConfig struct {
|
|
| 219 |
+ Pause bool |
|
| 220 |
+ Repo string |
|
| 221 |
+ Tag string |
|
| 222 |
+ Author string |
|
| 223 |
+ Comment string |
|
| 224 |
+ Changes []string |
|
| 225 |
+ Config *runconfig.Config |
|
| 226 |
+} |
|
| 227 |
+ |
|
| 228 |
+func Commit(name string, d *daemon.Daemon, c *BuilderCommitConfig) (string, error) {
|
|
| 219 | 229 |
container, err := d.Get(name) |
| 220 | 230 |
if err != nil {
|
| 221 | 231 |
return "", err |
| ... | ... |
@@ -234,7 +244,16 @@ func Commit(d *daemon.Daemon, name string, c *daemon.ContainerCommitConfig) (str |
| 234 | 234 |
return "", err |
| 235 | 235 |
} |
| 236 | 236 |
|
| 237 |
- img, err := d.Commit(container, c.Repo, c.Tag, c.Comment, c.Author, c.Pause, newConfig) |
|
| 237 |
+ commitCfg := &daemon.ContainerCommitConfig{
|
|
| 238 |
+ Pause: c.Pause, |
|
| 239 |
+ Repo: c.Repo, |
|
| 240 |
+ Tag: c.Tag, |
|
| 241 |
+ Author: c.Author, |
|
| 242 |
+ Comment: c.Comment, |
|
| 243 |
+ Config: newConfig, |
|
| 244 |
+ } |
|
| 245 |
+ |
|
| 246 |
+ img, err := d.Commit(container, commitCfg) |
|
| 238 | 247 |
if err != nil {
|
| 239 | 248 |
return "", err |
| 240 | 249 |
} |
| ... | ... |
@@ -11,14 +11,13 @@ type ContainerCommitConfig struct {
|
| 11 | 11 |
Tag string |
| 12 | 12 |
Author string |
| 13 | 13 |
Comment string |
| 14 |
- Changes []string |
|
| 15 | 14 |
Config *runconfig.Config |
| 16 | 15 |
} |
| 17 | 16 |
|
| 18 | 17 |
// Commit creates a new filesystem image from the current state of a container. |
| 19 | 18 |
// The image can optionally be tagged into a repository |
| 20 |
-func (daemon *Daemon) Commit(container *Container, repository, tag, comment, author string, pause bool, config *runconfig.Config) (*image.Image, error) {
|
|
| 21 |
- if pause && !container.IsPaused() {
|
|
| 19 |
+func (daemon *Daemon) Commit(container *Container, c *ContainerCommitConfig) (*image.Image, error) {
|
|
| 20 |
+ if c.Pause && !container.IsPaused() {
|
|
| 22 | 21 |
container.Pause() |
| 23 | 22 |
defer container.Unpause() |
| 24 | 23 |
} |
| ... | ... |
@@ -45,14 +44,14 @@ func (daemon *Daemon) Commit(container *Container, repository, tag, comment, aut |
| 45 | 45 |
containerConfig = container.Config |
| 46 | 46 |
} |
| 47 | 47 |
|
| 48 |
- img, err := daemon.graph.Create(rwTar, containerID, parentImageID, comment, author, containerConfig, config) |
|
| 48 |
+ img, err := daemon.graph.Create(rwTar, containerID, parentImageID, c.Comment, c.Author, containerConfig, c.Config) |
|
| 49 | 49 |
if err != nil {
|
| 50 | 50 |
return nil, err |
| 51 | 51 |
} |
| 52 | 52 |
|
| 53 | 53 |
// Register the image if needed |
| 54 |
- if repository != "" {
|
|
| 55 |
- if err := daemon.repositories.Tag(repository, tag, img.ID, true); err != nil {
|
|
| 54 |
+ if c.Repo != "" {
|
|
| 55 |
+ if err := daemon.repositories.Tag(c.Repo, c.Tag, img.ID, true); err != nil {
|
|
| 56 | 56 |
return img, err |
| 57 | 57 |
} |
| 58 | 58 |
} |