diff --git a/artifacthub-pkg.yml b/artifacthub-pkg.yml index 9b9fb93..1c4761b 100644 --- a/artifacthub-pkg.yml +++ b/artifacthub-pkg.yml @@ -1,4 +1,4 @@ -version: 0.2.1 +version: 0.2.2 name: headlamp-polaris-plugin displayName: Polaris createdAt: "2026-02-05T19:00:00Z" @@ -28,7 +28,7 @@ maintainers: - name: cpfarhood email: "chris@farhood.org" annotations: - headlamp/plugin/archive-url: "https://github.com/cpfarhood/headlamp-polaris-plugin/releases/download/v0.2.1/headlamp-polaris-plugin-0.2.1.tar.gz" + headlamp/plugin/archive-url: "https://github.com/cpfarhood/headlamp-polaris-plugin/releases/download/v0.2.2/headlamp-polaris-plugin-0.2.2.tar.gz" headlamp/plugin/version-compat: ">=0.26" - headlamp/plugin/archive-checksum: sha256:0ee98511e23590699e623fc597c56aef6619793b0fe7dfa4bb4c21ca28b6fdaf + headlamp/plugin/archive-checksum: sha256:0000000000000000000000000000000000000000000000000000000000000000 headlamp/plugin/distro-compat: in-cluster diff --git a/package-lock.json b/package-lock.json index cece28c..503aa85 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "headlamp-polaris-plugin", - "version": "0.1.3", + "version": "0.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "headlamp-polaris-plugin", - "version": "0.1.3", + "version": "0.2.0", "devDependencies": { "@kinvolk/headlamp-plugin": "^0.13.0", "@playwright/test": "^1.58.2" diff --git a/package.json b/package.json index 99a085b..c35033d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "headlamp-polaris-plugin", - "version": "0.2.1", + "version": "0.2.2", "description": "Headlamp plugin for Fairwinds Polaris audit results", "scripts": { "start": "headlamp-plugin start", diff --git a/src/api/polaris.ts b/src/api/polaris.ts index 3f65fd7..ad8bbb1 100644 --- a/src/api/polaris.ts +++ b/src/api/polaris.ts @@ -125,11 +125,14 @@ export const INTERVAL_OPTIONS = [ { label: '30 minutes', value: 1800 }, ]; -const STORAGE_KEY = 'polaris-plugin-refresh-interval'; +const REFRESH_STORAGE_KEY = 'polaris-plugin-refresh-interval'; const DEFAULT_INTERVAL_SECONDS = 300; // 5 minutes +const URL_STORAGE_KEY = 'polaris-plugin-dashboard-url'; +const DEFAULT_DASHBOARD_URL = '/api/v1/namespaces/polaris/services/polaris-dashboard:80/proxy/'; + export function getRefreshInterval(): number { - const stored = localStorage.getItem(STORAGE_KEY); + const stored = localStorage.getItem(REFRESH_STORAGE_KEY); if (stored !== null) { const parsed = parseInt(stored, 10); if (!isNaN(parsed) && parsed > 0) { @@ -140,13 +143,26 @@ export function getRefreshInterval(): number { } export function setRefreshInterval(seconds: number): void { - localStorage.setItem(STORAGE_KEY, String(seconds)); + localStorage.setItem(REFRESH_STORAGE_KEY, String(seconds)); +} + +export function getDashboardUrl(): string { + const stored = localStorage.getItem(URL_STORAGE_KEY); + if (stored !== null && stored.trim() !== '') { + return stored.trim(); + } + return DEFAULT_DASHBOARD_URL; +} + +export function setDashboardUrl(url: string): void { + localStorage.setItem(URL_STORAGE_KEY, url.trim()); } // --- Polaris dashboard proxy URL --- -export const POLARIS_DASHBOARD_PROXY = - '/api/v1/namespaces/polaris/services/polaris-dashboard:80/proxy/'; +export function getPolarisProxyUrl(): string { + return getDashboardUrl(); +} // --- Score computation --- @@ -157,8 +173,10 @@ export function computeScore(counts: ResultCounts): number { // --- Data fetching hook --- -const POLARIS_API_PATH = - '/api/v1/namespaces/polaris/services/polaris-dashboard:80/proxy/results.json'; +function getPolarisApiPath(): string { + const baseUrl = getDashboardUrl(); + return baseUrl.endsWith('/') ? `${baseUrl}results.json` : `${baseUrl}/results.json`; +} interface PolarisDataState { data: AuditData | null; @@ -177,7 +195,7 @@ export function usePolarisData(refreshIntervalSeconds: number): PolarisDataState async function fetchData() { try { - const result: AuditData = await ApiProxy.request(POLARIS_API_PATH); + const result: AuditData = await ApiProxy.request(getPolarisApiPath()); if (!cancelled) { setData(result); setError(null); diff --git a/src/components/DashboardView.tsx b/src/components/DashboardView.tsx index fddde5f..650820c 100644 --- a/src/components/DashboardView.tsx +++ b/src/components/DashboardView.tsx @@ -26,7 +26,6 @@ function OverviewSection(props: { data: AuditData; counts: ResultCounts }) { { name: 'Pass', value: counts.pass, fill: COLORS.pass }, { name: 'Warning', value: counts.warning, fill: COLORS.warning }, { name: 'Danger', value: counts.danger, fill: COLORS.danger }, - { name: 'Skipped', value: counts.skipped, fill: COLORS.skipped }, ]; return ( @@ -51,14 +50,6 @@ function OverviewSection(props: { data: AuditData; counts: ResultCounts }) { name: 'Danger', value: {counts.danger}, }, - { - name: 'Skipped', - value: ( - - {counts.skipped} - - ), - }, ]} /> diff --git a/src/components/NamespaceDetailView.tsx b/src/components/NamespaceDetailView.tsx index b69f6a3..8884dd6 100644 --- a/src/components/NamespaceDetailView.tsx +++ b/src/components/NamespaceDetailView.tsx @@ -12,7 +12,7 @@ import { computeScore, countResultsForItems, filterResultsByNamespace, - POLARIS_DASHBOARD_PROXY, + getPolarisProxyUrl, Result, ResultCounts, } from '../api/polaris'; @@ -89,7 +89,7 @@ export default function NamespaceDetailView() { { name: 'Polaris Dashboard', value: ( - + View in Polaris Dashboard ), diff --git a/src/components/NamespacesListView.tsx b/src/components/NamespacesListView.tsx index 2b6c91e..753b6d0 100644 --- a/src/components/NamespacesListView.tsx +++ b/src/components/NamespacesListView.tsx @@ -13,7 +13,7 @@ import { countResultsForItems, filterResultsByNamespace, getNamespaces, - POLARIS_DASHBOARD_PROXY, + getPolarisProxyUrl, Result, ResultCounts, } from '../api/polaris'; @@ -102,7 +102,7 @@ function NamespaceDetailPanel({ namespace, onClose }: NamespaceDetailPanelProps) right: 0, top: 0, bottom: 0, - width: '600px', + width: '800px', backgroundColor: 'var(--background-paper, #fff)', boxShadow: '-2px 0 8px rgba(0,0,0,0.15)', overflowY: 'auto', @@ -140,7 +140,7 @@ function NamespaceDetailPanel({ namespace, onClose }: NamespaceDetailPanelProps) { name: 'Polaris Dashboard', value: ( - + View in Polaris Dashboard ), diff --git a/src/components/PolarisSettings.tsx b/src/components/PolarisSettings.tsx index be80a22..c7e3fd2 100644 --- a/src/components/PolarisSettings.tsx +++ b/src/components/PolarisSettings.tsx @@ -1,6 +1,6 @@ import { NameValueTable, SectionBox } from '@kinvolk/headlamp-plugin/lib/CommonComponents'; import React from 'react'; -import { getRefreshInterval, INTERVAL_OPTIONS, setRefreshInterval } from '../api/polaris'; +import { getDashboardUrl, getRefreshInterval, INTERVAL_OPTIONS, setDashboardUrl, setRefreshInterval } from '../api/polaris'; interface PluginSettingsProps { data?: { [key: string]: string | number | boolean }; @@ -10,13 +10,20 @@ interface PluginSettingsProps { export default function PolarisSettings(props: PluginSettingsProps) { const { data, onDataChange } = props; const currentInterval = (data?.refreshInterval as number) ?? getRefreshInterval(); + const currentUrl = (data?.dashboardUrl as string) ?? getDashboardUrl(); - function handleChange(e: React.ChangeEvent) { + function handleIntervalChange(e: React.ChangeEvent) { const seconds = Number(e.target.value); setRefreshInterval(seconds); onDataChange?.({ ...data, refreshInterval: seconds }); } + function handleUrlChange(e: React.ChangeEvent) { + const url = e.target.value; + setDashboardUrl(url); + onDataChange?.({ ...data, dashboardUrl: url }); + } + return ( + ), }, + { + name: 'Dashboard URL', + value: ( + + ), + }, ]} />