mirror of
https://github.com/docker/setup-buildx-action.git
synced 2025-04-20 09:36:45 +00:00
driver-opt as array of inputs (renamed driver-opts)
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
f96a630d38
commit
d479e0f33a
8 changed files with 239 additions and 57 deletions
40
src/context.ts
Normal file
40
src/context.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
import * as os from 'os';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
export const osPlat: string = os.platform();
|
||||
|
||||
export interface Inputs {
|
||||
version: string;
|
||||
driver: string;
|
||||
driverOpts: string[];
|
||||
buildkitdFlags: string;
|
||||
install: boolean;
|
||||
use: boolean;
|
||||
}
|
||||
|
||||
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'),
|
||||
install: /true/i.test(core.getInput('install')),
|
||||
use: /true/i.test(core.getInput('use'))
|
||||
};
|
||||
}
|
||||
|
||||
export async function getInputList(name: string, ignoreComma?: boolean): Promise<string[]> {
|
||||
const items = core.getInput(name);
|
||||
if (items == '') {
|
||||
return [];
|
||||
}
|
||||
return items
|
||||
.split(/\r?\n/)
|
||||
.reduce<string[]>((acc, line) => acc.concat(!ignoreComma ? line.split(',') : 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);
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue