Skip to content

Commit

Permalink
fix(docker): suppress gcr.io error (#24661)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Sep 26, 2023
1 parent 0aa9981 commit 93ab46e
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions lib/modules/datasource/docker/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 93ab46e

Please sign in to comment.