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,10 +69,12 @@ 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) {
return undefined;
metadata = this.resolveMetadata();
if (!metadata) {
return undefined;
}
}
const refs = new Array<string>();
for (const key in metadata) {

View File

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