fix: use official Headlamp API instead of internal paths
The plugin was importing from internal Headlamp paths like '@kinvolk/headlamp-plugin/lib/lib/k8s/cluster' instead of using the official public API '@kinvolk/headlamp-plugin/lib'. This caused the plugin to fail loading in the browser with: "TypeError: undefined is not an object (evaluating 'Ot.KubeObject')" Changes: - Updated imports to use K8s.cluster and ApiProxy from main export - Added vite.config.js with custom globals (now obsolete with this fix) - Moved node-forge to dependencies for proper bundling The plugin now uses only the official documented Headlamp plugin API. Fixes: #[issue number if exists] Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
+3
-2
@@ -8,11 +8,13 @@
|
||||
"name": "headlamp-sealed-secrets",
|
||||
"version": "0.2.5",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"node-forge": "^1.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@iconify/react": "^6.0.2",
|
||||
"@kinvolk/headlamp-plugin": "^0.13.0",
|
||||
"@types/node-forge": "^1.3.11",
|
||||
"node-forge": "^1.3.1",
|
||||
"typedoc": "^0.28.16",
|
||||
"typedoc-plugin-markdown": "^4.10.0"
|
||||
}
|
||||
@@ -12397,7 +12399,6 @@
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.3.tgz",
|
||||
"integrity": "sha512-rLvcdSyRCyouf6jcOIPe/BgwG/d7hKjzMKOas33/pHEr6gbq18IK9zV7DiPvzsz0oBJPme6qr6H6kGZuI9/DZg==",
|
||||
"dev": true,
|
||||
"license": "(BSD-3-Clause OR GPL-2.0)",
|
||||
"engines": {
|
||||
"node": ">= 6.13.0"
|
||||
|
||||
@@ -56,11 +56,13 @@
|
||||
"overrides": {
|
||||
"typescript": "5.6.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"node-forge": "^1.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@iconify/react": "^6.0.2",
|
||||
"@kinvolk/headlamp-plugin": "^0.13.0",
|
||||
"@types/node-forge": "^1.3.11",
|
||||
"node-forge": "^1.3.1",
|
||||
"typedoc": "^0.28.16",
|
||||
"typedoc-plugin-markdown": "^4.10.0"
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
* SealedSecret Custom Resource Definition
|
||||
*/
|
||||
|
||||
import { apiFactoryWithNamespace } from '@kinvolk/headlamp-plugin/lib/lib/k8s/apiProxy';
|
||||
import { KubeObject } from '@kinvolk/headlamp-plugin/lib/lib/k8s/cluster';
|
||||
import { K8s, ApiProxy } from '@kinvolk/headlamp-plugin/lib';
|
||||
|
||||
const { apiFactoryWithNamespace } = ApiProxy;
|
||||
const { KubeObject } = K8s.cluster;
|
||||
import { AsyncResult, Err, Ok, tryCatchAsync } from '../types';
|
||||
import {
|
||||
SealedSecretInterface,
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
* TypeScript interfaces for Bitnami Sealed Secrets plugin
|
||||
*/
|
||||
|
||||
import { KubeObjectInterface } from '@kinvolk/headlamp-plugin/lib/lib/k8s/cluster';
|
||||
import { K8s } from '@kinvolk/headlamp-plugin/lib';
|
||||
|
||||
type KubeObjectInterface = K8s.cluster.KubeObjectInterface;
|
||||
|
||||
/**
|
||||
* Result type for operations that can fail
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { defineConfig, mergeConfig } from 'vite';
|
||||
import baseConfig from '@kinvolk/headlamp-plugin/config/vite.config.mjs';
|
||||
|
||||
// Override the base config to add missing externals
|
||||
export default mergeConfig(baseConfig, defineConfig({
|
||||
build: {
|
||||
rollupOptions: {
|
||||
output: {
|
||||
globals: (request) => {
|
||||
// Add the missing /lib/lib/k8s/* mappings
|
||||
if (request === '@kinvolk/headlamp-plugin/lib/lib/k8s/cluster') {
|
||||
return 'pluginLib.libk8scluster';
|
||||
}
|
||||
if (request === '@kinvolk/headlamp-plugin/lib/lib/k8s/apiProxy') {
|
||||
return 'pluginLib.libk8sapiProxy';
|
||||
}
|
||||
|
||||
// Use base config's globals function for everything else
|
||||
if (typeof baseConfig.build.rollupOptions.output.globals === 'function') {
|
||||
return baseConfig.build.rollupOptions.output.globals(request);
|
||||
}
|
||||
|
||||
return request;
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}));
|
||||
Reference in New Issue
Block a user