Skip to content
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

fix: Support global credsStore in docker config #602

Merged
merged 1 commit into from
Jun 7, 2024

Conversation

msiebuhr
Copy link
Contributor

It is perfectly normal to have config.json with just the global config store:

{ "credsStore": "osxkeychain" }

See https://github.com/docker/docker-credential-helpers?tab=readme-ov-file#usage and https://github.com/google/go-containerregistry/tree/main/pkg/authn#helpers for examples.

Previously, the authn-code would only look at the credsStore if there was a specific host maching in auths, but lacking other authn-fields.

Now it also looks at the global credsStore as a fallback.

Fixes #388.

Copy link
Collaborator

@thesayyn thesayyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GREAT! thanks for adding tests.

It is perfectly normal to have config.json with just the global config
store:

    { "credsStore": "osxkeychain" }

See https://github.com/docker/docker-credential-helpers?tab=readme-ov-file#usage
and https://github.com/google/go-containerregistry/tree/main/pkg/authn#helpers
for examples.

Previously, the authn-code would only look at the `credsStore` if there
was a specific host maching in `auths`, but lacking other authn-fields.

Now it also looks at the global `credsStore` as a fallback.

Fixes bazel-contrib#388.
@msiebuhr
Copy link
Contributor Author

msiebuhr commented Jun 7, 2024

Ugh. Copy/pasted an unassigned-variable in. Fixed, so the helper should now (properly) ask the credential-helper for credentials to the right registry. Diff from previous version:

diff --git oci/private/authn.bzl oci/private/authn.bzl
index 902fdf6..8a2f531 100644
--- oci/private/authn.bzl
+++ oci/private/authn.bzl
@@ -183,7 +183,7 @@ def _get_auth(rctx, state, registry):
 
     # look for generic credentials-store all lookups for host-specific auth fails
     if "credsStore" in config and len(pattern.keys()) == 0:
-        pattern = _fetch_auth_via_creds_helper(rctx, host_raw, config["credsStore"])
+        pattern = _fetch_auth_via_creds_helper(rctx, registry, config["credsStore"])
 
     # cache the result so that we don't do this again unnecessarily.
     state["auth"][registry] = pattern

@thesayyn thesayyn merged commit db7ecff into bazel-contrib:main Jun 7, 2024
20 checks passed
@msiebuhr msiebuhr deleted the fix-388 branch June 19, 2024 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to authenticate against ECR using amazon-ecr-credential-helper
2 participants