Skip to content

Commit 922550f

Browse files
committed
context: only append flags if we know the driver supports them
Background: before this change, if i tried to use GHA with an experimental driver, it would automatically append the flags `` --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host ``` even if the underlying driver did not support them. Signed-off-by: Nick Santos <[email protected]>
1 parent ecf9528 commit 922550f

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

__tests__/context.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,21 @@ describe('getCreateArgs', () => {
148148
'--buildkitd-flags', '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host',
149149
'--platform', 'linux/amd64,linux/arm64,linux/arm/v7'
150150
]
151+
],
152+
[
153+
7,
154+
'v0.10.3',
155+
new Map<string, string>([
156+
['install', 'false'],
157+
['use', 'false'],
158+
['driver', 'unknown'],
159+
['cleanup', 'true'],
160+
]),
161+
[
162+
'create',
163+
'--name', 'builder-9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d',
164+
'--driver', 'unknown',
165+
]
151166
]
152167
])(
153168
'[%d] given buildx %s and %p as inputs, returns %p',

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/context.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export async function getCreateArgs(inputs: Inputs, toolkit: Toolkit): Promise<A
5151
await Util.asyncForEach(inputs.driverOpts, async driverOpt => {
5252
args.push('--driver-opt', driverOpt);
5353
});
54-
if (inputs.driver != 'remote' && inputs.buildkitdFlags) {
54+
if (driverSupportsFlags(inputs.driver) && inputs.buildkitdFlags) {
5555
args.push('--buildkitd-flags', inputs.buildkitdFlags);
5656
}
5757
}
@@ -61,7 +61,7 @@ export async function getCreateArgs(inputs: Inputs, toolkit: Toolkit): Promise<A
6161
if (inputs.use) {
6262
args.push('--use');
6363
}
64-
if (inputs.driver != 'remote') {
64+
if (driverSupportsFlags(inputs.driver)) {
6565
if (inputs.config) {
6666
args.push('--config', toolkit.buildkit.config.resolveFromFile(inputs.config));
6767
} else if (inputs.configInline) {
@@ -85,7 +85,7 @@ export async function getAppendArgs(inputs: Inputs, node: Node, toolkit: Toolkit
8585
await Util.asyncForEach(node['driver-opts'], async driverOpt => {
8686
args.push('--driver-opt', driverOpt);
8787
});
88-
if (inputs.driver != 'remote' && node['buildkitd-flags']) {
88+
if (driverSupportsFlags(inputs.driver) && node['buildkitd-flags']) {
8989
args.push('--buildkitd-flags', node['buildkitd-flags']);
9090
}
9191
}
@@ -105,3 +105,7 @@ export async function getInspectArgs(inputs: Inputs, toolkit: Toolkit): Promise<
105105
}
106106
return args;
107107
}
108+
109+
function driverSupportsFlags(driver: string): boolean {
110+
return driver == '' || driver == 'docker-container' || driver == 'docker' || driver == 'kubernetes';
111+
}

0 commit comments

Comments
 (0)