buildx: allow passing metadata file when resolving digest or refs

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2024-04-26 14:04:58 +02:00
parent 5820a0ba86
commit a99525f2f1
No known key found for this signature in database
GPG Key ID: ADE44D8C9D44FBE4
2 changed files with 15 additions and 9 deletions

View File

@ -69,11 +69,13 @@ export class Bake {
return <BakeMetadata>JSON.parse(content);
}
public resolveRefs(): Array<string> | undefined {
const metadata = this.resolveMetadata();
public resolveRefs(metadata?: BakeMetadata): Array<string> | undefined {
if (!metadata) {
metadata = this.resolveMetadata();
if (!metadata) {
return undefined;
}
}
const refs = new Array<string>();
for (const key in metadata) {
if ('buildx.build.ref' in metadata[key]) {

View File

@ -69,22 +69,26 @@ export class Build {
return <BuildMetadata>JSON.parse(content);
}
public resolveRef(): string | undefined {
const metadata = this.resolveMetadata();
public resolveRef(metadata?: BuildMetadata): string | undefined {
if (!metadata) {
metadata = this.resolveMetadata();
if (!metadata) {
return undefined;
}
}
if ('buildx.build.ref' in metadata) {
return metadata['buildx.build.ref'];
}
return undefined;
}
public resolveDigest(): string | undefined {
const metadata = this.resolveMetadata();
public resolveDigest(metadata?: BuildMetadata): string | undefined {
if (!metadata) {
metadata = this.resolveMetadata();
if (!metadata) {
return undefined;
}
}
if ('containerimage.digest' in metadata) {
return metadata['containerimage.digest'];
}