1
0
Fork 0
mirror of https://github.com/docker/setup-buildx-action.git synced 2025-05-10 08:29:30 +02:00

auth support for tls endpoint

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2022-09-22 02:48:11 +02:00
parent f5bc16b105
commit 1c2ad20e10
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
8 changed files with 239 additions and 16 deletions

View file

@ -1,6 +1,8 @@
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import * as uuid from 'uuid';
import * as auth from './auth';
import * as buildx from './buildx';
import * as context from './context';
import * as docker from './docker';
@ -56,8 +58,16 @@ async function run(): Promise<void> {
context.setOutput('name', builderName);
stateHelper.setBuilderName(builderName);
const credsdir = path.join(dockerConfigHome, 'buildx', 'creds', builderName);
fs.mkdirSync(credsdir, {recursive: true});
stateHelper.setCredsDir(credsdir);
if (inputs.driver !== 'docker') {
core.startGroup(`Creating a new builder instance`);
const authOpts = auth.setCredentials(credsdir, 0, inputs.driver, inputs.endpoint);
if (authOpts.length > 0) {
inputs.driverOpts = [...inputs.driverOpts, ...authOpts];
}
const createArgs: Array<string> = ['create', '--name', builderName, '--driver', inputs.driver];
if (buildx.satisfies(buildxVersion, '>=0.3.0')) {
await context.asyncForEach(inputs.driverOpts, async driverOpt => {
@ -156,6 +166,11 @@ async function cleanup(): Promise<void> {
});
core.endGroup();
}
if (stateHelper.credsDir.length > 0 && fs.existsSync(stateHelper.credsDir)) {
core.info(`Cleaning up credentials`);
fs.rmdirSync(stateHelper.credsDir, {recursive: true});
}
}
if (!stateHelper.IsPost) {