mirror of
https://github.com/docker/login-action.git
synced 2026-11-16 14:04:59 +08:00
use the registry host for the scoped buildx config dir
scopeToConfigDir joined the registry as given onto the Buildx config dir. For a registry given as a URL this produced config/https:/<host>/<scope>, and Buildx parses the first path element as the registry host, so it never finds these credentials. ECR always hits this: loginECR logs in to the proxy endpoint returned by GetAuthorizationToken, which is a URL (https://<id>.dkr.ecr.<region>.amazonaws.com), so a scoped ECR login wrote its credentials to a directory Buildx does not read, and logout looked in a different directory than login wrote to. Drop the URL scheme and trailing slashes before building the path. Assisted-By: Claude Signed-off-by: breken-ai <312387581+breken-ai@users.noreply.github.com>
This commit is contained in:
parent
783ae9cac5
commit
53ae646628
5 changed files with 54 additions and 7 deletions
|
|
@ -77,8 +77,11 @@ export function scopeToConfigDir(registry: string, scope?: string): string {
|
|||
if (scopeDisabled() || !scope || scope === '') {
|
||||
return '';
|
||||
}
|
||||
// Buildx looks up scoped credentials by registry host, so drop any URL
|
||||
// scheme (e.g. the https:// in AWS ECR proxy endpoints) and trailing slash.
|
||||
const registryHost = registry.replace(/^[a-z][a-z0-9+.-]*:\/\//i, '').replace(/\/+$/, '');
|
||||
const configRoot = path.resolve(Buildx.configDir, 'config');
|
||||
const registryDir = path.resolve(configRoot, registry === 'docker.io' ? 'registry-1.docker.io' : registry);
|
||||
const registryDir = path.resolve(configRoot, registryHost === 'docker.io' ? 'registry-1.docker.io' : registryHost);
|
||||
if (!isChildPath(configRoot, registryDir)) {
|
||||
throw new Error(`Invalid registry '${registry}': resolved config path escapes the Buildx config directory`);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue