Browse Source

Update "github.com/docker-library/go-dockerlibrary" vendoring (improved error handling, more edge cases)

Tianon Gravi 8 years ago
parent
commit
ae7dc214bb

+ 1 - 1
bashbrew/go/vendor/manifest

@@ -10,7 +10,7 @@
 		{
 		{
 			"importpath": "github.com/docker-library/go-dockerlibrary",
 			"importpath": "github.com/docker-library/go-dockerlibrary",
 			"repository": "https://github.com/docker-library/go-dockerlibrary",
 			"repository": "https://github.com/docker-library/go-dockerlibrary",
-			"revision": "6c6566f129042695444eb647d5cee653ca943b0d",
+			"revision": "08ef5a968ebdd83dcc42998a96b6528837b55273",
 			"branch": "master"
 			"branch": "master"
 		},
 		},
 		{
 		{

+ 25 - 13
bashbrew/go/vendor/src/github.com/docker-library/go-dockerlibrary/manifest/rfc2822.go

@@ -26,11 +26,14 @@ type Manifest2822Entry struct {
 	control.Paragraph
 	control.Paragraph
 
 
 	Maintainers []string `delim:"," strip:"\n\r\t "`
 	Maintainers []string `delim:"," strip:"\n\r\t "`
-	Tags        []string `delim:"," strip:"\n\r\t "`
-	GitRepo     string
-	GitFetch    string
-	GitCommit   string
-	Directory   string
+
+	Tags []string `delim:"," strip:"\n\r\t "`
+
+	GitRepo   string
+	GitFetch  string
+	GitCommit string
+	Directory string
+
 	Constraints []string `delim:"," strip:"\n\r\t "`
 	Constraints []string `delim:"," strip:"\n\r\t "`
 }
 }
 
 
@@ -152,10 +155,25 @@ func (manifest Manifest2822) GetTag(tag string) *Manifest2822Entry {
 }
 }
 
 
 func (manifest *Manifest2822) AddEntry(entry Manifest2822Entry) error {
 func (manifest *Manifest2822) AddEntry(entry Manifest2822Entry) error {
+	if len(entry.Tags) < 1 {
+		return fmt.Errorf("missing Tags")
+	}
+	if entry.GitRepo == "" || entry.GitFetch == "" || entry.GitCommit == "" {
+		return fmt.Errorf("Tags %q missing one of GitRepo, GitFetch, or GitCommit", entry.TagsString())
+	}
+	if invalidMaintainers := entry.InvalidMaintainers(); len(invalidMaintainers) > 0 {
+		return fmt.Errorf("Tags %q has invalid Maintainers: %q (expected format %q)", strings.Join(invalidMaintainers, ", "), MaintainersFormat)
+	}
+
+	seenTag := map[string]bool{}
 	for _, tag := range entry.Tags {
 	for _, tag := range entry.Tags {
-		if manifest.GetTag(tag) != nil {
-			return fmt.Errorf("Tags %q includes duplicate tag: %s", entry.TagsString(), tag)
+		if otherEntry := manifest.GetTag(tag); otherEntry != nil {
+			return fmt.Errorf("Tags %q includes duplicate tag: %q (duplicated in %q)", entry.TagsString(), tag, otherEntry.TagsString())
+		}
+		if seenTag[tag] {
+			return fmt.Errorf("Tags %q includes duplicate tag: %q", entry.TagsString(), tag)
 		}
 		}
+		seenTag[tag] = true
 	}
 	}
 
 
 	for i, existingEntry := range manifest.Entries {
 	for i, existingEntry := range manifest.Entries {
@@ -246,12 +264,6 @@ func Parse2822(readerIn io.Reader) (*Manifest2822, error) {
 			return nil, err
 			return nil, err
 		}
 		}
 
 
-		if len(entry.Tags) < 1 {
-			return nil, fmt.Errorf("missing Tags")
-		}
-		if entry.GitRepo == "" || entry.GitFetch == "" || entry.GitCommit == "" {
-			return nil, fmt.Errorf("Tags %q missing one of GitRepo, GitFetch, or GitCommit", entry.TagsString())
-		}
 		if !GitFetchRegex.MatchString(entry.GitFetch) {
 		if !GitFetchRegex.MatchString(entry.GitFetch) {
 			return nil, fmt.Errorf(`Tags %q has invalid GitFetch (must be "refs/heads/..." or "refs/tags/..."): %q`, entry.TagsString(), entry.GitFetch)
 			return nil, fmt.Errorf(`Tags %q has invalid GitFetch (must be "refs/heads/..." or "refs/tags/..."): %q`, entry.TagsString(), entry.GitFetch)
 		}
 		}