소스 검색

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.
Tianon Gravi 6 년 전
부모
커밋
c11e329115
1개의 변경된 파일6개의 추가작업 그리고 1개의 파일을 삭제
  1. 6 1
      bashbrew/go/src/bashbrew/sort.go

+ 6 - 1
bashbrew/go/src/bashbrew/sort.go

@@ -79,7 +79,12 @@ func sortRepoObjects(rs []*Repo, applyConstraints bool) ([]*Repo, error) {
 	for _, r := range rs {
 		node := r.Identifier()
 		for _, entry := range r.Entries() {
-			for _, tag := range r.Tags(namespace, false, entry) {
+			// add edges both with and without namespace so sorting still works properly for official images ("bashbrew --namespace amd64 list --build-order wordpress php")
+			// 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
+			tags := []string{}
+			tags = append(tags, r.Tags("", false, entry)...)
+			tags = append(tags, r.Tags(namespace, false, entry)...)
+			for _, tag := range tags {
 				if canonicalRepo, ok := canonicalRepos[tag]; ok && canonicalRepo.TagName != "" {
 					// if we run into a duplicate, we want to prefer a specific tag over a full repo
 					continue