Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bake: align build metadata #390

Merged
merged 1 commit into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions __tests__/buildx/bake.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
},
Expand Down Expand Up @@ -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);
});
});

Expand Down
9 changes: 5 additions & 4 deletions src/buildx/bake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
4 changes: 0 additions & 4 deletions src/types/buildx/bake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
}
Expand Down
Loading