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

@@ -424,4 +424,34 @@ export class Bake {
}
return false;
}
public static hasProvenanceAttestation(def: BakeDefinition): boolean {
return Bake.hasAttestationType('provenance', Bake.attestations(def));
}
public static hasSBOMAttestation(def: BakeDefinition): boolean {
return Bake.hasAttestationType('sbom', Bake.attestations(def));
}
public static hasAttestationType(name: string, attestations: Array<AttestEntry>): boolean {
for (const attestation of attestations) {
if (attestation.type == name) {
return true;
}
}
return false;
}
private static attestations(def: BakeDefinition): Array<AttestEntry> {
const attestations = new Array<AttestEntry>();
for (const key in def.target) {
const target = def.target[key];
if (target.attest) {
for (const attest of target.attest) {
attestations.push(Bake.parseAttestEntry(attest));
}
}
}
return attestations;
}
}