Skip to content

Commit 0c704be

Browse files
committed
frontend: runPlugin: Fix to handle static-plugins plugins
This static-plugins path for plugins was added recently, but this function did not consider it.
1 parent 3fdf114 commit 0c704be

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

frontend/src/plugin/runPlugin.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,24 @@ describe('identifyPackages', () => {
337337
expect(result).toEqual({ '@headlamp-k8s/minikube': true });
338338
});
339339

340+
test('should identify package by static-plugins path and name in production mode', () => {
341+
const result = identifyPackages(
342+
'static-plugins/headlamp_minikube',
343+
'@headlamp-k8s/minikube',
344+
false
345+
);
346+
expect(result).toEqual({ '@headlamp-k8s/minikube': true });
347+
});
348+
349+
test('should identify package by static-plugins prerelease path and name in production mode', () => {
350+
const result = identifyPackages(
351+
'static-plugins/headlamp_minikubeprerelease',
352+
'@headlamp-k8s/minikubeprerelease',
353+
false
354+
);
355+
expect(result).toEqual({ '@headlamp-k8s/minikube': true });
356+
});
357+
340358
test('should not identify package if path does not match', () => {
341359
const result = identifyPackages('plugins/other_plugin', '@headlamp-k8s/minikube', false);
342360
expect(result).toEqual({ '@headlamp-k8s/minikube': false });
@@ -376,6 +394,15 @@ describe('identifyPackages', () => {
376394
expect(result).toEqual({ '@headlamp-k8s/minikube': true });
377395
});
378396

397+
test('should handle windows paths for static-plugins', () => {
398+
const result = identifyPackages(
399+
'static-plugins\\headlamp_minikube',
400+
'@headlamp-k8s/minikube',
401+
false
402+
);
403+
expect(result).toEqual({ '@headlamp-k8s/minikube': true });
404+
});
405+
379406
test('should handle windows paths in development mode', () => {
380407
const result = identifyPackages('plugins\\minikube', '@headlamp-k8s/minikube', true);
381408
expect(result).toEqual({ '@headlamp-k8s/minikube': true });

frontend/src/plugin/runPlugin.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,18 @@ export function identifyPackages(
187187
// Normalize path for Windows compatibility
188188
const pluginPathNormalized = pluginPath
189189
.replace(/plugins[\\/]/, 'plugins/')
190+
.replace(/static-plugins[\\/]/, 'static-plugins/')
190191
.replace(/user-plugins[\\/]/, 'user-plugins/');
191192

192193
// For artifacthub installed packages, the package name is the folder name.
193194
const pluginPaths: Record<string, string[]> = {
194195
'@headlamp-k8s/minikube': [
195196
'plugins/headlamp_minikube',
196197
'user-plugins/headlamp_minikube',
198+
'static-plugins/headlamp_minikube',
197199
'plugins/headlamp_minikubeprerelease',
198200
'user-plugins/headlamp_minikubeprerelease',
201+
'static-plugins/headlamp_minikubeprerelease',
199202
],
200203
};
201204

0 commit comments

Comments
 (0)