buildx: check standalone
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -6,6 +6,8 @@ import {parse} from 'csv-parse/sync';
|
|||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
import * as tmp from 'tmp';
|
import * as tmp from 'tmp';
|
||||||
|
|
||||||
|
import {Docker} from './docker';
|
||||||
|
|
||||||
export interface BuildxOpts {
|
export interface BuildxOpts {
|
||||||
standalone?: boolean;
|
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);
|
private tmpdir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-actions-toolkit-')).split(path.sep).join(path.posix.sep);
|
||||||
|
|
||||||
constructor(opts?: BuildxOpts) {
|
constructor(opts?: BuildxOpts) {
|
||||||
this.standalone = opts?.standalone ?? false;
|
this.standalone = opts?.standalone ?? this.isStandalone();
|
||||||
this.version = this.getVersion();
|
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>) {
|
public getCommand(args: Array<string>) {
|
||||||
return {
|
return {
|
||||||
command: this.standalone ? 'buildx' : 'docker',
|
command: this.standalone ? 'buildx' : 'docker',
|
||||||
|
|||||||
Reference in New Issue
Block a user