Merge branch 'master' into feat/api-auth-client
This commit is contained in:
@@ -1,5 +1,25 @@
|
||||
# @backstage/plugin-kubernetes
|
||||
|
||||
## 0.3.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [12ece98cd]
|
||||
- Updated dependencies [d82246867]
|
||||
- Updated dependencies [c810082ae]
|
||||
- Updated dependencies [5fa3bdb55]
|
||||
- Updated dependencies [6e612ce25]
|
||||
- Updated dependencies [025e122c3]
|
||||
- Updated dependencies [21e624ba9]
|
||||
- Updated dependencies [da9f53c60]
|
||||
- Updated dependencies [32c95605f]
|
||||
- Updated dependencies [7881f2117]
|
||||
- Updated dependencies [54c7d02f7]
|
||||
- Updated dependencies [11cb5ef94]
|
||||
- @backstage/core@0.6.0
|
||||
- @backstage/theme@0.2.3
|
||||
- @backstage/catalog-model@0.7.1
|
||||
|
||||
## 0.3.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -14,6 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { createDevApp } from '@backstage/dev-utils';
|
||||
import { plugin } from '../src';
|
||||
import { kubernetesPlugin } from '../src';
|
||||
|
||||
createDevApp().registerPlugin(plugin).render();
|
||||
createDevApp().registerPlugin(kubernetesPlugin).render();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@backstage/plugin-kubernetes",
|
||||
"version": "0.3.7",
|
||||
"version": "0.3.8",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"license": "Apache-2.0",
|
||||
@@ -31,11 +31,12 @@
|
||||
"clean": "backstage-cli clean"
|
||||
},
|
||||
"dependencies": {
|
||||
"@backstage/catalog-model": "^0.7.0",
|
||||
"@backstage/catalog-model": "^0.7.1",
|
||||
"@backstage/plugin-catalog-react": "^0.0.2",
|
||||
"@backstage/config": "^0.1.2",
|
||||
"@backstage/core": "^0.5.0",
|
||||
"@backstage/core": "^0.6.0",
|
||||
"@backstage/plugin-kubernetes-backend": "^0.2.6",
|
||||
"@backstage/theme": "^0.2.2",
|
||||
"@backstage/theme": "^0.2.3",
|
||||
"@kubernetes/client-node": "^0.13.2",
|
||||
"@material-ui/core": "^4.11.0",
|
||||
"@material-ui/icons": "^4.9.1",
|
||||
@@ -47,8 +48,8 @@
|
||||
"react-use": "^15.3.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@backstage/cli": "^0.5.0",
|
||||
"@backstage/dev-utils": "^0.1.8",
|
||||
"@backstage/cli": "^0.6.0",
|
||||
"@backstage/dev-utils": "^0.1.9",
|
||||
"@backstage/test-utils": "^0.1.6",
|
||||
"@testing-library/jest-dom": "^5.10.1",
|
||||
"@testing-library/react": "^10.4.1",
|
||||
|
||||
@@ -16,15 +16,22 @@
|
||||
|
||||
import React from 'react';
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { useEntity } from '@backstage/plugin-catalog-react';
|
||||
import { Route, Routes } from 'react-router-dom';
|
||||
|
||||
import { rootCatalogKubernetesRouteRef } from './plugin';
|
||||
import { KubernetesContent } from './components/KubernetesContent';
|
||||
import { MissingAnnotationEmptyState } from '@backstage/core';
|
||||
|
||||
const KUBERNETES_ANNOTATION = 'backstage.io/kubernetes-id';
|
||||
|
||||
export const Router = ({ entity }: { entity: Entity }) => {
|
||||
type Props = {
|
||||
/** @deprecated The entity is now grabbed from context instead */
|
||||
entity?: Entity;
|
||||
};
|
||||
|
||||
export const Router = (_props: Props) => {
|
||||
const { entity } = useEntity();
|
||||
|
||||
const kubernetesAnnotationValue =
|
||||
entity.metadata.annotations?.[KUBERNETES_ANNOTATION];
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ export const DeploymentDrawer = ({
|
||||
object={deployment}
|
||||
expanded={expanded}
|
||||
kind="Deployment"
|
||||
renderObject={(deployment: V1Deployment) => {
|
||||
const conditions = (deployment.status?.conditions ?? [])
|
||||
renderObject={(deploymentObj: V1Deployment) => {
|
||||
const conditions = (deploymentObj.status?.conditions ?? [])
|
||||
.map(renderCondition)
|
||||
.reduce((accum, next) => {
|
||||
accum[next[0]] = next[1];
|
||||
@@ -41,10 +41,10 @@ export const DeploymentDrawer = ({
|
||||
}, {} as { [key: string]: React.ReactNode });
|
||||
|
||||
return {
|
||||
strategy: deployment.spec?.strategy ?? '???',
|
||||
minReadySeconds: deployment.spec?.minReadySeconds ?? '???',
|
||||
strategy: deploymentObj.spec?.strategy ?? '???',
|
||||
minReadySeconds: deploymentObj.spec?.minReadySeconds ?? '???',
|
||||
progressDeadlineSeconds:
|
||||
deployment.spec?.progressDeadlineSeconds ?? '???',
|
||||
deploymentObj.spec?.progressDeadlineSeconds ?? '???',
|
||||
...conditions,
|
||||
};
|
||||
}}
|
||||
|
||||
+7
-7
@@ -32,16 +32,16 @@ export const HorizontalPodAutoscalerDrawer = ({
|
||||
kind="HorizontalPodAutoscaler"
|
||||
object={hpa}
|
||||
expanded={expanded}
|
||||
renderObject={(hpa: V1HorizontalPodAutoscaler) => {
|
||||
renderObject={(hpaObject: V1HorizontalPodAutoscaler) => {
|
||||
return {
|
||||
targetCPUUtilizationPercentage:
|
||||
hpa.spec?.targetCPUUtilizationPercentage,
|
||||
hpaObject.spec?.targetCPUUtilizationPercentage,
|
||||
currentCPUUtilizationPercentage:
|
||||
hpa.status?.currentCPUUtilizationPercentage,
|
||||
minReplicas: hpa.spec?.minReplicas,
|
||||
maxReplicas: hpa.spec?.maxReplicas,
|
||||
currentReplicas: hpa.status?.currentReplicas,
|
||||
desiredReplicas: hpa.status?.desiredReplicas,
|
||||
hpaObject.status?.currentCPUUtilizationPercentage,
|
||||
minReplicas: hpaObject.spec?.minReplicas,
|
||||
maxReplicas: hpaObject.spec?.maxReplicas,
|
||||
currentReplicas: hpaObject.status?.currentReplicas,
|
||||
desiredReplicas: hpaObject.status?.desiredReplicas,
|
||||
};
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -31,8 +31,8 @@ export const IngressDrawer = ({
|
||||
object={ingress}
|
||||
expanded={expanded}
|
||||
kind="Ingress"
|
||||
renderObject={(ingress: ExtensionsV1beta1Ingress) => {
|
||||
return ingress.spec || {};
|
||||
renderObject={(ingressObject: ExtensionsV1beta1Ingress) => {
|
||||
return ingressObject.spec || {};
|
||||
}}
|
||||
>
|
||||
<Grid
|
||||
|
||||
+8
-8
@@ -37,17 +37,17 @@ export const PodDrawer = ({
|
||||
object={pod}
|
||||
expanded={expanded}
|
||||
kind="Pod"
|
||||
renderObject={(pod: V1Pod) => {
|
||||
const phase = pod.status?.phase ?? 'unknown';
|
||||
renderObject={(podObject: V1Pod) => {
|
||||
const phase = podObject.status?.phase ?? 'unknown';
|
||||
|
||||
const ports =
|
||||
pod.spec?.containers?.map(c => {
|
||||
podObject.spec?.containers?.map(c => {
|
||||
return {
|
||||
[c.name]: c.ports,
|
||||
};
|
||||
}) ?? 'N/A';
|
||||
|
||||
const conditions = (pod.status?.conditions ?? [])
|
||||
const conditions = (podObject.status?.conditions ?? [])
|
||||
.map(renderCondition)
|
||||
.reduce((accum, next) => {
|
||||
accum[next[0]] = next[1];
|
||||
@@ -55,11 +55,11 @@ export const PodDrawer = ({
|
||||
}, {} as { [key: string]: React.ReactNode });
|
||||
|
||||
return {
|
||||
images: imageChips(pod),
|
||||
images: imageChips(podObject),
|
||||
phase: phase,
|
||||
'Containers Ready': containersReady(pod),
|
||||
'Total Restarts': totalRestarts(pod),
|
||||
'Container Statuses': containerStatuses(pod),
|
||||
'Containers Ready': containersReady(podObject),
|
||||
'Total Restarts': totalRestarts(podObject),
|
||||
'Container Statuses': containerStatuses(podObject),
|
||||
...conditions,
|
||||
'Exposed ports': ports,
|
||||
};
|
||||
|
||||
@@ -31,8 +31,8 @@ export const ServiceDrawer = ({
|
||||
object={service}
|
||||
expanded={expanded}
|
||||
kind="Service"
|
||||
renderObject={(service: V1Service) => {
|
||||
return service.spec || {};
|
||||
renderObject={(serviceObject: V1Service) => {
|
||||
return serviceObject.spec || {};
|
||||
}}
|
||||
>
|
||||
<Grid
|
||||
|
||||
@@ -13,5 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export { plugin } from './plugin';
|
||||
export {
|
||||
kubernetesPlugin,
|
||||
kubernetesPlugin as plugin,
|
||||
EntityKubernetesContent,
|
||||
} from './plugin';
|
||||
export { Router } from './Router';
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { plugin } from './plugin';
|
||||
import { kubernetesPlugin } from './plugin';
|
||||
|
||||
describe('kubernetes', () => {
|
||||
it('should export plugin', () => {
|
||||
expect(plugin).toBeDefined();
|
||||
expect(kubernetesPlugin).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
discoveryApiRef,
|
||||
identityApiRef,
|
||||
googleAuthApiRef,
|
||||
createRoutableExtension,
|
||||
} from '@backstage/core';
|
||||
import { KubernetesBackendClient } from './api/KubernetesBackendClient';
|
||||
import { kubernetesApiRef } from './api/types';
|
||||
@@ -31,7 +32,7 @@ export const rootCatalogKubernetesRouteRef = createRouteRef({
|
||||
title: 'Kubernetes',
|
||||
});
|
||||
|
||||
export const plugin = createPlugin({
|
||||
export const kubernetesPlugin = createPlugin({
|
||||
id: 'kubernetes',
|
||||
apis: [
|
||||
createApiFactory({
|
||||
@@ -48,4 +49,14 @@ export const plugin = createPlugin({
|
||||
},
|
||||
}),
|
||||
],
|
||||
routes: {
|
||||
entityContent: rootCatalogKubernetesRouteRef,
|
||||
},
|
||||
});
|
||||
|
||||
export const EntityKubernetesContent = kubernetesPlugin.provide(
|
||||
createRoutableExtension({
|
||||
component: () => import('./Router').then(m => m.Router),
|
||||
mountPoint: rootCatalogKubernetesRouteRef,
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -36,9 +36,9 @@ export const imageChips = (pod: V1Pod): ReactNode => {
|
||||
|
||||
export const containersReady = (pod: V1Pod): string => {
|
||||
const containerStatuses = pod.status?.containerStatuses ?? [];
|
||||
const containersReady = containerStatuses.filter(cs => cs.ready).length;
|
||||
const containersReadyItem = containerStatuses.filter(cs => cs.ready).length;
|
||||
|
||||
return `${containersReady}/${containerStatuses.length}`;
|
||||
return `${containersReadyItem}/${containerStatuses.length}`;
|
||||
};
|
||||
|
||||
export const totalRestarts = (pod: V1Pod): number => {
|
||||
@@ -47,8 +47,8 @@ export const totalRestarts = (pod: V1Pod): number => {
|
||||
};
|
||||
|
||||
export const containerStatuses = (pod: V1Pod): ReactNode => {
|
||||
const containerStatuses = pod.status?.containerStatuses ?? [];
|
||||
const errors = containerStatuses.reduce((accum, next) => {
|
||||
const containerStatusesItem = pod.status?.containerStatuses ?? [];
|
||||
const errors = containerStatusesItem.reduce((accum, next) => {
|
||||
if (next.state === undefined) {
|
||||
return accum;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user