buildx: check standalone

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2023-01-23 14:08:52 +01:00
parent 595e2417e8
commit 1b8e89676e
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7

View File

@ -6,6 +6,8 @@ import {parse} from 'csv-parse/sync';
import * as semver from 'semver';
import * as tmp from 'tmp';
import {Docker} from './docker';
export interface BuildxOpts {
standalone?: boolean;
}
@ -16,10 +18,22 @@ export class Buildx {
private tmpdir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-actions-toolkit-')).split(path.sep).join(path.posix.sep);
constructor(opts?: BuildxOpts) {
this.standalone = opts?.standalone ?? false;
this.standalone = opts?.standalone ?? this.isStandalone();
this.version = this.getVersion();
}
private isStandalone(): boolean {
let dockerAvailable = false;
Docker.isAvailable()
.then((res: boolean) => {
dockerAvailable = res;
})
.catch(e => {
dockerAvailable = false;
});
return dockerAvailable;
}
public getCommand(args: Array<string>) {
return {
command: this.standalone ? 'buildx' : 'docker',