buildx(bake): funcs to check attest set in bake definition

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2025-11-26 11:08:57 +01:00
parent 764a608ae0
commit 9c05197992
2 changed files with 140 additions and 0 deletions

View File

@@ -485,3 +485,113 @@ describe('hasGitAuthTokenSecret', () => {
expect(Bake.hasGitAuthTokenSecret(def)).toEqual(expected);
});
});
describe('hasProvenanceAttestation', () => {
// prettier-ignore
test.each([
[
{
"target": {
"build": {
"attest": [
{
"type": "provenance",
"mode": "max"
}
]
},
}
} as unknown as BakeDefinition,
true
],
[
{
"target": {
"build": {
"attest": [
{
"type": "sbom"
}
]
},
}
} as unknown as BakeDefinition,
false
],
[
{
"target": {
"build": {
"attest": [
{
"type": "sbom"
},
{
"type": "provenance",
"mode": "max"
}
]
},
}
} as unknown as BakeDefinition,
true
]
])('given %o returns %p', async (def: BakeDefinition, expected: boolean) => {
expect(Bake.hasProvenanceAttestation(def)).toEqual(expected);
});
});
describe('hasSBOMAttestation', () => {
// prettier-ignore
test.each([
[
{
"target": {
"build": {
"attest": [
{
"type": "provenance",
"mode": "max"
}
]
},
}
} as unknown as BakeDefinition,
false
],
[
{
"target": {
"build": {
"attest": [
{
"type": "sbom"
}
]
},
}
} as unknown as BakeDefinition,
true
],
[
{
"target": {
"build": {
"attest": [
{
"type": "sbom"
},
{
"type": "provenance",
"mode": "max"
}
]
},
}
} as unknown as BakeDefinition,
true
]
])('given %o returns %p', async (def: BakeDefinition, expected: boolean) => {
expect(Bake.hasSBOMAttestation(def)).toEqual(expected);
});
});