Skip to content

Commit

Permalink
rename variable
Browse files Browse the repository at this point in the history
Signed-off-by: Lixia (Sylvia) Lei <[email protected]>
  • Loading branch information
Wwwsylvia committed Sep 8, 2023
1 parent ee5e952 commit 75100f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions registry/remote/auth/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var defaultClientID = "oras-go"
//
// [EmptyCredential] is a valid return value and should not be considered as
// an error.
type CredentialFunc func(ctx context.Context, target string) (Credential, error)
type CredentialFunc func(ctx context.Context, hostport string) (Credential, error)

// StaticCredential specifies static credentials for the given host.
func StaticCredential(registry string, cred Credential) CredentialFunc {
Expand All @@ -69,8 +69,8 @@ func StaticCredential(registry string, cred Credential) CredentialFunc {
// reference: https://github.com/moby/moby/blob/v24.0.0-beta.2/registry/config.go#L25-L48
registry = "registry-1.docker.io"
}
return func(_ context.Context, target string) (Credential, error) {
if target == registry {
return func(_ context.Context, hostport string) (Credential, error) {
if hostport == registry {
return cred, nil
}
return EmptyCredential, nil
Expand Down
8 changes: 4 additions & 4 deletions registry/remote/credentials/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ func Logout(ctx context.Context, store Store, registryName string) error {

// Credential returns a Credential() function that can be used by auth.Client.
func Credential(store Store) auth.CredentialFunc {
return func(ctx context.Context, reg string) (auth.Credential, error) {
reg = ServerAddressFromHostname(reg)
if reg == "" {
return func(ctx context.Context, hostport string) (auth.Credential, error) {
hostport = ServerAddressFromHostname(hostport)
if hostport == "" {
return auth.EmptyCredential, nil
}
return store.Get(ctx, reg)
return store.Get(ctx, hostport)
}
}

Expand Down

0 comments on commit 75100f8

Please sign in to comment.