Browse code

- Registry: Fix issue preventing to pull specific tag

Guillaume J. Charmes authored on 2013/05/17 04:29:16
Showing 1 changed files
... ...
@@ -340,13 +340,24 @@ func (srv *Server) pullRepository(stdout io.Writer, remote, askedTag string) err
340 340
 	if err != nil {
341 341
 		return err
342 342
 	}
343
-	for tag, id := range tagsList {
344
-		repoData.ImgList[id].Tag = tag
343
+	utils.Debugf("Registering tags")
344
+	// If not specific tag have been asked, take all
345
+	if askedTag == "" {
346
+		for tag, id := range tagsList {
347
+			repoData.ImgList[id].Tag = tag
348
+		}
349
+	} else {
350
+		// Otherwise, check that the tag exists and use only that one
351
+		if id, exists := tagsList[askedTag]; !exists {
352
+			return fmt.Errorf("Tag %s not found in repositoy %s", askedTag, remote)
353
+		} else {
354
+			repoData.ImgList[id].Tag = askedTag
355
+		}
345 356
 	}
346 357
 
347 358
 	for _, img := range repoData.ImgList {
348
-		// If we asked for a specific tag, skip all tags expect the wanted one
349
-		if askedTag != "" && askedTag != img.Tag {
359
+		if askedTag != "" && img.Tag != askedTag {
360
+			utils.Debugf("%s does not match %s, skipping", img.Tag, askedTag)
350 361
 			continue
351 362
 		}
352 363
 		fmt.Fprintf(stdout, "Pulling image %s (%s) from %s\n", img.Id, img.Tag, remote)
... ...
@@ -367,6 +378,10 @@ func (srv *Server) pullRepository(stdout io.Writer, remote, askedTag string) err
367 367
 			return fmt.Errorf("Could not find repository on any of the indexed registries.")
368 368
 		}
369 369
 	}
370
+	// If we asked for a specific tag, do not register the others
371
+	if askedTag != "" {
372
+		return nil
373
+	}
370 374
 	for tag, id := range tagsList {
371 375
 		if err := srv.runtime.repositories.Set(remote, tag, id, true); err != nil {
372 376
 			return err