Skip to content

Commit

Permalink
escape surrounding quotes for platforms input
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Oct 18, 2022
1 parent 693fdd6 commit 1fb9cbd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
15 changes: 15 additions & 0 deletions __tests__/context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,21 @@ describe('getCreateArgs', () => {
'--buildkitd-flags', '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host'
]
],
[
6,
new Map<string, string>([
['install', 'false'],
['use', 'false'],
['platforms', 'linux/amd64\n"linux/arm64,linux/arm/v7"'],
]),
[
'create',
'--name', 'builder-9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d',
'--driver', 'docker-container',
'--buildkitd-flags', '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host',
'--platform', 'linux/amd64,linux/arm64,linux/arm/v7'
]
],
])(
'[%d] given %p as inputs, returns %p',
async (num: number, inputs: Map<string, string>, expected: Array<string>) => {
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.

6 changes: 3 additions & 3 deletions src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export async function getInputs(): Promise<Inputs> {
driver: core.getInput('driver') || 'docker-container',
driverOpts: await getInputList('driver-opts', true),
buildkitdFlags: core.getInput('buildkitd-flags') || '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host',
platforms: await getInputList('platforms'),
platforms: await getInputList('platforms', false, true),
install: core.getBooleanInput('install'),
use: core.getBooleanInput('use'),
endpoint: core.getInput('endpoint'),
Expand Down Expand Up @@ -118,7 +118,7 @@ export async function getInspectArgs(inputs: Inputs, buildxVersion: string): Pro
return args;
}

export async function getInputList(name: string, ignoreComma?: boolean): Promise<string[]> {
export async function getInputList(name: string, ignoreComma?: boolean, escapeQuotes?: boolean): Promise<string[]> {
const res: Array<string> = [];

const items = core.getInput(name);
Expand All @@ -132,7 +132,7 @@ export async function getInputList(name: string, ignoreComma?: boolean): Promise
comment: '#',
relaxColumnCount: true,
skipEmptyLines: true,
quote: false
quote: escapeQuotes ? `"` : false
});

for (const record of records as Array<string[]>) {
Expand Down

0 comments on commit 1fb9cbd

Please sign in to comment.