Skip to content

Commit 4fde394

Browse files
authored
additional logging when overriding DOCKER_CONFIG
1 parent 023e5a4 commit 4fde394

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/spec-configuration/httpOCIRegistry.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,11 @@ async function getCredentialFromDockerConfigOrCredentialHelper(params: CommonPar
213213
let configContainsAuth = false;
214214
try {
215215
// https://docs.docker.com/engine/reference/commandline/cli/#change-the-docker-directory
216-
const dockerConfigRootDir = process.env.DOCKER_CONFIG || path.join(os.homedir(), '.docker');
216+
const customDockerConfigPath = process.env.DOCKER_CONFIG;
217+
if (customDockerConfigPath) {
218+
output.write(`[httpOci] Environment DOCKER_CONFIG is set to '${customDockerConfigPath}'`, LogLevel.Trace);
219+
}
220+
const dockerConfigRootDir = customDockerConfigPath || path.join(os.homedir(), '.docker');
217221
const dockerConfigFilePath = path.join(dockerConfigRootDir, 'config.json');
218222
if (await isLocalFile(dockerConfigFilePath)) {
219223
const dockerConfig: DockerConfigFile = jsonc.parse((await readLocalFile(dockerConfigFilePath)).toString());
@@ -277,12 +281,14 @@ async function getCredentialFromDockerConfigOrCredentialHelper(params: CommonPar
277281
output.write(`[httpOci] Invoking platform default credential helper '${defaultCredHelper}'`, LogLevel.Trace);
278282
const auth = await getCredentialFromHelper(params, registry, defaultCredHelper);
279283
if (auth) {
284+
output.write('[httpOci] Found auth from platform default credential helper', LogLevel.Trace);
280285
return auth;
281286
}
282287
}
283288
}
284289

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

0 commit comments

Comments
 (0)