Skip to content

Commit 8d6444a

Browse files
committed
Adjust "bashbrew" namespace sorting to account for more edge cases
In particular, our namespace changes made `bashbrew list --build-order wordpress php` work properly but `bashbrew --namespace amd64 list --build-order wordpress php` does not -- these changes adjust our sorting to take into account both the namespaced and the non-namespaced version of each tag in our library when checking the `FROM` values for sorting purposes.
1 parent 40f1034 commit 8d6444a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

go/src/bashbrew/sort.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,12 @@ func sortRepoObjects(rs []*Repo, applyConstraints bool) ([]*Repo, error) {
7979
for _, r := range rs {
8080
node := r.Identifier()
8181
for _, entry := range r.Entries() {
82-
for _, tag := range r.Tags(namespace, false, entry) {
82+
// add edges both with and without namespace so sorting still works properly for official images ("bashbrew --namespace amd64 list --build-order wordpress php")
83+
// this should be reasonably harmless for other use cases of --namespace but catches things like "tianon/foo -> tianon/bar" and things like "php -> wordpress" equally even if we're building to target a different namespace
84+
tags := []string{}
85+
tags = append(tags, r.Tags("", false, entry)...)
86+
tags = append(tags, r.Tags(namespace, false, entry)...)
87+
for _, tag := range tags {
8388
if canonicalRepo, ok := canonicalRepos[tag]; ok && canonicalRepo.TagName != "" {
8489
// if we run into a duplicate, we want to prefer a specific tag over a full repo
8590
continue

0 commit comments

Comments
 (0)