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

context: only append flags if we know the driver supports them #241

Merged
merged 1 commit into from Jun 28, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions __tests__/context.test.ts
Expand Up @@ -148,6 +148,21 @@ describe('getCreateArgs', () => {
'--buildkitd-flags', '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host',
'--platform', 'linux/amd64,linux/arm64,linux/arm/v7'
]
],
[
7,
'v0.10.3',
new Map<string, string>([
['install', 'false'],
['use', 'false'],
['driver', 'unknown'],
['cleanup', 'true'],
]),
[
'create',
'--name', 'builder-9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d',
'--driver', 'unknown',
]
]
])(
'[%d] given buildx %s and %p as inputs, returns %p',
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions src/context.ts
Expand Up @@ -51,7 +51,7 @@ export async function getCreateArgs(inputs: Inputs, toolkit: Toolkit): Promise<A
await Util.asyncForEach(inputs.driverOpts, async driverOpt => {
args.push('--driver-opt', driverOpt);
});
if (inputs.driver != 'remote' && inputs.buildkitdFlags) {
if (driverSupportsFlags(inputs.driver) && inputs.buildkitdFlags) {
args.push('--buildkitd-flags', inputs.buildkitdFlags);
}
}
Expand All @@ -61,7 +61,7 @@ export async function getCreateArgs(inputs: Inputs, toolkit: Toolkit): Promise<A
if (inputs.use) {
args.push('--use');
}
if (inputs.driver != 'remote') {
if (driverSupportsFlags(inputs.driver)) {
if (inputs.config) {
args.push('--config', toolkit.buildkit.config.resolveFromFile(inputs.config));
} else if (inputs.configInline) {
Expand All @@ -85,7 +85,7 @@ export async function getAppendArgs(inputs: Inputs, node: Node, toolkit: Toolkit
await Util.asyncForEach(node['driver-opts'], async driverOpt => {
args.push('--driver-opt', driverOpt);
});
if (inputs.driver != 'remote' && node['buildkitd-flags']) {
if (driverSupportsFlags(inputs.driver) && node['buildkitd-flags']) {
args.push('--buildkitd-flags', node['buildkitd-flags']);
}
}
Expand All @@ -105,3 +105,7 @@ export async function getInspectArgs(inputs: Inputs, toolkit: Toolkit): Promise<
}
return args;
}

function driverSupportsFlags(driver: string): boolean {
return driver == '' || driver == 'docker-container' || driver == 'docker' || driver == 'kubernetes';
}