From 8785275da1ac3db605311cd6fedd817e096f4947 Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Sat, 29 Jun 2024 12:00:21 +0200 Subject: [PATCH] bake: align build metadata Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- __tests__/buildx/bake.test.ts | 7 ++++--- src/buildx/bake.ts | 9 +++++---- src/types/buildx/bake.ts | 4 ---- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/__tests__/buildx/bake.test.ts b/__tests__/buildx/bake.test.ts index c4464d2..8341571 100644 --- a/__tests__/buildx/bake.test.ts +++ b/__tests__/buildx/bake.test.ts @@ -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); }); }); diff --git a/src/buildx/bake.ts b/src/buildx/bake.ts index 70165ae..8490052 100644 --- a/src/buildx/bake.ts +++ b/src/buildx/bake.ts @@ -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 JSON.parse(content); + return JSON.parse(content); } - public resolveRefs(metadata?: BakeMetadata): Array | undefined { + public resolveRefs(metadata?: BuildMetadata): Array | undefined { if (!metadata) { metadata = this.resolveMetadata(); if (!metadata) { diff --git a/src/types/buildx/bake.ts b/src/types/buildx/bake.ts index b45b329..e257dc5 100644 --- a/src/types/buildx/bake.ts +++ b/src/types/buildx/bake.ts @@ -19,10 +19,6 @@ export interface BakeDefinition { target: Record; } -export interface BakeMetadata { - [target: string]: Record; -} - export interface Group { targets: Array; }