bake: fix undefined output property
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -31,9 +31,14 @@ describe('parseDefinitions', () => {
|
|||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
test.each([
|
test.each([
|
||||||
[
|
[
|
||||||
[path.join(fixturesDir, 'bake.hcl')],
|
[path.join(fixturesDir, 'bake-01.hcl')],
|
||||||
['validate'],
|
['validate'],
|
||||||
path.join(fixturesDir, 'bake-validate.json')
|
path.join(fixturesDir, 'bake-01-validate.json')
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[path.join(fixturesDir, 'bake-02.hcl')],
|
||||||
|
['build'],
|
||||||
|
path.join(fixturesDir, 'bake-02-build.json')
|
||||||
]
|
]
|
||||||
])('given %p', async (sources: string[], targets: string[], out: string) => {
|
])('given %p', async (sources: string[], targets: string[], out: string) => {
|
||||||
const bake = new Bake();
|
const bake = new Bake();
|
||||||
@@ -57,6 +62,16 @@ describe('hasLocalExporter', () => {
|
|||||||
},
|
},
|
||||||
false
|
false
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"target": {
|
||||||
|
"build": {
|
||||||
|
"target": "build"
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
false
|
||||||
|
],
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"target": {
|
"target": {
|
||||||
|
|||||||
20
__tests__/fixtures/bake-02-build.json
Normal file
20
__tests__/fixtures/bake-02-build.json
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"group": {
|
||||||
|
"default": {
|
||||||
|
"targets": [
|
||||||
|
"build"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"target": {
|
||||||
|
"build": {
|
||||||
|
"context": ".",
|
||||||
|
"dockerfile": "Dockerfile",
|
||||||
|
"args": {
|
||||||
|
"BUILDKIT_CONTEXT_KEEP_GIT_DIR": "1",
|
||||||
|
"GO_VERSION": "1.20"
|
||||||
|
},
|
||||||
|
"target": "build"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
33
__tests__/fixtures/bake-02.hcl
Normal file
33
__tests__/fixtures/bake-02.hcl
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
// Copyright 2023 actions-toolkit authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
variable "GO_VERSION" {
|
||||||
|
default = "1.20"
|
||||||
|
}
|
||||||
|
|
||||||
|
target "_common" {
|
||||||
|
args = {
|
||||||
|
GO_VERSION = GO_VERSION
|
||||||
|
BUILDKIT_CONTEXT_KEEP_GIT_DIR = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
group "default" {
|
||||||
|
targets = ["build"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "build" {
|
||||||
|
inherits = ["_common"]
|
||||||
|
target = "build"
|
||||||
|
}
|
||||||
@@ -84,7 +84,9 @@ export class Bake {
|
|||||||
const exporters = new Array<string>();
|
const exporters = new Array<string>();
|
||||||
for (const key in def.target) {
|
for (const key in def.target) {
|
||||||
const target = def.target[key];
|
const target = def.target[key];
|
||||||
exporters.push(...target.output);
|
if (target.output) {
|
||||||
|
exporters.push(...target.output);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return exporters;
|
return exporters;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,22 +24,22 @@ export interface Group {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Target {
|
export interface Target {
|
||||||
args: Record<string, string>;
|
args?: Record<string, string>;
|
||||||
attest: Array<string>;
|
attest?: Array<string>;
|
||||||
'cache-from': Array<string>;
|
'cache-from'?: Array<string>;
|
||||||
'cache-to': Array<string>;
|
'cache-to'?: Array<string>;
|
||||||
context: string;
|
context: string;
|
||||||
contexts: Record<string, string>;
|
contexts?: Record<string, string>;
|
||||||
dockerfile: string;
|
dockerfile: string;
|
||||||
'dockerfile-inline': string;
|
'dockerfile-inline'?: string;
|
||||||
labels: Record<string, string>;
|
labels?: Record<string, string>;
|
||||||
'no-cache': boolean;
|
'no-cache'?: boolean;
|
||||||
'no-cache-filter': Array<string>;
|
'no-cache-filter'?: Array<string>;
|
||||||
output: Array<string>;
|
output?: Array<string>;
|
||||||
platforms: Array<string>;
|
platforms?: Array<string>;
|
||||||
pull: boolean;
|
pull?: boolean;
|
||||||
secret: Array<string>;
|
secret?: Array<string>;
|
||||||
ssh: Array<string>;
|
ssh?: Array<string>;
|
||||||
tags: Array<string>;
|
tags?: Array<string>;
|
||||||
target: string;
|
target?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user