Skip to content

Commit c0f8766

Browse files
committed
Check podman installation for start dev on podman
Signed-off-by: Jessica He <jhe@redhat.com>
1 parent 4b1d92f commit c0f8766

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

src/odo.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export interface Odo {
7070
describeComponent(contextPath: string, experimental?: boolean): Promise<ComponentDescription | undefined>;
7171
analyze(contextPath: string): Promise<AnalyzeResponse[]>;
7272
canCreatePod(): Promise<boolean>;
73+
isPodmanPresent(): Promise<boolean>;
7374

7475
/**
7576
* Returns the URL of the API of the current active cluster,
@@ -343,6 +344,18 @@ export class OdoImpl implements Odo {
343344
}
344345
return false;
345346
}
347+
348+
public async isPodmanPresent(): Promise<boolean> {
349+
try {
350+
const result: cliInstance.CliExitData = await this.execute(Command.printOdoVersionJson());
351+
if ('podman' in JSON.parse(result.stdout)) {
352+
return true;
353+
}
354+
} catch {
355+
//ignore
356+
}
357+
return false;
358+
}
346359
}
347360

348361
export function getInstance(): Odo {

src/odo/command.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ export class Command {
160160
return new CommandText('odo version');
161161
}
162162

163+
static printOdoVersionJson(): CommandText {
164+
return new CommandText('odo version -o json');
165+
}
166+
163167
static odoLogout(): CommandText {
164168
return new CommandText('odo logout');
165169
}

src/openshift/component.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,16 @@ export class Component extends OpenShiftItem {
204204

205205
@vsCommand('openshift.component.dev.onPodman')
206206
static async devOnPodman(component: ComponentWorkspaceFolder) {
207-
return Component.dev(component, 'podman');
207+
if (await Component.odo.isPodmanPresent()) {
208+
return Component.dev(component, 'podman');
209+
}
210+
void window.showErrorMessage('Podman is not present in the system, please install podman on your machine and try again.', 'Install podman')
211+
.then(async (result) => {
212+
if (result === 'Install podman') {
213+
await commands.executeCommand('vscode.open', Uri.parse('https://podman.io/'));
214+
}
215+
});
216+
return;
208217
}
209218

210219
@vsCommand('openshift.component.binding.add')

0 commit comments

Comments
 (0)