Skip to content

Commit c5e406f

Browse files
committed
fix: Support global credsStore in docker config
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.
1 parent 3d43cb1 commit c5e406f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

e2e/pull/test.bats

+11
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,17 @@ EOF
9191
assert_success
9292
}
9393

94+
@test "global credstore" {
95+
cat > "$DOCKER_CONFIG/config.json" <<EOF
96+
{
97+
"credsStore": "oci"
98+
}
99+
EOF
100+
update_assert '{"Authorization": ["Basic dGVzdGluZzpvY2k="]}'
101+
run bazel build @empty_image//... $BAZEL_FLAGS
102+
assert_success
103+
}
104+
94105
@test "credstore misbehaves" {
95106
cat > "$DOCKER_CONFIG/config.json" <<EOF
96107
{

oci/private/authn.bzl

+4
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ def _get_auth(rctx, state, registry):
181181
"password": auth_val["password"],
182182
}
183183

184+
# look for generic credentials-store all lookups for host-specific auth fails
185+
if "credsStore" in config and len(pattern.keys()) == 0:
186+
pattern = _fetch_auth_via_creds_helper(rctx, registry, config["credsStore"])
187+
184188
# cache the result so that we don't do this again unnecessarily.
185189
state["auth"][registry] = pattern
186190

0 commit comments

Comments
 (0)