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

Applying: Fix for Issue 11285: warning message displayed when updating an existing image

Signed-off-by: Shishir Mahajan <shishir.mahajan@redhat.com>
This commit is contained in:
Shishir Mahajan 2015-04-01 10:44:40 -04:00
parent 58390b6087
commit 7d0053d554
3 changed files with 18 additions and 3 deletions

View file

@ -698,6 +698,7 @@ func getImagesGet(eng *engine.Engine, version version.Version, w http.ResponseWr
func postImagesLoad(eng *engine.Engine, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
job := eng.Job("load")
job.Stdin.Add(r.Body)
job.Stdout.Add(w)
return job.Run()
}

View file

@ -68,7 +68,7 @@ func (s *TagStore) CmdLoad(job *engine.Job) error {
for imageName, tagMap := range repositories {
for tag, address := range tagMap {
if err := s.Set(imageName, tag, address, true); err != nil {
if err := s.SetLoad(imageName, tag, address, true, job.Stdout); err != nil {
return err
}
}

View file

@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
@ -221,6 +222,10 @@ func (store *TagStore) Delete(repoName, ref string) (bool, error) {
}
func (store *TagStore) Set(repoName, tag, imageName string, force bool) error {
return store.SetLoad(repoName, tag, imageName, force, nil)
}
func (store *TagStore) SetLoad(repoName, tag, imageName string, force bool, out io.Writer) error {
img, err := store.LookupImage(imageName)
store.Lock()
defer store.Unlock()
@ -243,8 +248,17 @@ func (store *TagStore) Set(repoName, tag, imageName string, force bool) error {
repoName = registry.NormalizeLocalName(repoName)
if r, exists := store.Repositories[repoName]; exists {
repo = r
if old, exists := store.Repositories[repoName][tag]; exists && !force {
return fmt.Errorf("Conflict: Tag %s is already set to image %s, if you want to replace it, please use -f option", tag, old)
if old, exists := store.Repositories[repoName][tag]; exists {
if !force {
return fmt.Errorf("Conflict: Tag %s is already set to image %s, if you want to replace it, please use -f option", tag, old)
}
if old != img.ID && out != nil {
fmt.Fprintf(out, "The image %s:%s already exists, renaming the old one with ID %s to empty string\n", repoName, tag, old[:12])
}
}
} else {
repo = make(map[string]string)