@ -1,7 +1,6 @@
import * as uuid from 'uuid' ;
import * as core from '@actions/core' ;
import { Docker } from '@docker/actions-toolkit/lib/docker/docker' ;
import { Util } from '@docker/actions-toolkit/lib/util' ;
import { Toolkit } from '@docker/actions-toolkit/lib/toolkit' ;
@ -24,12 +23,13 @@ export interface Inputs {
append : string ;
cacheBinary : boolean ;
cleanup : boolean ;
keepState : boolean ;
}
export async function getInputs ( ) : Promise < Inputs > {
return {
version : core.getInput ( 'version' ) ,
name : await getBuilderName( core . getInput ( 'driver' ) || 'docker-container' ) ,
name : getBuilderName( core . getInput ( 'name' ) , core . getInput ( 'driver' ) || 'docker-container' ) ,
driver : core.getInput ( 'driver' ) || 'docker-container' ,
driverOpts : Util.getInputList ( 'driver-opts' , { ignoreComma : true , quote : false } ) ,
buildkitdFlags : core.getInput ( 'buildkitd-flags' ) || '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host' ,
@ -41,12 +41,17 @@ export async function getInputs(): Promise<Inputs> {
buildkitdConfigInline : core.getInput ( 'buildkitd-config-inline' ) || core . getInput ( 'config-inline' ) ,
append : core.getInput ( 'append' ) ,
cacheBinary : core.getBooleanInput ( 'cache-binary' ) ,
cleanup : core.getBooleanInput ( 'cleanup' )
cleanup : core.getBooleanInput ( 'cleanup' ) ,
keepState : core.getBooleanInput ( 'keep-state' )
} ;
}
export async function getBuilderName ( driver : string ) : Promise < string > {
return driver == 'docker' ? await Docker . context ( ) : ` builder- ${ uuid . v4 ( ) } ` ;
export function getBuilderName ( name : string , driver : string ) : string {
if ( name ) {
return name ;
}
return driver == 'docker' ? 'default' : ` builder- ${ uuid . v4 ( ) } ` ;
}
export async function getCreateArgs ( inputs : Inputs , toolkit : Toolkit ) : Promise < Array < string > > {