chore: Remove leading '+' on some directory names

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton committed 2023-04-26 09:26:39 -04:00
1 parent 7dff8e31a6
commit 4379edf0c7
903 files changed
+438 -438

No files matched your search

@@ -0,0 +1,117 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import React from "react";
import { PodDisruptionBudget } from "../../../../common/k8s-api/endpoints";
import { getDiForUnitTesting } from "../../../getDiForUnitTesting";
import { renderFor } from "../../test-utils/renderFor";
import { PodDisruptionBudgets } from "../pod-disruption-budgets";
import storesAndApisCanBeCreatedInjectable from "../../../stores-apis-can-be-created.injectable";
import selectedNamespacesStorageInjectable from "../../../../features/namespace-filtering/renderer/storage.injectable";
import loggerInjectable from "../../../../common/logger.injectable";
import maybeKubeApiInjectable from "../../../../common/k8s-api/maybe-kube-api.injectable";
import podDisruptionBudgetStoreInjectable from "../store.injectable";
import siblingTabsInjectable from "../../../routes/sibling-tabs.injectable";
import { Cluster } from "../../../../common/cluster/cluster";
import hostedClusterInjectable from "../../../cluster-frame-context/hosted-cluster.injectable";
import userPreferencesStateInjectable from "../../../../features/user-preferences/common/state.injectable";
import type { DiContainer } from "@ogre-tools/injectable";
describe("<PodDisruptionBudgets />", () => {
let di: DiContainer;
const getPdb = (spec: PodDisruptionBudget["spec"]): PodDisruptionBudget => new PodDisruptionBudget({
apiVersion: "policy/v1",
kind: "PodDisruptionBudget",
metadata: {
name: "my-pdb",
resourceVersion: "1",
selfLink: "/apis/policy/v1/poddistruptionbudgets/my-pdb",
uid: "1",
namespace: "default",
},
spec,
});
const getPodDisruptionBudgetStoreInjectableMock = (pdb: PodDisruptionBudget) => ({
api: {
kind: "PodDisruptionBudget",
},
getByPath: () => pdb,
getTotalCount: () => 1,
contextItems: [pdb],
pickOnlySelected: (items: any[]) => items,
isSelectedAll: () => false,
isSelected: () => true,
}) as any;
beforeEach(() => {
di = getDiForUnitTesting();
di.override(hostedClusterInjectable, () => new Cluster({
contextName: "some-context-name",
id: "some-cluster-id",
kubeConfigPath: "/some-path-to-a-kubeconfig",
}));
di.override(storesAndApisCanBeCreatedInjectable, () => true);
di.override(selectedNamespacesStorageInjectable, () => ({
get: () => ({}),
}) as any);
di.override(loggerInjectable, () => null);
di.override(maybeKubeApiInjectable, () => (() => null) as any);
di.override(siblingTabsInjectable, () => ({ get: () => [] } as any));
di.override(userPreferencesStateInjectable, () => ({
hiddenTableColumns: {
get: () => ({
has: () => false,
}),
} as any,
}));
});
describe("PDB with minAvailable 0", () => {
const pdb = getPdb(
{
minAvailable: 0,
},
);
it("should display minAvailable as 0", () => {
di.override(podDisruptionBudgetStoreInjectable, () => getPodDisruptionBudgetStoreInjectableMock(pdb));
const result = renderFor(di)(<PodDisruptionBudgets object={pdb}/>);
expect(result.container.querySelector(".TableRow .min-available")?.textContent).toEqual("0");
});
it("should display maxUnavailable as N/A", () => {
di.override(podDisruptionBudgetStoreInjectable, () => getPodDisruptionBudgetStoreInjectableMock(pdb));
const result = renderFor(di)(<PodDisruptionBudgets object={pdb}/>);
expect(result.container.querySelector(".TableRow .max-unavailable")?.textContent).toEqual("N/A");
});
});
describe("PDB with maxUnavailable 0", () => {
const pdb = getPdb(
{
maxUnavailable: 0,
},
);
it("should display minAvailable as N/A", () => {
di.override(podDisruptionBudgetStoreInjectable, () => getPodDisruptionBudgetStoreInjectableMock(pdb));
const result = renderFor(di)(<PodDisruptionBudgets object={pdb}/>);
expect(result.container.querySelector(".TableRow .min-available")?.textContent).toEqual("N/A");
});
it("should display maxUnavailable as 0", () => {
di.override(podDisruptionBudgetStoreInjectable, () => getPodDisruptionBudgetStoreInjectableMock(pdb));
const result = renderFor(di)(<PodDisruptionBudgets object={pdb}/>);
expect(result.container.querySelector(".TableRow .max-unavailable")?.textContent).toEqual("0");
});
});
});
@@ -0,0 +1,7 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
export * from "./pod-disruption-budgets";
export * from "./pod-disruption-budgets-details";
@@ -0,0 +1,7 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
.PodDisruptionBudgetDetails {
}
@@ -0,0 +1,53 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import "./pod-disruption-budgets-details.scss";
import React from "react";
import { observer } from "mobx-react";
import { DrawerItem } from "../drawer";
import { Badge } from "../badge";
import type { KubeObjectDetailsProps } from "../kube-object-details";
import type { PodDisruptionBudget } from "../../../common/k8s-api/endpoints";
export interface PodDisruptionBudgetDetailsProps extends KubeObjectDetailsProps<PodDisruptionBudget> {
}
export const PodDisruptionBudgetDetails = observer((props: PodDisruptionBudgetDetailsProps) => {
const { object: pdb } = props;
if (!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>
);
});
@@ -0,0 +1,21 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import { PodDisruptionBudgets } from "./pod-disruption-budgets";
import podDisruptionBudgetsRouteInjectable from "../../../common/front-end-routing/routes/cluster/config/pod-disruption-budgets/pod-disruption-budgets-route.injectable";
import { routeSpecificComponentInjectionToken } from "../../routes/route-specific-component-injection-token";
const podDisruptionBudgetsRouteComponentInjectable = getInjectable({
id: "pod-disruption-budgets-route-component",
instantiate: (di) => ({
route: di.inject(podDisruptionBudgetsRouteInjectable),
Component: PodDisruptionBudgets,
}),
injectionToken: routeSpecificComponentInjectionToken,
});
export default podDisruptionBudgetsRouteComponentInjectable;
@@ -0,0 +1,38 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import { computed } from "mobx";
import podDisruptionBudgetsRouteInjectable from "../../../common/front-end-routing/routes/cluster/config/pod-disruption-budgets/pod-disruption-budgets-route.injectable";
import { configSidebarItemId } from "../config/config-sidebar-items.injectable";
import { sidebarItemsInjectionToken } from "../layout/sidebar-items.injectable";
import routeIsActiveInjectable from "../../routes/route-is-active.injectable";
import navigateToPodDisruptionBudgetsInjectable from "../../../common/front-end-routing/routes/cluster/config/pod-disruption-budgets/navigate-to-pod-disruption-budgets.injectable";
const podDisruptionBudgetsSidebarItemsInjectable = getInjectable({
id: "pod-disruption-budgets-sidebar-items",
instantiate: (di) => {
const route = di.inject(podDisruptionBudgetsRouteInjectable);
const navigateToPodDisruptionBudgets = di.inject(navigateToPodDisruptionBudgetsInjectable);
const routeIsActive = di.inject(routeIsActiveInjectable, route);
return computed(() => [
{
id: "pod-disruption-budgets",
parentId: configSidebarItemId,
title: "Pod Disruption Budgets",
onClick: navigateToPodDisruptionBudgets,
isActive: routeIsActive,
isVisible: route.isEnabled,
orderNumber: 60,
},
]);
},
injectionToken: sidebarItemsInjectionToken,
});
export default podDisruptionBudgetsSidebarItemsInjectable;
@@ -0,0 +1,26 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
.PodDisruptionBudgets {
.TableCell {
&.name {
flex: 2;
}
&.warning {
@include table-cell-warning;
}
&.keys {
flex: 2.5;
}
&.age {
flex: .5;
}
}
}
@@ -0,0 +1,95 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import "./pod-disruption-budgets.scss";
import * as React from "react";
import { observer } from "mobx-react";
import type { PodDisruptionBudget } from "../../../common/k8s-api/endpoints/pod-disruption-budget.api";
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
import type { KubeObjectDetailsProps } from "../kube-object-details";
import { KubeObjectListLayout } from "../kube-object-list-layout";
import { SiblingsInTabLayout } from "../layout/siblings-in-tab-layout";
import { KubeObjectAge } from "../kube-object/age";
import type { PodDisruptionBudgetStore } from "./store";
import { withInjectables } from "@ogre-tools/injectable-react";
import podDisruptionBudgetStoreInjectable from "./store.injectable";
import { NamespaceSelectBadge } from "../namespaces/namespace-select-badge";
enum columnId {
name = "name",
namespace = "namespace",
minAvailable = "min-available",
maxUnavailable = "max-unavailable",
currentHealthy = "current-healthy",
desiredHealthy = "desired-healthy",
age = "age",
}
export interface PodDisruptionBudgetsProps extends KubeObjectDetailsProps<PodDisruptionBudget> {
}
interface Dependencies {
podDisruptionBudgetStore: PodDisruptionBudgetStore;
}
@observer
class NonInjectedPodDisruptionBudgets extends React.Component<PodDisruptionBudgetsProps & Dependencies> {
render() {
return (
<SiblingsInTabLayout>
<KubeObjectListLayout
isConfigurable
tableId="configuration_distribution_budgets"
className="PodDisruptionBudgets"
store={this.props.podDisruptionBudgetStore}
sortingCallbacks={{
[columnId.name]: pdb => pdb.getName(),
[columnId.namespace]: pdb => pdb.getNs(),
[columnId.minAvailable]: pdb => pdb.getMinAvailable(),
[columnId.maxUnavailable]: pdb => pdb.getMaxUnavailable(),
[columnId.currentHealthy]: pdb => pdb.getCurrentHealthy(),
[columnId.desiredHealthy]: pdb => pdb.getDesiredHealthy(),
[columnId.age]: pdb => -pdb.getCreationTimestamp(),
}}
searchFilters={[
pdb => pdb.getSearchFields(),
]}
renderHeaderTitle="Pod Disruption Budgets"
renderTableHeader={[
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
{ className: "warning", showWithColumn: columnId.name },
{ title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace },
{ title: "Min Available", className: "min-available", sortBy: columnId.minAvailable, id: columnId.minAvailable },
{ title: "Max Unavailable", className: "max-unavailable", sortBy: columnId.maxUnavailable, id: columnId.maxUnavailable },
{ title: "Current Healthy", className: "current-healthy", sortBy: columnId.currentHealthy, id: columnId.currentHealthy },
{ title: "Desired Healthy", className: "desired-healthy", sortBy: columnId.desiredHealthy, id: columnId.desiredHealthy },
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
]}
renderTableContents={pdb => [
pdb.getName(),
<KubeObjectStatusIcon key="icon" object={pdb} />,
<NamespaceSelectBadge
key="namespace"
namespace={pdb.getNs()}
/>,
pdb.getMinAvailable(),
pdb.getMaxUnavailable(),
pdb.getCurrentHealthy(),
pdb.getDesiredHealthy(),
<KubeObjectAge key="age" object={pdb} />,
]}
/>
</SiblingsInTabLayout>
);
}
}
export const PodDisruptionBudgets = withInjectables<Dependencies, PodDisruptionBudgetsProps>(NonInjectedPodDisruptionBudgets, {
getProps: (di, props) => ({
...props,
podDisruptionBudgetStore: di.inject(podDisruptionBudgetStoreInjectable),
}),
});
@@ -0,0 +1,29 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import assert from "assert";
import { kubeObjectStoreInjectionToken } from "../../../common/k8s-api/api-manager/kube-object-store-token";
import podDisruptionBudgetApiInjectable from "../../../common/k8s-api/endpoints/pod-disruption-budget.api.injectable";
import loggerInjectable from "../../../common/logger.injectable";
import clusterFrameContextForNamespacedResourcesInjectable from "../../cluster-frame-context/for-namespaced-resources.injectable";
import storesAndApisCanBeCreatedInjectable from "../../stores-apis-can-be-created.injectable";
import { PodDisruptionBudgetStore } from "./store";
const podDisruptionBudgetStoreInjectable = getInjectable({
id: "pod-disruption-budget-store",
instantiate: (di) => {
assert(di.inject(storesAndApisCanBeCreatedInjectable), "podDisruptionBudgetStore is only available in certain environments");
const api = di.inject(podDisruptionBudgetApiInjectable);
return new PodDisruptionBudgetStore({
context: di.inject(clusterFrameContextForNamespacedResourcesInjectable),
logger: di.inject(loggerInjectable),
}, api);
},
injectionToken: kubeObjectStoreInjectionToken,
});
export default podDisruptionBudgetStoreInjectable;
@@ -0,0 +1,10 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
import type { PodDisruptionBudget, PodDisruptionBudgetApi } from "../../../common/k8s-api/endpoints/pod-disruption-budget.api";
export class PodDisruptionBudgetStore extends KubeObjectStore<PodDisruptionBudget, PodDisruptionBudgetApi> {
}