Compare commits
8 Commits
v0.1.0-bet
...
v0.1.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c60cad840 | ||
|
|
847887b312 | ||
|
|
d9984214c9 | ||
|
|
33b4390bc2 | ||
|
|
5e8f679709 | ||
|
|
f288f4f7ea | ||
|
|
cb9121174a | ||
|
|
464dfbe1ec |
@@ -79,9 +79,15 @@ describe('getInputList', () => {
|
|||||||
expect(res).toEqual(['user/app:cache', 'type=local,src=path/to/dir']);
|
expect(res).toEqual(['user/app:cache', 'type=local,src=path/to/dir']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('do not escape surrounding quotes', async () => {
|
||||||
|
setInput('driver-opts', `"env.no_proxy=localhost,127.0.0.1,.mydomain"`);
|
||||||
|
const res = Util.getInputList('driver-opts', {ignoreComma: true, quote: false});
|
||||||
|
expect(res).toEqual(['"env.no_proxy=localhost,127.0.0.1,.mydomain"']);
|
||||||
|
});
|
||||||
|
|
||||||
it('escape surrounding quotes', async () => {
|
it('escape surrounding quotes', async () => {
|
||||||
setInput('platforms', 'linux/amd64\n"linux/arm64,linux/arm/v7"');
|
setInput('platforms', 'linux/amd64\n"linux/arm64,linux/arm/v7"');
|
||||||
const res = Util.getInputList('platforms', {escapeQuotes: true});
|
const res = Util.getInputList('platforms');
|
||||||
expect(res).toEqual(['linux/amd64', 'linux/arm64', 'linux/arm/v7']);
|
expect(res).toEqual(['linux/amd64', 'linux/arm64', 'linux/arm/v7']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ export interface BuildKitOpts {
|
|||||||
export class BuildKit {
|
export class BuildKit {
|
||||||
private readonly context: Context;
|
private readonly context: Context;
|
||||||
private readonly buildx: Buildx;
|
private readonly buildx: Buildx;
|
||||||
private containerNamePrefix = 'buildx_buildkit_';
|
|
||||||
|
|
||||||
public readonly config: Config;
|
public readonly config: Config;
|
||||||
|
|
||||||
@@ -67,7 +66,7 @@ export class BuildKit {
|
|||||||
|
|
||||||
private async getVersionWithinImage(nodeName: string): Promise<string> {
|
private async getVersionWithinImage(nodeName: string): Promise<string> {
|
||||||
return exec
|
return exec
|
||||||
.getExecOutput(`docker`, ['inspect', '--format', '{{.Config.Image}}', `${this.containerNamePrefix}${nodeName}`], {
|
.getExecOutput(`docker`, ['inspect', '--format', '{{.Config.Image}}', `${Buildx.containerNamePrefix}${nodeName}`], {
|
||||||
ignoreReturnCode: true,
|
ignoreReturnCode: true,
|
||||||
silent: true
|
silent: true
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import * as core from '@actions/core';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
|
|
||||||
@@ -36,6 +37,7 @@ export class Buildx {
|
|||||||
|
|
||||||
public readonly inputs: Inputs;
|
public readonly inputs: Inputs;
|
||||||
public readonly standalone: boolean;
|
public readonly standalone: boolean;
|
||||||
|
public static readonly containerNamePrefix = 'buildx_buildkit_';
|
||||||
|
|
||||||
constructor(opts: BuildxOpts) {
|
constructor(opts: BuildxOpts) {
|
||||||
this.context = opts.context;
|
this.context = opts.context;
|
||||||
@@ -122,9 +124,12 @@ export class Buildx {
|
|||||||
public async versionSatisfies(range: string, version?: string): Promise<boolean> {
|
public async versionSatisfies(range: string, version?: string): Promise<boolean> {
|
||||||
const ver = version ?? (await this.version);
|
const ver = version ?? (await this.version);
|
||||||
if (!ver) {
|
if (!ver) {
|
||||||
|
core.debug(`Buildx.versionSatisfies false: undefined version`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return semver.satisfies(ver, range) || /^[0-9a-f]{7}$/.exec(ver) !== null;
|
const res = semver.satisfies(ver, range) || /^[0-9a-f]{7}$/.exec(ver) !== null;
|
||||||
|
core.debug(`Buildx.versionSatisfies ${ver} statisfies ${range}: ${res}`);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static resolveCertsDriverOpts(driver: string, endpoint: string, cert: Cert): Array<string> {
|
public static resolveCertsDriverOpts(driver: string, endpoint: string, cert: Cert): Array<string> {
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ export class Install {
|
|||||||
} else {
|
} else {
|
||||||
vspec = await Git.getRemoteSha(repo, ref);
|
vspec = await Git.getRemoteSha(repo, ref);
|
||||||
}
|
}
|
||||||
core.debug(`Tool version spec ${vspec}`);
|
core.debug(`Install.build: tool version spec ${vspec}`);
|
||||||
|
|
||||||
let toolPath: string;
|
let toolPath: string;
|
||||||
toolPath = tc.find('buildx', vspec);
|
toolPath = tc.find('buildx', vspec);
|
||||||
@@ -112,16 +112,16 @@ export class Install {
|
|||||||
|
|
||||||
let buildStandalone = false;
|
let buildStandalone = false;
|
||||||
if (this.standalone && buildxStandaloneFound) {
|
if (this.standalone && buildxStandaloneFound) {
|
||||||
core.debug(`Buildx standalone found, build with it`);
|
core.debug(`Install.buildCommand: Buildx standalone found, build with it`);
|
||||||
buildStandalone = true;
|
buildStandalone = true;
|
||||||
} else if (!this.standalone && buildxPluginFound) {
|
} else if (!this.standalone && buildxPluginFound) {
|
||||||
core.debug(`Buildx plugin found, build with it`);
|
core.debug(`Install.buildCommand: Buildx plugin found, build with it`);
|
||||||
buildStandalone = false;
|
buildStandalone = false;
|
||||||
} else if (buildxStandaloneFound) {
|
} else if (buildxStandaloneFound) {
|
||||||
core.debug(`Buildx plugin not found, but standalone found so trying to build with it`);
|
core.debug(`Install.buildCommand: Buildx plugin not found, but standalone found so trying to build with it`);
|
||||||
buildStandalone = true;
|
buildStandalone = true;
|
||||||
} else if (buildxPluginFound) {
|
} else if (buildxPluginFound) {
|
||||||
core.debug(`Buildx standalone not found, but plugin found so trying to build with it`);
|
core.debug(`Install.buildCommand: Buildx standalone not found, but plugin found so trying to build with it`);
|
||||||
buildStandalone = false;
|
buildStandalone = false;
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Neither buildx standalone or plugin have been found to build from ref ${gitContext}`);
|
throw new Error(`Neither buildx standalone or plugin have been found to build from ref ${gitContext}`);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import * as core from '@actions/core';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
|
|
||||||
export class Docker {
|
export class Docker {
|
||||||
@@ -32,21 +33,25 @@ export class Docker {
|
|||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
|
core.debug(`Docker.isAvailable error: ${res.stderr}`);
|
||||||
dockerAvailable = false;
|
dockerAvailable = false;
|
||||||
} else {
|
} else {
|
||||||
|
core.debug(`Docker.isAvailable ok`);
|
||||||
dockerAvailable = res.exitCode == 0;
|
dockerAvailable = res.exitCode == 0;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
core.debug(`Docker.isAvailable failed: ${error}`);
|
||||||
dockerAvailable = false;
|
dockerAvailable = false;
|
||||||
});
|
});
|
||||||
return dockerAvailable;
|
return dockerAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async printVersion(standalone?: boolean) {
|
public static async printVersion(standalone?: boolean): Promise<void> {
|
||||||
const noDocker = standalone ?? !Docker.isAvailable;
|
const noDocker = standalone ?? !Docker.isAvailable;
|
||||||
if (noDocker) {
|
if (noDocker) {
|
||||||
|
core.debug('Docker.printVersion: Docker is not available, skipping.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await exec.exec('docker', ['version'], {
|
await exec.exec('docker', ['version'], {
|
||||||
@@ -54,9 +59,10 @@ export class Docker {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async printInfo(standalone?: boolean) {
|
public static async printInfo(standalone?: boolean): Promise<void> {
|
||||||
const noDocker = standalone ?? !Docker.isAvailable;
|
const noDocker = standalone ?? !Docker.isAvailable;
|
||||||
if (noDocker) {
|
if (noDocker) {
|
||||||
|
core.debug('Docker.printInfo: Docker is not available, skipping.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await exec.exec('docker', ['info'], {
|
await exec.exec('docker', ['info'], {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
import {Context} from './context';
|
import {Context} from './context';
|
||||||
import {Buildx} from './buildx/buildx';
|
import {Buildx} from './buildx/buildx';
|
||||||
import {Install} from './buildx/install';
|
import {Install} from './buildx/install';
|
||||||
|
import {Builder} from './buildx/builder';
|
||||||
import {BuildKit} from './buildkit/buildkit';
|
import {BuildKit} from './buildkit/buildkit';
|
||||||
import {GitHub} from './github';
|
import {GitHub} from './github';
|
||||||
|
|
||||||
@@ -33,6 +34,7 @@ export class Toolkit {
|
|||||||
public github: GitHub;
|
public github: GitHub;
|
||||||
public buildx: Buildx;
|
public buildx: Buildx;
|
||||||
public buildxInstall: Install;
|
public buildxInstall: Install;
|
||||||
|
public builder: Builder;
|
||||||
public buildkit: BuildKit;
|
public buildkit: BuildKit;
|
||||||
|
|
||||||
constructor(opts: ToolkitOpts = {}) {
|
constructor(opts: ToolkitOpts = {}) {
|
||||||
@@ -40,6 +42,7 @@ export class Toolkit {
|
|||||||
this.github = new GitHub({token: opts.githubToken});
|
this.github = new GitHub({token: opts.githubToken});
|
||||||
this.buildx = new Buildx({context: this.context});
|
this.buildx = new Buildx({context: this.context});
|
||||||
this.buildxInstall = new Install({context: this.context, standalone: this.buildx.standalone});
|
this.buildxInstall = new Install({context: this.context, standalone: this.buildx.standalone});
|
||||||
|
this.builder = new Builder({context: this.context, buildx: this.buildx});
|
||||||
this.buildkit = new BuildKit({context: this.context, buildx: this.buildx});
|
this.buildkit = new BuildKit({context: this.context, buildx: this.buildx});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import {parse} from 'csv-parse/sync';
|
|||||||
|
|
||||||
export interface InputListOpts {
|
export interface InputListOpts {
|
||||||
ignoreComma?: boolean;
|
ignoreComma?: boolean;
|
||||||
escapeQuotes?: boolean;
|
quote?: string | boolean | Buffer | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Util {
|
export class Util {
|
||||||
@@ -37,7 +37,7 @@ export class Util {
|
|||||||
comment: '#',
|
comment: '#',
|
||||||
relaxColumnCount: true,
|
relaxColumnCount: true,
|
||||||
skipEmptyLines: true,
|
skipEmptyLines: true,
|
||||||
quote: opts?.escapeQuotes ?? `"`
|
quote: opts?.quote
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const record of records as Array<string[]>) {
|
for (const record of records as Array<string[]>) {
|
||||||
|
|||||||
Reference in New Issue
Block a user