(stuff map[name.Reference]partial.Describable)
| 74 | } |
| 75 | |
| 76 | func (xcr *fakeXCR) setRefs(stuff map[name.Reference]partial.Describable) error { |
| 77 | repos := make(map[string]google.Tags) |
| 78 | |
| 79 | for ref, thing := range stuff { |
| 80 | repo := ref.Context().RepositoryStr() |
| 81 | tags, ok := repos[repo] |
| 82 | if !ok { |
| 83 | tags = google.Tags{ |
| 84 | Name: repo, |
| 85 | Children: []string{}, |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | // Populate the "child" field. |
| 90 | for parentPath := repo; parentPath != "."; parentPath = path.Dir(parentPath) { |
| 91 | child, parent := path.Base(parentPath), path.Dir(parentPath) |
| 92 | tags, ok := repos[parent] |
| 93 | if !ok { |
| 94 | tags = google.Tags{} |
| 95 | } |
| 96 | for _, c := range repos[parent].Children { |
| 97 | if c == child { |
| 98 | break |
| 99 | } |
| 100 | } |
| 101 | tags.Children = append(tags.Children, child) |
| 102 | repos[parent] = tags |
| 103 | } |
| 104 | |
| 105 | // Populate the "manifests" and "tags" field. |
| 106 | d, err := thing.Digest() |
| 107 | if err != nil { |
| 108 | return err |
| 109 | } |
| 110 | mt, err := thing.MediaType() |
| 111 | if err != nil { |
| 112 | return err |
| 113 | } |
| 114 | if tags.Manifests == nil { |
| 115 | tags.Manifests = make(map[string]google.ManifestInfo) |
| 116 | } |
| 117 | mi, ok := tags.Manifests[d.String()] |
| 118 | if !ok { |
| 119 | mi = google.ManifestInfo{ |
| 120 | MediaType: string(mt), |
| 121 | Tags: []string{}, |
| 122 | } |
| 123 | } |
| 124 | if tag, ok := ref.(name.Tag); ok { |
| 125 | tags.Tags = append(tags.Tags, tag.Identifier()) |
| 126 | mi.Tags = append(mi.Tags, tag.Identifier()) |
| 127 | } |
| 128 | tags.Manifests[d.String()] = mi |
| 129 | repos[repo] = tags |
| 130 | } |
| 131 | xcr.repos = repos |
| 132 | return nil |
| 133 | } |
no test coverage detected