2020-09-03 10:23:15 -04:00
|
|
|
import * as os from 'os';
|
|
|
|
import * as core from '@actions/core';
|
|
|
|
|
|
|
|
export const osPlat: string = os.platform();
|
2020-09-05 10:30:41 -04:00
|
|
|
export const osArch: string = os.arch();
|
2020-09-03 10:23:15 -04:00
|
|
|
|
|
|
|
export interface Inputs {
|
|
|
|
version: string;
|
|
|
|
driver: string;
|
|
|
|
driverOpts: string[];
|
|
|
|
buildkitdFlags: string;
|
|
|
|
install: boolean;
|
|
|
|
use: boolean;
|
2020-09-08 09:52:09 -04:00
|
|
|
endpoint: string;
|
2020-09-03 10:23:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export async function getInputs(): Promise<Inputs> {
|
|
|
|
return {
|
|
|
|
version: core.getInput('version'),
|
|
|
|
driver: core.getInput('driver') || 'docker-container',
|
|
|
|
driverOpts: await getInputList('driver-opts', true),
|
2020-09-03 14:38:04 -04:00
|
|
|
buildkitdFlags:
|
|
|
|
core.getInput('buildkitd-flags') ||
|
|
|
|
'--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host',
|
2020-09-03 10:23:15 -04:00
|
|
|
install: /true/i.test(core.getInput('install')),
|
2020-09-06 10:37:52 -04:00
|
|
|
use: /true/i.test(core.getInput('use')),
|
2020-09-08 09:52:09 -04:00
|
|
|
endpoint: core.getInput('endpoint')
|
2020-09-03 10:23:15 -04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function getInputList(name: string, ignoreComma?: boolean): Promise<string[]> {
|
|
|
|
const items = core.getInput(name);
|
|
|
|
if (items == '') {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
return items
|
|
|
|
.split(/\r?\n/)
|
2020-09-12 17:34:53 -04:00
|
|
|
.filter(x => x)
|
|
|
|
.reduce<string[]>(
|
|
|
|
(acc, line) => acc.concat(!ignoreComma ? line.split(',').filter(x => x) : line).map(pat => pat.trim()),
|
|
|
|
[]
|
|
|
|
);
|
2020-09-03 10:23:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export const asyncForEach = async (array, callback) => {
|
|
|
|
for (let index = 0; index < array.length; index++) {
|
|
|
|
await callback(array[index], index, array);
|
|
|
|
}
|
|
|
|
};
|