bake: align build metadata

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2024-06-29 12:00:21 +02:00
parent 7bd4fed6bc
commit 8785275da1
No known key found for this signature in database
GPG Key ID: ADE44D8C9D44FBE4
3 changed files with 9 additions and 11 deletions

View File

@ -23,13 +23,14 @@ import {Bake} from '../../src/buildx/bake';
import {Context} from '../../src/context';
import {ExecOptions} from '@actions/exec';
import {BakeDefinition, BakeMetadata} from '../../src/types/buildx/bake';
import {BakeDefinition} from '../../src/types/buildx/bake';
import {BuildMetadata} from '../../src/types/buildx/build';
const fixturesDir = path.join(__dirname, '..', 'fixtures');
// prettier-ignore
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-inputs-jest');
const tmpName = path.join(tmpDir, '.tmpname-jest');
const metadata: BakeMetadata = {
const metadata: BuildMetadata = {
app: {
'buildx.build.ref': 'default/default/7frbdw1fmfozgtqavghowsepk'
},
@ -57,7 +58,7 @@ describe('resolveMetadata', () => {
it('matches', async () => {
const bake = new Bake();
fs.writeFileSync(bake.getMetadataFilePath(), JSON.stringify(metadata));
expect(bake.resolveMetadata()).toEqual(metadata as BakeMetadata);
expect(bake.resolveMetadata()).toEqual(metadata as BuildMetadata);
});
});

View File

@ -24,7 +24,8 @@ import {Exec} from '../exec';
import {Util} from '../util';
import {ExecOptions} from '@actions/exec';
import {BakeDefinition, BakeMetadata} from '../types/buildx/bake';
import {BakeDefinition} from '../types/buildx/bake';
import {BuildMetadata} from '../types/buildx/build';
export interface BakeOpts {
buildx?: Buildx;
@ -57,7 +58,7 @@ export class Bake {
return path.join(Context.tmpDir(), this.metadataFilename);
}
public resolveMetadata(): BakeMetadata | undefined {
public resolveMetadata(): BuildMetadata | undefined {
const metadataFile = this.getMetadataFilePath();
if (!fs.existsSync(metadataFile)) {
return undefined;
@ -66,10 +67,10 @@ export class Bake {
if (content === 'null') {
return undefined;
}
return <BakeMetadata>JSON.parse(content);
return <BuildMetadata>JSON.parse(content);
}
public resolveRefs(metadata?: BakeMetadata): Array<string> | undefined {
public resolveRefs(metadata?: BuildMetadata): Array<string> | undefined {
if (!metadata) {
metadata = this.resolveMetadata();
if (!metadata) {

View File

@ -19,10 +19,6 @@ export interface BakeDefinition {
target: Record<string, Target>;
}
export interface BakeMetadata {
[target: string]: Record<string, string>;
}
export interface Group {
targets: Array<string>;
}