Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,8 @@ async function startElectron() {
console.info('App starting...');
// add run cmd consent for aks-desktop to avoid consent dialogs for the aks-desktop plugin
addRunCmdConsent({ name: 'aks-desktop' });
// add run cmd consent for az-auth to avoid consent dialogs for the az-auth plugin
addRunCmdConsent({ name: 'az-auth' });
addRunCmdConsent({ name: 'ai-assistant' });

// Increase max listeners to prevent false positive warnings
Expand Down
3 changes: 2 additions & 1 deletion app/electron/plugin-management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,8 @@ function validPluginBinFolder(folder: string): boolean {
return (
Comment thread
sniok marked this conversation as resolved.
folder === 'headlamp_minikube' ||
folder === 'headlamp_minikubeprerelease' ||
folder === 'aks-desktop'
folder === 'aks-desktop' ||
folder === 'az-auth'
);
}

Expand Down
7 changes: 7 additions & 0 deletions app/electron/runCmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ const COMMANDS_WITH_CONSENT = {
'kubectl top',
'kubectl config',
],
az_auth: ['scriptjs az-auth/azure-api.js'],
headlamp_ai_assistant: ['gh auth', 'az account', 'az cognitiveservices'],
ai_assistant: ['gh auth', 'az account', 'az cognitiveservices'],
};
Expand Down Expand Up @@ -184,6 +185,11 @@ export function addRunCmdConsent(pluginInfo: { name: string }): void {
commands = COMMANDS_WITH_CONSENT.aks_desktop;
}

const pluginIsAzAuth = pluginInfo.name === 'az-auth';
if (pluginIsAzAuth) {
commands = COMMANDS_WITH_CONSENT.az_auth;
}

Comment thread
sniok marked this conversation as resolved.
const pluginIsAiAssistant = pluginInfo.name === 'ai-assistant';
if (pluginIsAiAssistant) {
commands = COMMANDS_WITH_CONSENT.ai_assistant;
Expand Down Expand Up @@ -489,6 +495,7 @@ export function setupRunCmdHandlers(mainWindow: BrowserWindow | null, ipcMain: E
'runCmd-scriptjs-minikube/manage-minikube.js': cryptoRandom(),
'runCmd-scriptjs-headlamp_minikube/manage-minikube.js': cryptoRandom(),
'runCmd-scriptjs-headlamp_minikubeprerelease/manage-minikube.js': cryptoRandom(),
'runCmd-scriptjs-az-auth/azure-api.js': cryptoRandom(),
'runCmd-az': cryptoRandom(),
'runCmd-kubectl': cryptoRandom(),
'runCmd-gh': cryptoRandom(),
Expand Down
26 changes: 26 additions & 0 deletions frontend/src/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,11 @@ export async function fetchAndExecutePlugins(
secretsToReturn['runCmd-kubectl'] = secrets['runCmd-kubectl'];
}

if (isPackage['az-auth']) {
secretsToReturn['runCmd-scriptjs-az-auth/azure-api.js'] =
secrets['runCmd-scriptjs-az-auth/azure-api.js'];
}

if (isPackage['ai-assistant']) {
secretsToReturn['runCmd-gh'] = secrets['runCmd-gh'];
secretsToReturn['runCmd-az'] = secrets['runCmd-az'];
Expand Down Expand Up @@ -706,6 +711,27 @@ export async function fetchAndExecutePlugins(
];
}

if (isPackage['az-auth']) {
function pluginRunCommand(
command: 'scriptjs',
args: string[],
options: {}
): ReturnType<typeof internalRunCommand> {
return internalRunCommand(
command,
args,
options,
allowedPermissions,
pluginDesktopApiSend,
pluginDesktopApiReceive
);
}
return [
['pluginRunCommand', 'pluginPath'],
[pluginRunCommand, pluginPath],
];
}

if (isPackage['ai-assistant']) {
function pluginRunCommand(
command: 'gh' | 'az',
Expand Down
Loading
Loading