bake: align build metadata
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -23,13 +23,14 @@ import {Bake} from '../../src/buildx/bake';
|
|||||||
import {Context} from '../../src/context';
|
import {Context} from '../../src/context';
|
||||||
|
|
||||||
import {ExecOptions} from '@actions/exec';
|
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');
|
const fixturesDir = path.join(__dirname, '..', 'fixtures');
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-inputs-jest');
|
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-inputs-jest');
|
||||||
const tmpName = path.join(tmpDir, '.tmpname-jest');
|
const tmpName = path.join(tmpDir, '.tmpname-jest');
|
||||||
const metadata: BakeMetadata = {
|
const metadata: BuildMetadata = {
|
||||||
app: {
|
app: {
|
||||||
'buildx.build.ref': 'default/default/7frbdw1fmfozgtqavghowsepk'
|
'buildx.build.ref': 'default/default/7frbdw1fmfozgtqavghowsepk'
|
||||||
},
|
},
|
||||||
@@ -57,7 +58,7 @@ describe('resolveMetadata', () => {
|
|||||||
it('matches', async () => {
|
it('matches', async () => {
|
||||||
const bake = new Bake();
|
const bake = new Bake();
|
||||||
fs.writeFileSync(bake.getMetadataFilePath(), JSON.stringify(metadata));
|
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 {Util} from '../util';
|
||||||
|
|
||||||
import {ExecOptions} from '@actions/exec';
|
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 {
|
export interface BakeOpts {
|
||||||
buildx?: Buildx;
|
buildx?: Buildx;
|
||||||
@@ -57,7 +58,7 @@ export class Bake {
|
|||||||
return path.join(Context.tmpDir(), this.metadataFilename);
|
return path.join(Context.tmpDir(), this.metadataFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
public resolveMetadata(): BakeMetadata | undefined {
|
public resolveMetadata(): BuildMetadata | undefined {
|
||||||
const metadataFile = this.getMetadataFilePath();
|
const metadataFile = this.getMetadataFilePath();
|
||||||
if (!fs.existsSync(metadataFile)) {
|
if (!fs.existsSync(metadataFile)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
@@ -66,10 +67,10 @@ export class Bake {
|
|||||||
if (content === 'null') {
|
if (content === 'null') {
|
||||||
return undefined;
|
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) {
|
if (!metadata) {
|
||||||
metadata = this.resolveMetadata();
|
metadata = this.resolveMetadata();
|
||||||
if (!metadata) {
|
if (!metadata) {
|
||||||
|
|||||||
@@ -19,10 +19,6 @@ export interface BakeDefinition {
|
|||||||
target: Record<string, Target>;
|
target: Record<string, Target>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BakeMetadata {
|
|
||||||
[target: string]: Record<string, string>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Group {
|
export interface Group {
|
||||||
targets: Array<string>;
|
targets: Array<string>;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user