Skip to content
This repository has been archived by the owner on Aug 22, 2020. It is now read-only.

Add initial support for an explicit "ManifestListTags" field #2

Merged
merged 3 commits into from
Feb 10, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion manifest/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Maintainers: InfoSiftr <[email protected]> (@infosiftr),
Johan Euphrosine <[email protected]> (@proppy)
GitRepo: https://github.com/docker-library/golang.git
GitFetch: refs/heads/master
SharedTags: latest


# hi
Expand All @@ -29,18 +30,20 @@ GitFetch: refs/heads/master


# Go 1.6
Tags: 1.6.1, 1.6, 1, latest
Tags: 1.6.1, 1.6, 1
GitCommit: 0ce80411b9f41e9c3a21fc0a1bffba6ae761825a
Directory: 1.6


# Go 1.5
Tags: 1.5.3
SharedTags: 1.5.3-debian, 1.5-debian
GitCommit: d7e2a8d90a9b8f5dfd5bcd428e0c33b68c40cc19
Directory: 1.5


Tags: 1.5
SharedTags: 1.5-debian
GitCommit: d7e2a8d90a9b8f5dfd5bcd428e0c33b68c40cc19
Directory: 1.5

Expand All @@ -51,6 +54,15 @@ Directory: 1.5
}
fmt.Printf("-------------\n2822:\n%s\n", man)

fmt.Printf("\nShared Tag Groups:\n")
for _, group := range man.GetSharedTagGroups() {
fmt.Printf("\n - %s\n", strings.Join(group.SharedTags, ", "))
for _, entry := range group.Entries {
fmt.Printf(" - %s\n", entry.TagsString())
}
}
fmt.Printf("\n")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the output of this, for reference:

Shared Tag Groups:

  - latest
    - 1.6.1, 1.6, 1
    - 1.5.3, 1.5

  - 1.5.3-debian, 1.5-debian
    - 1.5.3, 1.5

🤘


man, err = manifest.Parse(bufio.NewReader(strings.NewReader(`
# first set
a: b@c d
Expand Down
12 changes: 8 additions & 4 deletions manifest/rfc2822.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,26 +199,30 @@ func (manifest Manifest2822) GetAllSharedTags() []string {

type SharedTagGroup struct {
SharedTags []string
Entries []*Manifest2822Entry
Entries []*Manifest2822Entry
}

// GetSharedTagGroups returns a map of shared tag groups to the list of entries they share (as described in https://github.com/docker-library/go-dockerlibrary/pull/2#issuecomment-277853597).
func (manifest Manifest2822) GetSharedTagGroups() []SharedTagGroup {
inter := map[string][]string{}
interOrder := []string{} // order matters, and maps randomize order
interKeySep := ","
for _, sharedTag := range manifest.GetAllSharedTags() {
interKeyParts := []string{}
for _, entry := range manifest.GetSharedTag(sharedTag) {
interKeyParts = append(interKeyParts, entry.Tags[0])
}
interKey := strings.Join(interKeyParts, interKeySep)
if _, ok := inter[interKey]; !ok {
interOrder = append(interOrder, interKey)
}
inter[interKey] = append(inter[interKey], sharedTag)
}
ret := []SharedTagGroup{}
for tags, sharedTags := range inter {
for _, tags := range interOrder {
group := SharedTagGroup{
SharedTags: sharedTags,
Entries: []*Manifest2822Entry{},
SharedTags: inter[tags],
Entries: []*Manifest2822Entry{},
}
for _, tag := range strings.Split(tags, interKeySep) {
group.Entries = append(group.Entries, manifest.GetTag(tag))
Expand Down