From 4fde394ac16df1061b731d2d2f226850277cbce2 Mon Sep 17 00:00:00 2001 From: Josh Spicer Date: Mon, 10 Apr 2023 18:31:56 +0000 Subject: [PATCH] additional logging when overriding DOCKER_CONFIG --- src/spec-configuration/httpOCIRegistry.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/spec-configuration/httpOCIRegistry.ts b/src/spec-configuration/httpOCIRegistry.ts index 3c2bce1a1..4771e95c6 100644 --- a/src/spec-configuration/httpOCIRegistry.ts +++ b/src/spec-configuration/httpOCIRegistry.ts @@ -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()); @@ -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; }