Make ParseAuthHost public

Signed-off-by: guillaume <guillaume.derouville@gmail.com>
This commit is contained in:
guillaume 2022-01-31 16:05:58 +01:00
parent f6a71b95cf
commit 1a98c572b8
2 changed files with 4 additions and 4 deletions

View File

@ -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
}
@ -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, "/")

View File

@ -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)
}
@ -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)
}