瀏覽代碼

Merge pull request #3144 from infosiftr/manifest-tool-0.6.0

Update manifest-tool to 0.6.0 and take advantage of new "tags:" support (for increased efficiency in pushing aliases)
yosifkit 8 年之前
父節點
當前提交
f5ab22b02d
共有 2 個文件被更改,包括 24 次插入16 次删除
  1. 1 1
      bashbrew/Dockerfile.release
  2. 23 15
      bashbrew/go/src/bashbrew/cmd-put-shared.go

+ 1 - 1
bashbrew/Dockerfile.release

@@ -10,7 +10,7 @@ ENV GOPATH /usr/src/bashbrew:/usr/src/bashbrew/vendor
 ENV CGO_ENABLED 0
 
 # https://github.com/estesp/manifest-tool/releases
-ENV MANIFEST_TOOL_VERSION 0.5.0
+ENV MANIFEST_TOOL_VERSION 0.6.0
 # gpg: key 0F386284C03A1162: public key "Philip Estes <[email protected]>" imported
 ENV MANIFEST_TOOL_GPG_KEY 27F3EA268A97867EAF0BD05C0F386284C03A1162
 

+ 23 - 15
bashbrew/go/src/bashbrew/cmd-put-shared.go

@@ -47,6 +47,17 @@ func entriesToManifestToolYaml(r Repo, entries ...*manifest.Manifest2822Entry) (
 	return "manifests:\n" + yaml, nil
 }
 
+func tagsToManifestToolYaml(repo string, tags ...string) string {
+	yaml := fmt.Sprintf("image: %s:%s\n", repo, tags[0])
+	if len(tags) > 1 {
+		yaml += "tags:\n"
+		for _, tag := range tags[1:] {
+			yaml += fmt.Sprintf("  - %s\n", tag)
+		}
+	}
+	return yaml
+}
+
 func cmdPutShared(c *cli.Context) error {
 	repos, err := repos(c.Bool("all"), c.Args()...)
 	if err != nil {
@@ -65,6 +76,8 @@ func cmdPutShared(c *cli.Context) error {
 			return cli.NewMultiError(fmt.Errorf(`failed fetching repo %q`, repo), err)
 		}
 
+		targetRepo := path.Join(namespace, r.RepoName)
+
 		// handle all multi-architecture tags first (regardless of whether they have SharedTags)
 		for _, entry := range r.Entries() {
 			// "image:" will be added later so we don't have to regenerate the entire "manifests" section every time
@@ -73,12 +86,11 @@ func cmdPutShared(c *cli.Context) error {
 				return err
 			}
 
-			for _, tag := range r.Tags(namespace, false, entry) {
-				tagYaml := fmt.Sprintf("image: %s\n%s", tag, yaml)
-				fmt.Printf("Putting %s\n", tag)
-				if err := manifestToolPushFromSpec(tagYaml); err != nil {
-					return fmt.Errorf("failed pushing %q (%q)", tag, entry.TagsString())
-				}
+			entryIdentifier := fmt.Sprintf("%s:%s", targetRepo, entry.Tags[0])
+			fmt.Printf("Putting %s\n", entryIdentifier)
+			tagYaml := tagsToManifestToolYaml(targetRepo, entry.Tags...) + yaml
+			if err := manifestToolPushFromSpec(tagYaml); err != nil {
+				return fmt.Errorf("failed pushing %q (%q)", entryIdentifier, entry.TagsString())
 			}
 		}
 
@@ -92,21 +104,17 @@ func cmdPutShared(c *cli.Context) error {
 			continue
 		}
 
-		targetRepo := path.Join(namespace, r.RepoName)
 		for _, group := range sharedTagGroups {
 			yaml, err := entriesToManifestToolYaml(*r, group.Entries...)
 			if err != nil {
 				return err
 			}
 
-			for _, tag := range group.SharedTags {
-				tag = targetRepo + ":" + tag
-
-				tagYaml := fmt.Sprintf("image: %s\n%s", tag, yaml)
-				fmt.Printf("Putting shared %s\n", tag)
-				if err := manifestToolPushFromSpec(tagYaml); err != nil {
-					return fmt.Errorf("failed pushing %s", tag)
-				}
+			groupIdentifier := fmt.Sprintf("%s:%s", targetRepo, group.SharedTags[0])
+			fmt.Printf("Putting shared %s\n", groupIdentifier)
+			tagYaml := tagsToManifestToolYaml(targetRepo, group.SharedTags...) + yaml
+			if err := manifestToolPushFromSpec(tagYaml); err != nil {
+				return fmt.Errorf("failed pushing %s", groupIdentifier)
 			}
 		}
 	}