Skip to content

Commit 5856619

Browse files
authored
Merge pull request #222 from mgalesloot/flux/overview-status
Flux: objects without status should show as ready
2 parents fda59dc + 2604447 commit 5856619

File tree

1 file changed

+20
-23
lines changed

1 file changed

+20
-23
lines changed

flux/src/overview/index.tsx

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
StatusLabel,
99
TileChart,
1010
} from '@kinvolk/headlamp-plugin/lib/components/common';
11+
import { KubeObject } from '@kinvolk/headlamp-plugin/lib/lib/k8s/cluster';
1112
import { Accordion, AccordionDetails, AccordionSummary, Box } from '@mui/material';
1213
import { useTheme } from '@mui/material/styles';
1314
import React, { useEffect } from 'react';
@@ -405,30 +406,26 @@ function FluxOverviewChart({ resourceClass }) {
405406
return '';
406407
}
407408

408-
function getStatus(crds) {
409-
const isOciHelmRepository = resource => {
410-
return resource.kind === 'HelmRepository' && resource.spec.type === 'oci';
411-
};
412-
413-
const success = crds.filter(
414-
crd =>
415-
(crd.jsonData.status?.conditions?.some(
416-
condition => condition.type === 'Ready' && condition.status === 'True'
417-
) &&
418-
!crd.jsonData.spec?.suspend) ||
419-
isOciHelmRepository(crd.jsonData)
420-
).length;
421-
const failed = crds.filter(
422-
crd =>
423-
!crd.jsonData.spec?.suspend &&
424-
!crd.jsonData.status?.conditions?.some(
409+
function getStatus(customResources: KubeObject[]) {
410+
let success: number = 0;
411+
let failed: number = 0;
412+
let suspended: number = 0;
413+
414+
for (const resource of customResources) {
415+
if (!resource.jsonData.status) {
416+
success++;
417+
} else if (resource.jsonData.spec?.suspend) {
418+
suspended++;
419+
} else if (
420+
resource.jsonData.status.conditions?.some(
425421
condition => condition.type === 'Ready' && condition.status === 'True'
426-
) &&
427-
!crd.jsonData.spec?.suspend &&
428-
!isOciHelmRepository(crd.jsonData)
429-
).length;
430-
431-
const suspended = crds.filter(crd => crd.jsonData.spec?.suspend).length;
422+
)
423+
) {
424+
success++;
425+
} else {
426+
failed++;
427+
}
428+
}
432429

433430
return [success, failed, suspended];
434431
}

0 commit comments

Comments
 (0)