From edc7195126079bfaa9e7e85094f426ccff321519 Mon Sep 17 00:00:00 2001 From: Lucian Buzzo Date: Tue, 21 Jun 2022 12:23:19 +0100 Subject: [PATCH] Add debug logs when registry secrets are being used If you unknowingly have a `secrets.json` file that has incorrect credentials, it can be really hard to debug why you're builds will start failing with the error: ``` unauthorized: incorrect username or password ``` This change adds extra logging that will make it more obvious what's going on when you use `--debug`. Change-type: patch Signed-off-by: Lucian Buzzo --- lib/utils/compose_ts.ts | 2 ++ lib/utils/device/deploy.ts | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/lib/utils/compose_ts.ts b/lib/utils/compose_ts.ts index f9690385..797f30d2 100644 --- a/lib/utils/compose_ts.ts +++ b/lib/utils/compose_ts.ts @@ -910,6 +910,7 @@ export async function getRegistrySecrets( sdk: BalenaSDK, inputFilename?: string, ): Promise { + const logger = await Logger.getLogger(); if (inputFilename != null) { return await parseRegistrySecrets(inputFilename); } @@ -923,6 +924,7 @@ export async function getRegistrySecrets( for (const potentialPath of potentialPaths) { if (await exists(potentialPath)) { + logger.logDebug(`Found registry secrets file: ${potentialPath}`); return await parseRegistrySecrets(potentialPath); } } diff --git a/lib/utils/device/deploy.ts b/lib/utils/device/deploy.ts index 61d9c970..0845962f 100644 --- a/lib/utils/device/deploy.ts +++ b/lib/utils/device/deploy.ts @@ -530,6 +530,13 @@ async function assignDockerBuildOpts( globalLogger.logDebug(`Using ${images.length} on-device images for cache...`); + if (opts.registrySecrets && Object.keys(opts.registrySecrets).length > 0) { + globalLogger.logDebug('Using secrets for the following registries:'); + for (const registry of Object.keys(opts.registrySecrets)) { + globalLogger.logDebug(` ${registry}`); + } + } + await Promise.all( buildTasks.map(async (task: BuildTask) => { task.dockerOpts = {