Signed-off-by: Shishir Mahajan <shishir.mahajan@redhat.com>
| ... | ... |
@@ -698,6 +698,7 @@ func getImagesGet(eng *engine.Engine, version version.Version, w http.ResponseWr |
| 698 | 698 |
func postImagesLoad(eng *engine.Engine, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
| 699 | 699 |
job := eng.Job("load")
|
| 700 | 700 |
job.Stdin.Add(r.Body) |
| 701 |
+ job.Stdout.Add(w) |
|
| 701 | 702 |
return job.Run() |
| 702 | 703 |
} |
| 703 | 704 |
|
| ... | ... |
@@ -68,7 +68,7 @@ func (s *TagStore) CmdLoad(job *engine.Job) error {
|
| 68 | 68 |
|
| 69 | 69 |
for imageName, tagMap := range repositories {
|
| 70 | 70 |
for tag, address := range tagMap {
|
| 71 |
- if err := s.Set(imageName, tag, address, true); err != nil {
|
|
| 71 |
+ if err := s.SetLoad(imageName, tag, address, true, job.Stdout); err != nil {
|
|
| 72 | 72 |
return err |
| 73 | 73 |
} |
| 74 | 74 |
} |
| ... | ... |
@@ -4,6 +4,7 @@ import ( |
| 4 | 4 |
"encoding/json" |
| 5 | 5 |
"errors" |
| 6 | 6 |
"fmt" |
| 7 |
+ "io" |
|
| 7 | 8 |
"io/ioutil" |
| 8 | 9 |
"os" |
| 9 | 10 |
"path/filepath" |
| ... | ... |
@@ -221,6 +222,10 @@ func (store *TagStore) Delete(repoName, ref string) (bool, error) {
|
| 221 | 221 |
} |
| 222 | 222 |
|
| 223 | 223 |
func (store *TagStore) Set(repoName, tag, imageName string, force bool) error {
|
| 224 |
+ return store.SetLoad(repoName, tag, imageName, force, nil) |
|
| 225 |
+} |
|
| 226 |
+ |
|
| 227 |
+func (store *TagStore) SetLoad(repoName, tag, imageName string, force bool, out io.Writer) error {
|
|
| 224 | 228 |
img, err := store.LookupImage(imageName) |
| 225 | 229 |
store.Lock() |
| 226 | 230 |
defer store.Unlock() |
| ... | ... |
@@ -243,8 +248,17 @@ func (store *TagStore) Set(repoName, tag, imageName string, force bool) error {
|
| 243 | 243 |
repoName = registry.NormalizeLocalName(repoName) |
| 244 | 244 |
if r, exists := store.Repositories[repoName]; exists {
|
| 245 | 245 |
repo = r |
| 246 |
- if old, exists := store.Repositories[repoName][tag]; exists && !force {
|
|
| 247 |
- return fmt.Errorf("Conflict: Tag %s is already set to image %s, if you want to replace it, please use -f option", tag, old)
|
|
| 246 |
+ if old, exists := store.Repositories[repoName][tag]; exists {
|
|
| 247 |
+ |
|
| 248 |
+ if !force {
|
|
| 249 |
+ return fmt.Errorf("Conflict: Tag %s is already set to image %s, if you want to replace it, please use -f option", tag, old)
|
|
| 250 |
+ } |
|
| 251 |
+ |
|
| 252 |
+ if old != img.ID && out != nil {
|
|
| 253 |
+ |
|
| 254 |
+ fmt.Fprintf(out, "The image %s:%s already exists, renaming the old one with ID %s to empty string\n", repoName, tag, old[:12]) |
|
| 255 |
+ |
|
| 256 |
+ } |
|
| 248 | 257 |
} |
| 249 | 258 |
} else {
|
| 250 | 259 |
repo = make(map[string]string) |