mirror of
https://gitea.com/docker/setup-buildx-action.git
synced 2024-11-22 17:39:33 +01:00
dffa64995b
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
import * as os from 'os';
|
|
import * as core from '@actions/core';
|
|
import {issueCommand} from '@actions/core/lib/command';
|
|
|
|
export const osPlat: string = os.platform();
|
|
export const osArch: string = os.arch();
|
|
|
|
export interface Inputs {
|
|
version: string;
|
|
driver: string;
|
|
driverOpts: string[];
|
|
buildkitdFlags: string;
|
|
install: boolean;
|
|
use: boolean;
|
|
endpoint: string;
|
|
config: string;
|
|
}
|
|
|
|
export async function getInputs(): Promise<Inputs> {
|
|
return {
|
|
version: core.getInput('version'),
|
|
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',
|
|
install: core.getBooleanInput('install'),
|
|
use: core.getBooleanInput('use'),
|
|
endpoint: core.getInput('endpoint'),
|
|
config: core.getInput('config')
|
|
};
|
|
}
|
|
|
|
export async function getInputList(name: string, ignoreComma?: boolean): Promise<string[]> {
|
|
const items = core.getInput(name);
|
|
if (items == '') {
|
|
return [];
|
|
}
|
|
return items
|
|
.split(/\r?\n/)
|
|
.filter(x => x)
|
|
.reduce<string[]>(
|
|
(acc, line) => acc.concat(!ignoreComma ? line.split(',').filter(x => x) : line).map(pat => pat.trim()),
|
|
[]
|
|
);
|
|
}
|
|
|
|
export const asyncForEach = async (array, callback) => {
|
|
for (let index = 0; index < array.length; index++) {
|
|
await callback(array[index], index, array);
|
|
}
|
|
};
|
|
|
|
// FIXME: Temp fix https://github.com/actions/toolkit/issues/777
|
|
export function setOutput(name: string, value: any): void {
|
|
issueCommand('set-output', {name}, value);
|
|
}
|