Skip to content

Commit

Permalink
fix(client): do not cache credentialFuncs for unconfigured repositories
Browse files Browse the repository at this point in the history
When we create the http client for a given repository the code checks if it is somehow configured.
It caches a function called `credentialFunction`. This function knows how to retrieve the
credentials for a given repository. For unconfigured repositories, or repositories that fail to
get valid credentials using their `credentialFunction,` we cache an `emptyCredential function`.
This causes trouble in case of transient errors causing the client to not recover.
This commit avoids caching the `emptyCredential function` in such cases or for unconfigured repositories.

Signed-off-by: Aldo Lacuku <[email protected]>
  • Loading branch information
alacuku authored and poiana committed Sep 21, 2023
1 parent 5507e3b commit 9fa598a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/oci/authn/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ func NewClient(options ...func(*Options)) *auth.Client {
return cred, nil
}
}
// remember empty cred func for registries we dont have creds for
opt.CredentialsFuncsCache[reg] = EmptyCredentialFunc

return auth.EmptyCredential, nil
},
}
Expand Down

0 comments on commit 9fa598a

Please sign in to comment.