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 <fbenoit@redhat.com>
This commit is contained in:
Florent Benoit 2023-04-14 10:48:38 +02:00 committed by Florent BENOIT
parent 1d2351f7dd
commit 9e158e68d2
3 changed files with 8 additions and 4 deletions

View file

@ -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);

View file

@ -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<void> => {
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 });
},
};

View file

@ -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;