Use `core.getBooleanInput`

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2021-06-22 17:25:52 +02:00
parent 93a9859764
commit 9199c83f6e
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7
3 changed files with 66 additions and 18 deletions

View File

@ -143,6 +143,10 @@ describe('getArgs', () => {
'0.4.1', '0.4.1',
new Map<string, string>([ new Map<string, string>([
['context', '.'], ['context', '.'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
['pull', 'false']
]), ]),
[ [
'buildx', 'buildx',
@ -155,6 +159,10 @@ describe('getArgs', () => {
'0.4.2', '0.4.2',
new Map<string, string>([ new Map<string, string>([
['build-args', 'MY_ARG=val1,val2,val3\nARG=val'], ['build-args', 'MY_ARG=val1,val2,val3\nARG=val'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
['pull', 'false']
]), ]),
[ [
'buildx', 'buildx',
@ -169,6 +177,10 @@ describe('getArgs', () => {
'0.4.2', '0.4.2',
new Map<string, string>([ new Map<string, string>([
['tags', 'name/app:7.4, name/app:latest'], ['tags', 'name/app:7.4, name/app:latest'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
['pull', 'false']
]), ]),
[ [
'buildx', 'buildx',
@ -184,7 +196,11 @@ describe('getArgs', () => {
new Map<string, string>([ new Map<string, string>([
['context', '.'], ['context', '.'],
['labels', 'org.opencontainers.image.title=buildkit\norg.opencontainers.image.description=concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit'], ['labels', 'org.opencontainers.image.title=buildkit\norg.opencontainers.image.description=concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit'],
['outputs', 'type=local,dest=./release-out'] ['outputs', 'type=local,dest=./release-out'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
['pull', 'false']
]), ]),
[ [
'buildx', 'buildx',
@ -199,7 +215,11 @@ describe('getArgs', () => {
'0.4.1', '0.4.1',
new Map<string, string>([ new Map<string, string>([
['context', '.'], ['context', '.'],
['platforms', 'linux/amd64,linux/arm64'] ['platforms', 'linux/amd64,linux/arm64'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
['pull', 'false']
]), ]),
[ [
'buildx', 'buildx',
@ -211,7 +231,11 @@ describe('getArgs', () => {
[ [
'0.4.1', '0.4.1',
new Map<string, string>([ new Map<string, string>([
['context', '.'] ['context', '.'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
['pull', 'false']
]), ]),
[ [
'buildx', 'buildx',
@ -225,6 +249,10 @@ describe('getArgs', () => {
new Map<string, string>([ new Map<string, string>([
['context', '.'], ['context', '.'],
['secrets', 'GIT_AUTH_TOKEN=abcdefghijklmno=0123456789'], ['secrets', 'GIT_AUTH_TOKEN=abcdefghijklmno=0123456789'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
['pull', 'false']
]), ]),
[ [
'buildx', 'buildx',
@ -238,7 +266,11 @@ describe('getArgs', () => {
'0.4.2', '0.4.2',
new Map<string, string>([ new Map<string, string>([
['github-token', 'abcdefghijklmno0123456789'], ['github-token', 'abcdefghijklmno0123456789'],
['outputs', '.'] ['outputs', '.'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
['pull', 'false']
]), ]),
[ [
'buildx', 'buildx',
@ -257,7 +289,10 @@ describe('getArgs', () => {
['secrets', 'GIT_AUTH_TOKEN=abcdefghijklmno=0123456789'], ['secrets', 'GIT_AUTH_TOKEN=abcdefghijklmno=0123456789'],
['file', './test/Dockerfile'], ['file', './test/Dockerfile'],
['builder', 'builder-git-context-2'], ['builder', 'builder-git-context-2'],
['push', 'true'] ['load', 'false'],
['no-cache', 'false'],
['push', 'true'],
['pull', 'false']
]), ]),
[ [
'buildx', 'buildx',
@ -288,7 +323,10 @@ bbbb
ccc"`], ccc"`],
['file', './test/Dockerfile'], ['file', './test/Dockerfile'],
['builder', 'builder-git-context-2'], ['builder', 'builder-git-context-2'],
['push', 'true'] ['load', 'false'],
['no-cache', 'false'],
['push', 'true'],
['pull', 'false']
]), ]),
[ [
'buildx', 'buildx',
@ -322,7 +360,10 @@ bbbb
ccc`], ccc`],
['file', './test/Dockerfile'], ['file', './test/Dockerfile'],
['builder', 'builder-git-context-2'], ['builder', 'builder-git-context-2'],
['push', 'true'] ['load', 'false'],
['no-cache', 'false'],
['push', 'true'],
['pull', 'false']
]), ]),
[ [
'buildx', 'buildx',
@ -348,7 +389,10 @@ ccc`],
['file', './test/Dockerfile'], ['file', './test/Dockerfile'],
['builder', 'builder-git-context-2'], ['builder', 'builder-git-context-2'],
['network', 'host'], ['network', 'host'],
['push', 'true'] ['load', 'false'],
['no-cache', 'false'],
['push', 'true'],
['pull', 'false']
]), ]),
[ [
'buildx', 'buildx',
@ -367,7 +411,11 @@ ccc`],
new Map<string, string>([ new Map<string, string>([
['context', '.'], ['context', '.'],
['labels', 'org.opencontainers.image.title=filter_results_top_n\norg.opencontainers.image.description=Reference implementation of operation "filter results (top-n)"'], ['labels', 'org.opencontainers.image.title=filter_results_top_n\norg.opencontainers.image.description=Reference implementation of operation "filter results (top-n)"'],
['outputs', 'type=local,dest=./release-out'] ['outputs', 'type=local,dest=./release-out'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
['pull', 'false']
]), ]),
[ [
'buildx', 'buildx',
@ -592,7 +640,7 @@ describe('setOutput', () => {
}); });
}); });
// See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67 // See: https://github.com/actions/toolkit/blob/a1b068ec31a042ff1e10a522d8fdf0b8869d53ca/packages/core/src/core.ts#L89
function getInputName(name: string): string { function getInputName(name: string): string {
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`; return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
} }

8
dist/index.js generated vendored
View File

@ -13553,13 +13553,13 @@ function getInputs(defaultContext) {
context: core.getInput('context') || defaultContext, context: core.getInput('context') || defaultContext,
file: core.getInput('file'), file: core.getInput('file'),
labels: yield getInputList('labels', true), labels: yield getInputList('labels', true),
load: /true/i.test(core.getInput('load')), load: core.getBooleanInput('load'),
network: core.getInput('network'), network: core.getInput('network'),
noCache: /true/i.test(core.getInput('no-cache')), noCache: core.getBooleanInput('no-cache'),
outputs: yield getInputList('outputs', true), outputs: yield getInputList('outputs', true),
platforms: yield getInputList('platforms'), platforms: yield getInputList('platforms'),
pull: /true/i.test(core.getInput('pull')), pull: core.getBooleanInput('pull'),
push: /true/i.test(core.getInput('push')), push: core.getBooleanInput('push'),
secrets: yield getInputList('secrets', true), secrets: yield getInputList('secrets', true),
secretFiles: yield getInputList('secret-files', true), secretFiles: yield getInputList('secret-files', true),
ssh: yield getInputList('ssh'), ssh: yield getInputList('ssh'),

View File

@ -74,13 +74,13 @@ export async function getInputs(defaultContext: string): Promise<Inputs> {
context: core.getInput('context') || defaultContext, context: core.getInput('context') || defaultContext,
file: core.getInput('file'), file: core.getInput('file'),
labels: await getInputList('labels', true), labels: await getInputList('labels', true),
load: /true/i.test(core.getInput('load')), load: core.getBooleanInput('load'),
network: core.getInput('network'), network: core.getInput('network'),
noCache: /true/i.test(core.getInput('no-cache')), noCache: core.getBooleanInput('no-cache'),
outputs: await getInputList('outputs', true), outputs: await getInputList('outputs', true),
platforms: await getInputList('platforms'), platforms: await getInputList('platforms'),
pull: /true/i.test(core.getInput('pull')), pull: core.getBooleanInput('pull'),
push: /true/i.test(core.getInput('push')), push: core.getBooleanInput('push'),
secrets: await getInputList('secrets', true), secrets: await getInputList('secrets', true),
secretFiles: await getInputList('secret-files', true), secretFiles: await getInputList('secret-files', true),
ssh: await getInputList('ssh'), ssh: await getInputList('ssh'),