Skip to content

Commit 2707872

Browse files
authored
Merge pull request #2991 from headlamp-k8s/extra-artifact-hub-tarballs
Install platform-specific tarballs for plugins
2 parents a578022 + cf444c5 commit 2707872

File tree

7 files changed

+1085
-75
lines changed

7 files changed

+1085
-75
lines changed

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/electron/preload.js
99
/electron/windowSize.js
1010
/electron/plugin-management.js
11+
/electron/plugin-management.test.js
1112
/electron/runCmd.js
1213
electron/windowSize.test.js
1314
electron/env-paths.js
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
version: 0.1.0
2+
name: headlamp_minikube
3+
displayName: Minikube
4+
createdAt: '2024-11-08T10:00:00Z'
5+
logoURL: 'https://minikube.sigs.k8s.io/images/logo/logo.png'
6+
description: A Headlamp plugin for managing Minikube clusters
7+
annotations:
8+
headlamp/plugin/archive-url: 'https://github.com/headlamp-k8s/plugins/releases/download/example-change-logo-0.0.1/change-logo-0.0.1.tar.gz'
9+
headlamp/plugin/archive-checksum: 'SHA256:8a2a23d116fe175b4350ffc6cc259781ed98d943f932e30fc5c8fe4e07b86e89'
10+
headlamp/plugin/version-compat: '>=0.30'
11+
headlamp/plugin/distro-compat: 'in-cluster,web,docker-desktop,desktop'
12+
headlamp/plugin/extra-files/0/url: 'https://github.com/kubernetes/minikube/releases/download/v1.35.0/minikube-linux-amd64.tar.gz'
13+
headlamp/plugin/extra-files/0/checksum: 'SHA256:56da5a1a5265e2d1a315d08073e29f0793579b6bf82202cd1e297d95a54a3b2a'
14+
headlamp/plugin/extra-files/0/arch: 'linux/x64'
15+
headlamp/plugin/extra-files/0/output/minikube/output: 'minikube'
16+
headlamp/plugin/extra-files/0/output/minikube/input: 'out/minikube-linux-amd64'
17+
headlamp/plugin/extra-files/0/output/docker-machine-driver-kvm2/output: 'docker-machine-driver-kvm2'
18+
headlamp/plugin/extra-files/0/output/docker-machine-driver-kvm2/input: 'out/docker-machine-driver-kvm2'
19+
headlamp/plugin/extra-files/1/url: 'https://github.com/kubernetes/minikube/releases/download/v1.35.0/minikube-linux-arm64.tar.gz'
20+
headlamp/plugin/extra-files/1/checksum: 'SHA256:c87e39b6e408c9b156bdd87f64a4d83c0d7c3901ddf1fc5cbced60a9c203fbf7'
21+
headlamp/plugin/extra-files/1/arch: 'linux/arm64'
22+
headlamp/plugin/extra-files/1/output/minikube/output: 'minikube'
23+
headlamp/plugin/extra-files/1/output/minikube/input: 'out/minikube-linux-arm64'
24+
headlamp/plugin/extra-files/2/url: 'https://github.com/kubernetes/minikube/releases/download/v1.35.0/minikube-darwin-amd64.tar.gz'
25+
headlamp/plugin/extra-files/2/checksum: 'SHA256:e2eadd14acaeb9876b70ed2b9f1ba3931125ec4b63e166b1088abece119494ea'
26+
headlamp/plugin/extra-files/2/arch: 'darwin/x64'
27+
headlamp/plugin/extra-files/2/output/minikube/output: 'minikube'
28+
headlamp/plugin/extra-files/2/output/minikube/input: 'out/minikube-darwin-amd64'
29+
headlamp/plugin/extra-files/2/output/docker-machine-driver-hyperkit/output: 'docker-machine-driver-hyperkit'
30+
headlamp/plugin/extra-files/2/output/docker-machine-driver-hyperkit/input: 'out/docker-machine-driver-hyperkit'
31+
headlamp/plugin/extra-files/3/url: 'https://github.com/kubernetes/minikube/releases/download/v1.35.0/minikube-darwin-arm64.tar.gz'
32+
headlamp/plugin/extra-files/3/checksum: 'SHA256:05880f5b488215d865f6a391c5b52da4b84b220e53b47b333f290ce1edaa4189'
33+
headlamp/plugin/extra-files/3/arch: 'darwin/arm64'
34+
headlamp/plugin/extra-files/3/output/minikube/output: 'minikube'
35+
headlamp/plugin/extra-files/3/output/minikube/input: 'out/minikube-darwin-arm64'
36+
headlamp/plugin/extra-files/4/url: 'https://github.com/kubernetes/minikube/releases/download/v1.35.0/minikube-windows-amd64.tar.gz'
37+
headlamp/plugin/extra-files/4/checksum: 'SHA256:9b03e763c1f34ce4a25921f67782d3e95c76be0971dc7dfd21c2148ca8c03eb2'
38+
headlamp/plugin/extra-files/4/arch: 'win32/x64'
39+
headlamp/plugin/extra-files/4/output/minikube/output: 'minikube.exe'
40+
headlamp/plugin/extra-files/4/output/minikube/input: 'out/minikube-windows-amd64.exe'

