Skip to content

Commit

Permalink
Make ParseAuthHost public
Browse files Browse the repository at this point in the history
Signed-off-by: guillaume <guillaume.derouville@gmail.com>
  • Loading branch information
grouville committed Jan 31, 2022
1 parent f6a71b9 commit 1a98c57
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions solver/registryauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (a *RegistryAuthProvider) Credentials(ctx context.Context, req *bkauth.Cred
defer a.m.RUnlock()

for authHost, auth := range a.credentials {
u, err := parseAuthHost(authHost)
u, err := ParseAuthHost(authHost)
if err != nil {
return nil, err
}
Expand All @@ -65,7 +65,7 @@ func (a *RegistryAuthProvider) Credentials(ctx context.Context, req *bkauth.Cred

// Parsing function based on splitReposSearchTerm
// "github.com/docker/docker/registry"
func parseAuthHost(host string) (string, error) {
func ParseAuthHost(host string) (string, error) {
host = strings.TrimPrefix(host, "http://")
host = strings.TrimPrefix(host, "https://")
host = strings.TrimSuffix(host, "/")
Expand Down
4 changes: 2 additions & 2 deletions solver/registryauth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func TestParseAuthHost(t *testing.T) {

successRefs := []output{}
for _, scase := range scases {
named, err := parseAuthHost(scase.Host)
named, err := ParseAuthHost(scase.Host)
if err != nil {
t.Fatalf("Invalid normalized reference for [%q]. Got %q", scase, err)
}
Expand All @@ -273,7 +273,7 @@ func TestParseAuthHost(t *testing.T) {
}

for _, fcase := range fcases {
named, err := parseAuthHost(fcase.Host)
named, err := ParseAuthHost(fcase.Host)
if err == nil {
t.Fatalf("Invalid normalized reference for [%q]. Expected failure for %q", fcase, named)
}
Expand Down

0 comments on commit 1a98c57

Please sign in to comment.