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 <lucian.buzzo@gmail.com>
This commit is contained in:
Lucian Buzzo 2022-06-21 12:23:19 +01:00
parent f55dd81a19
commit edc7195126
2 changed files with 9 additions and 0 deletions

View File

@ -910,6 +910,7 @@ export async function getRegistrySecrets(
sdk: BalenaSDK,
inputFilename?: string,
): Promise<MultiBuild.RegistrySecrets> {
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);
}
}

View File

@ -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 = {