From 9e158e68d261f0340537d4ab94492d58d0efaea9 Mon Sep 17 00:00:00 2001 From: Florent Benoit Date: Fri, 14 Apr 2023 10:48:38 +0200 Subject: [PATCH] fix: ensure PATH is correctly set for kind commands fix https://github.com/containers/podman-desktop/issues/2088 Change-Id: I0f565bafa45db5872dcdfb0950e06b03e9fe3c3e Signed-off-by: Florent Benoit --- extensions/kind/src/create-cluster.ts | 5 ++++- extensions/kind/src/extension.ts | 5 +++-- extensions/kind/src/util.ts | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/extensions/kind/src/create-cluster.ts b/extensions/kind/src/create-cluster.ts index 041840f1ab7..49620948397 100644 --- a/extensions/kind/src/create-cluster.ts +++ b/extensions/kind/src/create-cluster.ts @@ -19,7 +19,7 @@ import * as extensionApi from '@podman-desktop/api'; import * as fs from 'node:fs'; import * as path from 'node:path'; import * as os from 'node:os'; -import { runCliCommand } from './util'; +import { getKindPath, runCliCommand } from './util'; import mustache from 'mustache'; import { parseAllDocuments } from 'yaml'; @@ -112,6 +112,9 @@ export async function createCluster( // ok we need to write the file await fs.promises.writeFile(tmpFilePath, kindClusterConfig, 'utf8'); + // update PATH to include kind + env.PATH = getKindPath(); + // now execute the command to create the cluster try { await runCliCommand(kindCli, ['create', 'cluster', '--config', tmpFilePath], { env, logger }, token); diff --git a/extensions/kind/src/extension.ts b/extensions/kind/src/extension.ts index 11d4ef666eb..c7fb5a6fd64 100644 --- a/extensions/kind/src/extension.ts +++ b/extensions/kind/src/extension.ts @@ -17,7 +17,7 @@ ***********************************************************************/ import * as extensionApi from '@podman-desktop/api'; -import { detectKind, runCliCommand } from './util'; +import { detectKind, getKindPath, runCliCommand } from './util'; import { KindInstaller } from './kind-installer'; import type { CancellationToken, Logger } from '@podman-desktop/api'; import { window } from '@podman-desktop/api'; @@ -121,10 +121,11 @@ async function updateClusters(provider: extensionApi.Provider, containers: exten await extensionApi.containerEngine.stopContainer(cluster.engineId, cluster.id); }, delete: async (logger): Promise => { - const env = process.env; + const env = Object.assign({}, process.env); if (cluster.engineType === 'podman') { env['KIND_EXPERIMENTAL_PROVIDER'] = 'podman'; } + env.PATH = getKindPath(); await runCliCommand(kindCli, ['delete', 'cluster', '--name', cluster.name], { env, logger }); }, }; diff --git a/extensions/kind/src/util.ts b/extensions/kind/src/util.ts index 883f84c89cd..1446d66a771 100644 --- a/extensions/kind/src/util.ts +++ b/extensions/kind/src/util.ts @@ -49,7 +49,7 @@ export interface RunOptions { logger?: extensionApi.Logger; } -const macosExtraPath = '/usr/local/bin:/opt/homebrew/bin:/opt/local/bin'; +const macosExtraPath = '/usr/local/bin:/opt/homebrew/bin:/opt/local/bin:/opt/podman/bin'; export function getKindPath(): string { const env = process.env;