mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix PodDistruptionBudgets not displaying on newer Kube versions (#6989)
* Add ability for KubeApi to filter server versions Signed-off-by: Sebastian Malton <sebastian@malton.name> * Update error message Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix tests Signed-off-by: Sebastian Malton <sebastian@malton.name> * Check preferred version for PodDistruptionBudgets Signed-off-by: Sebastian Malton <sebastian@malton.name> * Limit which versions can be used Signed-off-by: Sebastian Malton <sebastian@malton.name> * Make sure that details are show for all versions - Remove duplicate versioning checks since everything must go through the API anyway Signed-off-by: Sebastian Malton <sebastian@malton.name> * Remove unnecessary logger as dep Signed-off-by: Sebastian Malton <sebastian@malton.name> Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
9b001adb07
commit
591d9f30f3
5 files changed
+84
-69
No files matched your search
+33
-59
@@ -10,70 +10,44 @@ import { observer } from "mobx-react";
|
||||
import { DrawerItem } from "../drawer";
|
||||
import { Badge } from "../badge";
|
||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||
import { PodDisruptionBudget } from "../../../common/k8s-api/endpoints";
|
||||
import type { Logger } from "../../../common/logger";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import loggerInjectable from "../../../common/logger.injectable";
|
||||
import type { PodDisruptionBudget } from "../../../common/k8s-api/endpoints";
|
||||
|
||||
export interface PodDisruptionBudgetDetailsProps extends KubeObjectDetailsProps<PodDisruptionBudget> {
|
||||
}
|
||||
|
||||
interface Dependencies {
|
||||
logger: Logger;
|
||||
}
|
||||
export const PodDisruptionBudgetDetails = observer((props: PodDisruptionBudgetDetailsProps) => {
|
||||
const { object: pdb } = props;
|
||||
|
||||
@observer
|
||||
class NonInjectedPodDisruptionBudgetDetails extends React.Component<PodDisruptionBudgetDetailsProps & Dependencies> {
|
||||
|
||||
render() {
|
||||
const { object: pdb } = this.props;
|
||||
|
||||
if (!pdb) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!(pdb instanceof PodDisruptionBudget)) {
|
||||
this.props.logger.error("[PodDisruptionBudgetDetails]: passed object that is not an instanceof PodDisruptionBudget", pdb);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
const selectors = pdb.getSelectors();
|
||||
|
||||
return (
|
||||
<div className="PdbDetails">
|
||||
{selectors.length > 0 && (
|
||||
<DrawerItem name="Selector" labelsOnly>
|
||||
{
|
||||
selectors.map(label => <Badge key={label} label={label}/>)
|
||||
}
|
||||
</DrawerItem>
|
||||
)}
|
||||
|
||||
<DrawerItem name="Min Available">
|
||||
{pdb.getMinAvailable()}
|
||||
</DrawerItem>
|
||||
|
||||
<DrawerItem name="Max Unavailable">
|
||||
{pdb.getMaxUnavailable()}
|
||||
</DrawerItem>
|
||||
|
||||
<DrawerItem name="Current Healthy">
|
||||
{pdb.getCurrentHealthy()}
|
||||
</DrawerItem>
|
||||
|
||||
<DrawerItem name="Desired Healthy">
|
||||
{pdb.getDesiredHealthy()}
|
||||
</DrawerItem>
|
||||
|
||||
</div>
|
||||
);
|
||||
if (!pdb) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export const PodDisruptionBudgetDetails = withInjectables<Dependencies, PodDisruptionBudgetDetailsProps>(NonInjectedPodDisruptionBudgetDetails, {
|
||||
getProps: (di, props) => ({
|
||||
...props,
|
||||
logger: di.inject(loggerInjectable),
|
||||
}),
|
||||
const selectors = pdb.getSelectors();
|
||||
|
||||
return (
|
||||
<div className="PdbDetails">
|
||||
{selectors.length > 0 && (
|
||||
<DrawerItem name="Selector" labelsOnly>
|
||||
{selectors.map(label => <Badge key={label} label={label}/>)}
|
||||
</DrawerItem>
|
||||
)}
|
||||
|
||||
<DrawerItem name="Min Available">
|
||||
{pdb.getMinAvailable()}
|
||||
</DrawerItem>
|
||||
|
||||
<DrawerItem name="Max Unavailable">
|
||||
{pdb.getMaxUnavailable()}
|
||||
</DrawerItem>
|
||||
|
||||
<DrawerItem name="Current Healthy">
|
||||
{pdb.getCurrentHealthy()}
|
||||
</DrawerItem>
|
||||
|
||||
<DrawerItem name="Desired Healthy">
|
||||
{pdb.getDesiredHealthy()}
|
||||
</DrawerItem>
|
||||
|
||||
</div>
|
||||
);
|
||||
});
|
||||
+2
-7
@@ -6,8 +6,8 @@ import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { kubeObjectDetailItemInjectionToken } from "../kube-object-detail-item-injection-token";
|
||||
import { computed } from "mobx";
|
||||
import { PodDisruptionBudgetDetails } from "../../../+config-pod-disruption-budgets";
|
||||
import { kubeObjectMatchesToKindAndApiVersion } from "../kube-object-matches-to-kind-and-api-version";
|
||||
import currentKubeObjectInDetailsInjectable from "../../current-kube-object-in-details.injectable";
|
||||
import { PodDisruptionBudget } from "../../../../../common/k8s-api/endpoints";
|
||||
|
||||
const podDisruptionBudgetDetailItemInjectable = getInjectable({
|
||||
id: "pod-disruption-budget-detail-item",
|
||||
@@ -17,7 +17,7 @@ const podDisruptionBudgetDetailItemInjectable = getInjectable({
|
||||
|
||||
return {
|
||||
Component: PodDisruptionBudgetDetails,
|
||||
enabled: computed(() => isPodDisruptionBudget(kubeObject.value.get()?.object)),
|
||||
enabled: computed(() => kubeObject.value.get()?.object instanceof PodDisruptionBudget),
|
||||
orderNumber: 10,
|
||||
};
|
||||
},
|
||||
@@ -25,9 +25,4 @@ const podDisruptionBudgetDetailItemInjectable = getInjectable({
|
||||
injectionToken: kubeObjectDetailItemInjectionToken,
|
||||
});
|
||||
|
||||
const isPodDisruptionBudget = kubeObjectMatchesToKindAndApiVersion(
|
||||
"PodDisruptionBudget",
|
||||
["policy/v1beta1"],
|
||||
);
|
||||
|
||||
export default podDisruptionBudgetDetailItemInjectable;
|
||||
Reference in new issue
Block a user