Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b2cbce16c1 | |||
| c95aab3ca3 |
+3
-3
@@ -1,4 +1,4 @@
|
|||||||
version: 0.2.2
|
version: 0.2.3
|
||||||
name: headlamp-polaris-plugin
|
name: headlamp-polaris-plugin
|
||||||
displayName: Polaris
|
displayName: Polaris
|
||||||
createdAt: "2026-02-05T19:00:00Z"
|
createdAt: "2026-02-05T19:00:00Z"
|
||||||
@@ -28,7 +28,7 @@ maintainers:
|
|||||||
- name: cpfarhood
|
- name: cpfarhood
|
||||||
email: "chris@farhood.org"
|
email: "chris@farhood.org"
|
||||||
annotations:
|
annotations:
|
||||||
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/archive-url: "https://github.com/cpfarhood/headlamp-polaris-plugin/releases/download/v0.2.3/headlamp-polaris-plugin-0.2.3.tar.gz"
|
||||||
headlamp/plugin/version-compat: ">=0.26"
|
headlamp/plugin/version-compat: ">=0.26"
|
||||||
headlamp/plugin/archive-checksum: sha256:22400516eed9645e463873e7a5ab6c2dab8bfa8fca8a51bb51b0475079ca8c83
|
headlamp/plugin/archive-checksum: sha256:20f0a39450cb45258b5b8f10252a6d9ce1d6bdccd39c2347f5b316020ac2cb01
|
||||||
headlamp/plugin/distro-compat: in-cluster
|
headlamp/plugin/distro-compat: in-cluster
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "headlamp-polaris-plugin",
|
"name": "headlamp-polaris-plugin",
|
||||||
"version": "0.2.2",
|
"version": "0.2.3",
|
||||||
"description": "Headlamp plugin for Fairwinds Polaris audit results",
|
"description": "Headlamp plugin for Fairwinds Polaris audit results",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "headlamp-plugin start",
|
"start": "headlamp-plugin start",
|
||||||
|
|||||||
+42
-10
@@ -178,6 +178,10 @@ function getPolarisApiPath(): string {
|
|||||||
return baseUrl.endsWith('/') ? `${baseUrl}results.json` : `${baseUrl}/results.json`;
|
return baseUrl.endsWith('/') ? `${baseUrl}results.json` : `${baseUrl}/results.json`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isFullUrl(url: string): boolean {
|
||||||
|
return url.startsWith('http://') || url.startsWith('https://');
|
||||||
|
}
|
||||||
|
|
||||||
interface PolarisDataState {
|
interface PolarisDataState {
|
||||||
data: AuditData | null;
|
data: AuditData | null;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
@@ -195,7 +199,21 @@ export function usePolarisData(refreshIntervalSeconds: number): PolarisDataState
|
|||||||
|
|
||||||
async function fetchData() {
|
async function fetchData() {
|
||||||
try {
|
try {
|
||||||
const result: AuditData = await ApiProxy.request(getPolarisApiPath());
|
const apiPath = getPolarisApiPath();
|
||||||
|
let result: AuditData;
|
||||||
|
|
||||||
|
if (isFullUrl(apiPath)) {
|
||||||
|
// Direct fetch for full URLs
|
||||||
|
const response = await fetch(apiPath);
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
||||||
|
}
|
||||||
|
result = await response.json();
|
||||||
|
} else {
|
||||||
|
// Kubernetes proxy for relative URLs
|
||||||
|
result = await ApiProxy.request(apiPath);
|
||||||
|
}
|
||||||
|
|
||||||
if (!cancelled) {
|
if (!cancelled) {
|
||||||
setData(result);
|
setData(result);
|
||||||
setError(null);
|
setError(null);
|
||||||
@@ -203,17 +221,31 @@ export function usePolarisData(refreshIntervalSeconds: number): PolarisDataState
|
|||||||
}
|
}
|
||||||
} catch (err: unknown) {
|
} catch (err: unknown) {
|
||||||
if (cancelled) return;
|
if (cancelled) return;
|
||||||
|
const apiPath = getPolarisApiPath();
|
||||||
const status = (err as { status?: number }).status;
|
const status = (err as { status?: number }).status;
|
||||||
if (status === 403) {
|
|
||||||
setError(
|
if (isFullUrl(apiPath)) {
|
||||||
'Access denied (403). Check that your RBAC permissions allow proxying to the Polaris service.'
|
// Full URL errors
|
||||||
);
|
if (status === 403) {
|
||||||
} else if (status === 404 || status === 503) {
|
setError('Access denied (403). Check authentication and CORS configuration.');
|
||||||
setError(
|
} else if (status === 404) {
|
||||||
'Polaris dashboard not reachable. Ensure Polaris is installed in the polaris namespace.'
|
setError('Polaris dashboard not found (404). Verify the URL is correct.');
|
||||||
);
|
} else {
|
||||||
|
setError(`Failed to fetch from ${apiPath}: ${String(err)}`);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
setError(`Failed to fetch Polaris data: ${String(err)}`);
|
// Kubernetes proxy errors
|
||||||
|
if (status === 403) {
|
||||||
|
setError(
|
||||||
|
'Access denied (403). Check that your RBAC permissions allow proxying to the Polaris service.'
|
||||||
|
);
|
||||||
|
} else if (status === 404 || status === 503) {
|
||||||
|
setError(
|
||||||
|
'Polaris dashboard not reachable. Ensure Polaris is installed in the configured namespace.'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
setError(`Failed to fetch Polaris data: ${String(err)}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,19 +43,26 @@ export default function PolarisSettings(props: PluginSettingsProps) {
|
|||||||
{
|
{
|
||||||
name: 'Dashboard URL',
|
name: 'Dashboard URL',
|
||||||
value: (
|
value: (
|
||||||
<input
|
<div>
|
||||||
type="text"
|
<input
|
||||||
value={currentUrl}
|
type="text"
|
||||||
onChange={handleUrlChange}
|
value={currentUrl}
|
||||||
placeholder="/api/v1/namespaces/polaris/services/polaris-dashboard:80/proxy/"
|
onChange={handleUrlChange}
|
||||||
style={{
|
placeholder="/api/v1/namespaces/polaris/services/polaris-dashboard:80/proxy/"
|
||||||
width: '100%',
|
style={{
|
||||||
padding: '4px 8px',
|
width: '100%',
|
||||||
border: '1px solid #ccc',
|
padding: '4px 8px',
|
||||||
borderRadius: '4px',
|
border: '1px solid #ccc',
|
||||||
fontSize: '14px',
|
borderRadius: '4px',
|
||||||
}}
|
fontSize: '14px',
|
||||||
/>
|
}}
|
||||||
|
/>
|
||||||
|
<div style={{ fontSize: '12px', color: '#666', marginTop: '4px' }}>
|
||||||
|
Examples:<br />
|
||||||
|
• K8s proxy: <code>/api/v1/namespaces/polaris/services/polaris-dashboard:80/proxy/</code><br />
|
||||||
|
• Full URL: <code>https://my-polaris.example.com</code>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
|
|||||||
Reference in New Issue
Block a user