Skip to content

Commit

Permalink
additional logging when overriding DOCKER_CONFIG
Browse files Browse the repository at this point in the history
  • Loading branch information
joshspicer authored Apr 10, 2023
1 parent 023e5a4 commit 4fde394
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/spec-configuration/httpOCIRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,11 @@ async function getCredentialFromDockerConfigOrCredentialHelper(params: CommonPar
let configContainsAuth = false;
try {
// https://docs.docker.com/engine/reference/commandline/cli/#change-the-docker-directory
const dockerConfigRootDir = process.env.DOCKER_CONFIG || path.join(os.homedir(), '.docker');
const customDockerConfigPath = process.env.DOCKER_CONFIG;
if (customDockerConfigPath) {
output.write(`[httpOci] Environment DOCKER_CONFIG is set to '${customDockerConfigPath}'`, LogLevel.Trace);
}
const dockerConfigRootDir = customDockerConfigPath || path.join(os.homedir(), '.docker');
const dockerConfigFilePath = path.join(dockerConfigRootDir, 'config.json');
if (await isLocalFile(dockerConfigFilePath)) {
const dockerConfig: DockerConfigFile = jsonc.parse((await readLocalFile(dockerConfigFilePath)).toString());
Expand Down Expand Up @@ -277,12 +281,14 @@ async function getCredentialFromDockerConfigOrCredentialHelper(params: CommonPar
output.write(`[httpOci] Invoking platform default credential helper '${defaultCredHelper}'`, LogLevel.Trace);
const auth = await getCredentialFromHelper(params, registry, defaultCredHelper);
if (auth) {
output.write('[httpOci] Found auth from platform default credential helper', LogLevel.Trace);
return auth;
}
}
}

// No auth found from docker config or credential helper.
output.write(`[httpOci] No authentication credentials found for registry '${registry}' via docker config or credential helper.`, LogLevel.Trace);
return;
}

Expand Down

0 comments on commit 4fde394

Please sign in to comment.