Skip to content

Commit

Permalink
fix: support docker-credential-gcr
Browse files Browse the repository at this point in the history
  • Loading branch information
glebbash committed Jan 23, 2025
1 parent f3aa07c commit 69da6b0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ describe("CredentialProvider", () => {
);
});

it("should not throw when list credentials command is not implemented", async () => {
mockExec.mockImplementationOnce((command, callback) => {
return callback(new Error(), null, "list is unimplemented\n");
});

const credentials = await credentialProvider.getAuthConfig("registry", containerRuntimeConfig);

expect(credentials).toBeUndefined();
});

it("should throw when get credentials fails", async () => {
mockExecReturns(JSON.stringify({ registry: "username" }));
mockSpawnReturns(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ export abstract class CredentialProvider implements RegistryAuthLocator {

private listCredentials(providerName: string): Promise<CredentialProviderListResponse> {
return new Promise((resolve, reject) => {
exec(`${providerName} list`, (err, stdout) => {
exec(`${providerName} list`, (err, stdout, stderr) => {
if (err) {
if (stderr === "list is unimplemented\n") {
return resolve([]);
}

log.error(`An error occurred listing credentials: ${err}`);
return reject(new Error("An error occurred listing credentials"));
}
Expand Down

0 comments on commit 69da6b0

Please sign in to comment.