From 873ec033fe9b82e13434c58de5519a52a356925e Mon Sep 17 00:00:00 2001 From: Chris Farhood Date: Thu, 12 Feb 2026 18:03:37 -0500 Subject: [PATCH] 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 Co-Authored-By: Happy --- headlamp-sealed-secrets/package-lock.json | 5 ++-- headlamp-sealed-secrets/package.json | 4 ++- .../src/lib/SealedSecretCRD.ts | 6 ++-- headlamp-sealed-secrets/src/types.ts | 4 ++- headlamp-sealed-secrets/vite.config.js | 28 +++++++++++++++++++ 5 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 headlamp-sealed-secrets/vite.config.js diff --git a/headlamp-sealed-secrets/package-lock.json b/headlamp-sealed-secrets/package-lock.json index 0957905..bd8ad62 100644 --- a/headlamp-sealed-secrets/package-lock.json +++ b/headlamp-sealed-secrets/package-lock.json @@ -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" diff --git a/headlamp-sealed-secrets/package.json b/headlamp-sealed-secrets/package.json index 4a4bd66..f078860 100644 --- a/headlamp-sealed-secrets/package.json +++ b/headlamp-sealed-secrets/package.json @@ -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" } diff --git a/headlamp-sealed-secrets/src/lib/SealedSecretCRD.ts b/headlamp-sealed-secrets/src/lib/SealedSecretCRD.ts index 2892bf1..f66778e 100644 --- a/headlamp-sealed-secrets/src/lib/SealedSecretCRD.ts +++ b/headlamp-sealed-secrets/src/lib/SealedSecretCRD.ts @@ -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, diff --git a/headlamp-sealed-secrets/src/types.ts b/headlamp-sealed-secrets/src/types.ts index f1e6978..280c604 100644 --- a/headlamp-sealed-secrets/src/types.ts +++ b/headlamp-sealed-secrets/src/types.ts @@ -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 diff --git a/headlamp-sealed-secrets/vite.config.js b/headlamp-sealed-secrets/vite.config.js new file mode 100644 index 0000000..5ecea75 --- /dev/null +++ b/headlamp-sealed-secrets/vite.config.js @@ -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; + }, + }, + }, + }, +}));