Skip to content

Fix EntryForRegistry code coverage randomization #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Changes from all commits
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
10 changes: 8 additions & 2 deletions registry/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/http"
"net/url"
"os"
"slices"
"strings"
"sync"

Expand Down Expand Up @@ -137,8 +138,13 @@ func (c dockerAuthConfigWrapper) EntryForRegistry(host string) (ociauth.ConfigEn
if entry, err := c.Config.EntryForRegistry(host); err == nil && entry != zero {
return entry, err
} else if dockerHubHosts[host] {
// TODO this will iterate in a random order -- maybe that's fine, but maybe we want something more stable? (the new "SortedKeys" iterator that we might get in go1.23? I guess that was rejected, so "slices.Sorted(maps.Keys)")
for dockerHubHost := range dockerHubHosts {
// https://github.com/docker-library/meta-scripts/pull/32#issuecomment-2018950756 (TODO hopefully someday we can replace this with something like `iter.Sorted(maps.Keys(dockerHubHosts))`; https://github.com/golang/go/issues/61900)
keys := make([]string, 0, len(dockerHubHosts))
for k := range dockerHubHosts {
keys = append(keys, k)
}
slices.Sort(keys)
for _, dockerHubHost := range keys {
if dockerHubHost == "" {
continue
}
Expand Down