From 19b79116456b90ea59113a8b2eb9dbf7ef47dbd0 Mon Sep 17 00:00:00 2001 From: Jessica He Date: Wed, 19 Jul 2023 13:05:34 -0400 Subject: [PATCH] Check podman installation for start dev on podman Signed-off-by: Jessica He --- src/odo.ts | 13 +++++++++++++ src/odo/command.ts | 4 ++++ src/openshift/component.ts | 11 ++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/odo.ts b/src/odo.ts index 337d4dcd2..cbc33fb37 100644 --- a/src/odo.ts +++ b/src/odo.ts @@ -70,6 +70,7 @@ export interface Odo { describeComponent(contextPath: string, experimental?: boolean): Promise; analyze(contextPath: string): Promise; canCreatePod(): Promise; + isPodmanPresent(): Promise; /** * Returns the URL of the API of the current active cluster, @@ -343,6 +344,18 @@ export class OdoImpl implements Odo { } return false; } + + public async isPodmanPresent(): Promise { + try { + const result: cliInstance.CliExitData = await this.execute(Command.printOdoVersionJson()); + if ('podman' in JSON.parse(result.stdout)) { + return true; + } + } catch { + //ignore + } + return false; + } } export function getInstance(): Odo { diff --git a/src/odo/command.ts b/src/odo/command.ts index 488e4b26b..78e66f618 100644 --- a/src/odo/command.ts +++ b/src/odo/command.ts @@ -160,6 +160,10 @@ export class Command { return new CommandText('odo version'); } + static printOdoVersionJson(): CommandText { + return new CommandText('odo version -o json'); + } + static odoLogout(): CommandText { return new CommandText('odo logout'); } diff --git a/src/openshift/component.ts b/src/openshift/component.ts index 98651b336..2a68af522 100644 --- a/src/openshift/component.ts +++ b/src/openshift/component.ts @@ -204,7 +204,16 @@ export class Component extends OpenShiftItem { @vsCommand('openshift.component.dev.onPodman') static async devOnPodman(component: ComponentWorkspaceFolder) { - return Component.devRunOn(component, 'podman'); + if (await Component.odo.isPodmanPresent()) { + return Component.devRunOn(component, 'podman'); + } + void window.showErrorMessage('Podman is not present in the system, please install podman on your machine and try again.', 'Install podman') + .then(async (result) => { + if (result === 'Install podman') { + await commands.executeCommand('vscode.open', Uri.parse('https://podman.io/')); + } + }); + return; } @vsCommand('openshift.component.binding.add')