buildx(build): handle domain when checking git auth token secret
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -348,10 +348,11 @@ describe('resolveAttestationAttrs', () => {
|
|||||||
describe('hasGitAuthTokenSecret', () => {
|
describe('hasGitAuthTokenSecret', () => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
test.each([
|
test.each([
|
||||||
[['A_SECRET=abcdef0123456789'], false],
|
[['A_SECRET=abcdef0123456789'], undefined, false],
|
||||||
[['GIT_AUTH_TOKEN=abcdefghijklmno=0123456789'], true],
|
[['GIT_AUTH_TOKEN=abcdefghijklmno=0123456789'], undefined, true],
|
||||||
])('given %p secret', async (kvp: Array<string>, expected: boolean) => {
|
[['GIT_AUTH_TOKEN.github.com=abcdefghijklmno=0123456789'], 'github.com', true],
|
||||||
expect(Build.hasGitAuthTokenSecret(kvp)).toBe(expected);
|
])('given %p secret', async (kvp: Array<string>, domain: string | undefined, expected: boolean) => {
|
||||||
|
expect(Build.hasGitAuthTokenSecret(kvp, domain)).toBe(expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -310,9 +310,11 @@ export class Build {
|
|||||||
return res.join(',');
|
return res.join(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static hasGitAuthTokenSecret(secrets: string[]): boolean {
|
public static hasGitAuthTokenSecret(secrets: string[], domain?: string): boolean {
|
||||||
for (const secret of secrets) {
|
for (const secret of secrets) {
|
||||||
if (secret.startsWith('GIT_AUTH_TOKEN=')) {
|
if (domain && secret.startsWith(`GIT_AUTH_TOKEN.${domain}=`)) {
|
||||||
|
return true;
|
||||||
|
} else if (secret.startsWith('GIT_AUTH_TOKEN=')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user