From 4e0794511bfb71bbf46935685935b98cf18ad4b8 Mon Sep 17 00:00:00 2001 From: David Hiendl Date: Thu, 28 Dec 2023 20:33:45 +0100 Subject: [PATCH] add debug output to mergeExistingDockerAuthJson --- dist/index.js | 10 ++++++++-- src/lib.js | 9 ++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/dist/index.js b/dist/index.js index 86361ff..c27a214 100644 --- a/dist/index.js +++ b/dist/index.js @@ -62169,10 +62169,12 @@ function mergeArgRegistryAuthJson(registryAuthJson) { function mergeExistingDockerAuthJson(registryAuthJson, targetFile) { if (!core.getBooleanInput('merge_existing_auth_json')) { + console.log('merge_existing_auth_json is disabled'); return; } if (!external_fs_.existsSync(targetFile)) { + console.log(`${targetFile} does not exist`); return; } @@ -62180,13 +62182,18 @@ function mergeExistingDockerAuthJson(registryAuthJson, targetFile) { const existingJsonStr = external_fs_.readFileSync(targetFile, {encoding: 'utf-8'}); const existingJson = JSON.parse(existingJsonStr); - if (existingJson.auths != null && typeof existingJson === 'object') { + if (existingJson.auths != null && typeof existingJson.auths === 'object') { for (const key in existingJson.auths) { + console.log(`existingJson.auths.${key}`); if (existingJson.auths.hasOwnProperty(key)) { + console.log(`existingJson.auths.${key} has own property, assigning value`); registryAuthJson.auths[key] = existingJson.auths[key]; } } } + else { + console.log('existingJson.auths is ' + typeof existingJson.auths); + } } catch (e) { console.log(`Failed to parse existing docker auth json in file: ${targetFile}"`); @@ -62478,7 +62485,6 @@ try { console.log('determined .docker/config.json location: ', dockerConfigFile); } - const registryAuthJson = {auths: {}}; mergeExistingDockerAuthJson(registryAuthJson); addCiRegistryAuth(ci_registry, registryAuthJson); diff --git a/src/lib.js b/src/lib.js index 08df9b2..3928670 100644 --- a/src/lib.js +++ b/src/lib.js @@ -62,10 +62,12 @@ export function mergeArgRegistryAuthJson(registryAuthJson) { export function mergeExistingDockerAuthJson(registryAuthJson, targetFile) { if (!core.getBooleanInput('merge_existing_auth_json')) { + console.log('merge_existing_auth_json is disabled'); return; } if (!fs.existsSync(targetFile)) { + console.log(`${targetFile} does not exist`); return; } @@ -73,13 +75,18 @@ export function mergeExistingDockerAuthJson(registryAuthJson, targetFile) { const existingJsonStr = fs.readFileSync(targetFile, {encoding: 'utf-8'}); const existingJson = JSON.parse(existingJsonStr); - if (existingJson.auths != null && typeof existingJson === 'object') { + if (existingJson.auths != null && typeof existingJson.auths === 'object') { for (const key in existingJson.auths) { + console.log(`existingJson.auths.${key}`); if (existingJson.auths.hasOwnProperty(key)) { + console.log(`existingJson.auths.${key} has own property, assigning value`); registryAuthJson.auths[key] = existingJson.auths[key]; } } } + else { + console.log('existingJson.auths is ' + typeof existingJson.auths); + } } catch (e) { console.log(`Failed to parse existing docker auth json in file: ${targetFile}"`);