app/electron/main.ts

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@ import url from 'url';
2424
import yargs from 'yargs';
2525
import { hideBin } from 'yargs/helpers';
2626
import i18n from './i18next.config';
27-
import { PluginManager } from './plugin-management';
27+
import {
28+
addToPath,
29+
ArtifactHubHeadlampPkg,
30+
defaultPluginsDir,
31+
getMatchingExtraFiles,
32+
getPluginBinDirectories,
33+
PluginManager,
34+
} from './plugin-management';
2835
import { handleRunCommand } from './runCmd';
2936
import windowSize from './windowSize';
3037

@@ -189,7 +196,6 @@ class PluginManagerEventListeners {
189196
ipcMain.on('plugin-manager', async (event, data) => {
190197
const eventData = JSON.parse(data) as Action;
191198
const { identifier, action } = eventData;
192-
193199
const updateCache = (progress: ProgressResp) => {
194200
const percentage = this.convertProgressToPercentage(progress);
195201
this.cache[identifier].progress = progress;
@@ -248,7 +254,7 @@ class PluginManagerEventListeners {
248254
controller,
249255
};
250256

251-
let pluginInfo;
257+
let pluginInfo: ArtifactHubHeadlampPkg | undefined = undefined;
252258
try {
253259
pluginInfo = await PluginManager.fetchPluginInfo(URL, { signal: controller.signal });
254260
} catch (error) {
@@ -260,14 +266,20 @@ class PluginManagerEventListeners {
260266
return { type: 'error', message: 'Failed to fetch plugin info' };
261267
}
262268

269+
const { matchingExtraFiles } = getMatchingExtraFiles(
270+
pluginInfo?.extraFiles ? pluginInfo?.extraFiles : {}
271+
);
272+
const extraUrls = matchingExtraFiles.map(file => file.url);
273+
const allUrls = [pluginInfo.archiveURL, ...extraUrls].join(', ');
274+
263275
const dialogOptions: MessageBoxOptions = {
264276
type: 'question',
265277
buttons: [i18n.t('Yes'), i18n.t('No')],
266278
defaultId: 1,
267279
title: i18n.t('Plugin Installation'),
268280
message: i18n.t('Do you want to install the plugin "{{ pluginName }}"?', { pluginName }),
269281
detail: i18n.t('You are about to install a plugin from: {{ url }}\nDo you want to proceed?', {
270-
url: pluginInfo.archiveURL,
282+
url: allUrls,
271283
}),
272284
};
273285

@@ -529,7 +541,6 @@ async function getShellEnv(): Promise<NodeJS.ProcessEnv> {
529541
};
530542

531543
const envVars = isEnvNull ? processLines('\0') : processLines('\n');
532-
533544
const mergedEnv = { ...process.env, ...envVars };
534545
return mergedEnv;
535546
} catch (error) {
@@ -1324,6 +1335,19 @@ function startElecron() {
13241335
attachServerEventHandlers(serverProcess);
13251336
}
13261337

1338+
// Also add bundled plugin bin directories to PATH
1339+
const bundledPlugins = path.join(process.resourcesPath, '.plugins');
1340+
const bundledPluginBinDirs = getPluginBinDirectories(bundledPlugins);
1341+
if (bundledPluginBinDirs.length > 0) {
1342+
addToPath(bundledPluginBinDirs, 'bundled plugin');
1343+
}
1344+
1345+
// Add the installed plugins as well
1346+
const userPluginBinDirs = getPluginBinDirectories(defaultPluginsDir());
1347+
if (userPluginBinDirs.length > 0) {
1348+
addToPath(userPluginBinDirs, 'userPluginBinDirs plugin');
1349+
}
1350+
13271351
// Finally load the frontend
13281352
mainWindow.loadURL(startUrl);
13291353
}

0 commit comments

Comments
 (0)