mirror of
https://github.com/docker/actions-toolkit.git
synced 2024-11-23 03:16:09 +08:00
Merge pull request #390 from crazy-max/build-metadata
bake: align build metadata
This commit is contained in:
commit
fe9937dd36
@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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>;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user