Fix GetSharedTagGroups ordering and update our hacky example code to have some SharedTags examples
This commit is contained in:
parent
c48fd9a499
commit
ff63f9df03
|
|
@ -20,6 +20,7 @@ Maintainers: InfoSiftr <github@infosiftr.com> (@infosiftr),
|
||||||
Johan Euphrosine <proppy@google.com> (@proppy)
|
Johan Euphrosine <proppy@google.com> (@proppy)
|
||||||
GitRepo: https://github.com/docker-library/golang.git
|
GitRepo: https://github.com/docker-library/golang.git
|
||||||
GitFetch: refs/heads/master
|
GitFetch: refs/heads/master
|
||||||
|
SharedTags: latest
|
||||||
|
|
||||||
|
|
||||||
# hi
|
# hi
|
||||||
|
|
@ -29,18 +30,20 @@ GitFetch: refs/heads/master
|
||||||
|
|
||||||
|
|
||||||
# Go 1.6
|
# Go 1.6
|
||||||
Tags: 1.6.1, 1.6, 1, latest
|
Tags: 1.6.1, 1.6, 1
|
||||||
GitCommit: 0ce80411b9f41e9c3a21fc0a1bffba6ae761825a
|
GitCommit: 0ce80411b9f41e9c3a21fc0a1bffba6ae761825a
|
||||||
Directory: 1.6
|
Directory: 1.6
|
||||||
|
|
||||||
|
|
||||||
# Go 1.5
|
# Go 1.5
|
||||||
Tags: 1.5.3
|
Tags: 1.5.3
|
||||||
|
SharedTags: 1.5.3-debian, 1.5-debian
|
||||||
GitCommit: d7e2a8d90a9b8f5dfd5bcd428e0c33b68c40cc19
|
GitCommit: d7e2a8d90a9b8f5dfd5bcd428e0c33b68c40cc19
|
||||||
Directory: 1.5
|
Directory: 1.5
|
||||||
|
|
||||||
|
|
||||||
Tags: 1.5
|
Tags: 1.5
|
||||||
|
SharedTags: 1.5-debian
|
||||||
GitCommit: d7e2a8d90a9b8f5dfd5bcd428e0c33b68c40cc19
|
GitCommit: d7e2a8d90a9b8f5dfd5bcd428e0c33b68c40cc19
|
||||||
Directory: 1.5
|
Directory: 1.5
|
||||||
|
|
||||||
|
|
@ -51,6 +54,15 @@ Directory: 1.5
|
||||||
}
|
}
|
||||||
fmt.Printf("-------------\n2822:\n%s\n", man)
|
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")
|
||||||
|
|
||||||
man, err = manifest.Parse(bufio.NewReader(strings.NewReader(`
|
man, err = manifest.Parse(bufio.NewReader(strings.NewReader(`
|
||||||
# first set
|
# first set
|
||||||
a: b@c d
|
a: b@c d
|
||||||
|
|
|
||||||
|
|
@ -205,6 +205,7 @@ type SharedTagGroup struct {
|
||||||
// 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).
|
// 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 {
|
func (manifest Manifest2822) GetSharedTagGroups() []SharedTagGroup {
|
||||||
inter := map[string][]string{}
|
inter := map[string][]string{}
|
||||||
|
interOrder := []string{} // order matters, and maps randomize order
|
||||||
interKeySep := ","
|
interKeySep := ","
|
||||||
for _, sharedTag := range manifest.GetAllSharedTags() {
|
for _, sharedTag := range manifest.GetAllSharedTags() {
|
||||||
interKeyParts := []string{}
|
interKeyParts := []string{}
|
||||||
|
|
@ -212,12 +213,15 @@ func (manifest Manifest2822) GetSharedTagGroups() []SharedTagGroup {
|
||||||
interKeyParts = append(interKeyParts, entry.Tags[0])
|
interKeyParts = append(interKeyParts, entry.Tags[0])
|
||||||
}
|
}
|
||||||
interKey := strings.Join(interKeyParts, interKeySep)
|
interKey := strings.Join(interKeyParts, interKeySep)
|
||||||
|
if _, ok := inter[interKey]; !ok {
|
||||||
|
interOrder = append(interOrder, interKey)
|
||||||
|
}
|
||||||
inter[interKey] = append(inter[interKey], sharedTag)
|
inter[interKey] = append(inter[interKey], sharedTag)
|
||||||
}
|
}
|
||||||
ret := []SharedTagGroup{}
|
ret := []SharedTagGroup{}
|
||||||
for tags, sharedTags := range inter {
|
for _, tags := range interOrder {
|
||||||
group := SharedTagGroup{
|
group := SharedTagGroup{
|
||||||
SharedTags: sharedTags,
|
SharedTags: inter[tags],
|
||||||
Entries: []*Manifest2822Entry{},
|
Entries: []*Manifest2822Entry{},
|
||||||
}
|
}
|
||||||
for _, tag := range strings.Split(tags, interKeySep) {
|
for _, tag := range strings.Split(tags, interKeySep) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue