From 93ab46e37e26e1e0d48e9d9f2a19041372ca7093 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Tue, 26 Sep 2023 06:45:41 +0200 Subject: [PATCH] fix(docker): suppress gcr.io error (#24661) --- lib/modules/datasource/docker/common.ts | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/modules/datasource/docker/common.ts b/lib/modules/datasource/docker/common.ts index a91a712ff6..e6d7ba57fd 100644 --- a/lib/modules/datasource/docker/common.ts +++ b/lib/modules/datasource/docker/common.ts @@ -110,12 +110,23 @@ export async function getAuthHeaders( { registryHost, dockerRepository }, `Using google auth for Docker registry` ); - const accessToken = await getGoogleAccessToken(); - if (accessToken) { - const auth = Buffer.from( - `${'oauth2accesstoken'}:${accessToken}` - ).toString('base64'); - opts.headers = { authorization: `Basic ${auth}` }; + try { + const accessToken = await getGoogleAccessToken(); + if (accessToken) { + const auth = Buffer.from( + `${'oauth2accesstoken'}:${accessToken}` + ).toString('base64'); + opts.headers = { authorization: `Basic ${auth}` }; + } + } catch (err) /* istanbul ignore next */ { + if (err.message?.includes('Could not load the default credentials')) { + logger.once.debug( + { registryHost, dockerRepository }, + 'Could not get Google access token, using no auth' + ); + } else { + throw err; + } } } else if (opts.username && opts.password) { logger.trace( -- GitLab