@backstage/plugin-kubernetes 0.9.1 → 0.9.2-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,10 +1,20 @@
1
1
  # @backstage/plugin-kubernetes
2
2
 
3
- ## 0.9.1
3
+ ## 0.9.2-next.0
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - a3360ecd0d7f: Fix cyclical dependency in built output
7
+ - dc3cddf51ab5: Fix cyclical dependency in built output
8
+ - 4b230b97660d: Add errors to PodDrawer
9
+ - Updated dependencies
10
+ - @backstage/plugin-catalog-react@1.7.0-next.0
11
+ - @backstage/theme@0.4.0-next.0
12
+ - @backstage/config@1.0.7
13
+ - @backstage/core-components@0.13.2-next.0
14
+ - @backstage/core-plugin-api@1.5.1
15
+ - @backstage/catalog-model@1.3.0
16
+ - @backstage/errors@1.1.5
17
+ - @backstage/plugin-kubernetes-common@0.6.3
8
18
 
9
19
  ## 0.9.0
10
20
 
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ import { V1Pod, V1ReplicaSet, V1Deployment, V1HorizontalPodAutoscaler, V1Service
8
8
  import React from 'react';
9
9
  import { IObjectMeta } from '@kubernetes-models/apimachinery/apis/meta/v1/ObjectMeta';
10
10
  import { Pod } from 'kubernetes-models/v1';
11
+ import { Pod as Pod$1 } from 'kubernetes-models/v1/Pod';
11
12
 
12
13
  declare const kubernetesPlugin: _backstage_core_plugin_api.BackstagePlugin<{
13
14
  entityContent: _backstage_core_plugin_api.RouteRef<undefined>;
@@ -335,7 +336,7 @@ declare const KubernetesDrawer: ({ open, label, drawerContentsHeader, kubernetes
335
336
  interface PodAndErrors {
336
337
  clusterName: string;
337
338
  pod: Pod;
338
- errors: any[];
339
+ errors: DetectedError[];
339
340
  }
340
341
 
341
342
  interface PodDrawerProps {
@@ -346,7 +347,7 @@ declare const PodDrawer: ({ podAndErrors, open }: PodDrawerProps) => JSX.Element
346
347
 
347
348
  type PodColumns = 'READY' | 'RESOURCE';
348
349
  type PodsTablesProps = {
349
- pods: V1Pod[];
350
+ pods: Pod$1 | V1Pod[];
350
351
  extraColumns?: PodColumns[];
351
352
  children?: React.ReactNode;
352
353
  };
package/dist/index.esm.js CHANGED
@@ -5,7 +5,7 @@ import * as React from 'react';
5
5
  import React__default, { useState, useCallback, useContext, Fragment } from 'react';
6
6
  import { useEntity } from '@backstage/plugin-catalog-react';
7
7
  import { Routes, Route } from 'react-router-dom';
8
- import { Typography, Paper, makeStyles, createStyles, Dialog, DialogTitle, IconButton, DialogContent, Button, Card, CardHeader, CardContent, Grid, CardActions, FormControlLabel, Switch, Drawer, withStyles as withStyles$1, List, ListItem, Chip, Accordion, AccordionSummary, AccordionDetails, Stepper, Step, StepLabel } from '@material-ui/core';
8
+ import { Typography, Paper, makeStyles, createStyles, Dialog, DialogTitle, IconButton, DialogContent, Button, Card, CardHeader, CardContent, Grid, CardActions, FormControlLabel, Switch, Drawer, withStyles as withStyles$1, List, ListItem, Divider, ListItemText, Chip, Accordion, AccordionSummary, AccordionDetails, Stepper, Step, StepLabel } from '@material-ui/core';
9
9
  import { WarningPanel, Table, DismissableBanner, LogViewer, StructuredMetadataTable, CodeSnippet, LinkButton, StatusError, StatusOK, StatusWarning, ItemCardGrid, SubvalueCell, StatusAborted, StatusPending, Page, Content, Progress, MissingAnnotationEmptyState } from '@backstage/core-components';
10
10
  import lodash from 'lodash';
11
11
  import { DateTime } from 'luxon';
@@ -740,7 +740,7 @@ const PodLogs = ({ podScope }) => {
740
740
  ));
741
741
  };
742
742
 
743
- const useStyles = makeStyles(
743
+ const useStyles$1 = makeStyles(
744
744
  (theme) => createStyles({
745
745
  closeButton: {
746
746
  position: "absolute",
@@ -751,7 +751,7 @@ const useStyles = makeStyles(
751
751
  })
752
752
  );
753
753
  const PodLogsDialog = ({ podScope }) => {
754
- const classes = useStyles();
754
+ const classes = useStyles$1();
755
755
  const [open, setOpen] = useState(false);
756
756
  const openDialog = () => {
757
757
  setOpen(true);
@@ -1507,6 +1507,39 @@ const PendingPodContent = ({ pod }) => {
1507
1507
  return /* @__PURE__ */ React__default.createElement(Grid, { container: true, spacing: 2 }, /* @__PURE__ */ React__default.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React__default.createElement(Typography, { variant: "h5" }, "Pod is Pending. Conditions:"), /* @__PURE__ */ React__default.createElement(List, null, startupConditions.map((c) => /* @__PURE__ */ React__default.createElement(ListItem, { key: c.type }, /* @__PURE__ */ React__default.createElement(PodCondition, { condition: c }))))));
1508
1508
  };
1509
1509
 
1510
+ const useStyles = makeStyles(
1511
+ (_theme) => createStyles({
1512
+ root: {
1513
+ overflow: "auto"
1514
+ },
1515
+ list: {
1516
+ width: "100%"
1517
+ }
1518
+ })
1519
+ );
1520
+ const ErrorList = ({ podAndErrors }) => {
1521
+ const classes = useStyles();
1522
+ return /* @__PURE__ */ React__default.createElement(Paper, { className: classes.root }, /* @__PURE__ */ React__default.createElement(List, { className: classes.list }, podAndErrors.filter((pae) => pae.errors.length > 0).flatMap((onlyPodWithErrors) => {
1523
+ return onlyPodWithErrors.errors.map((error, i) => {
1524
+ var _a, _b, _c;
1525
+ return /* @__PURE__ */ React__default.createElement(
1526
+ React__default.Fragment,
1527
+ {
1528
+ key: `${(_b = (_a = onlyPodWithErrors.pod.metadata) == null ? void 0 : _a.name) != null ? _b : "unknown"}-eli-${i}`
1529
+ },
1530
+ i > 0 && /* @__PURE__ */ React__default.createElement(Divider, { key: `error-divider${i}` }),
1531
+ /* @__PURE__ */ React__default.createElement(ListItem, null, /* @__PURE__ */ React__default.createElement(
1532
+ ListItemText,
1533
+ {
1534
+ primary: error.message,
1535
+ secondary: (_c = onlyPodWithErrors.pod.metadata) == null ? void 0 : _c.name
1536
+ }
1537
+ ))
1538
+ );
1539
+ });
1540
+ })));
1541
+ };
1542
+
1510
1543
  const useDrawerContentStyles = makeStyles(
1511
1544
  (_theme) => createStyles({
1512
1545
  header: {
@@ -1563,7 +1596,7 @@ const PodDrawer = ({ podAndErrors, open }) => {
1563
1596
  }
1564
1597
  );
1565
1598
  }
1566
- )))))
1599
+ ))), podAndErrors.errors.length > 0 && /* @__PURE__ */ React__default.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React__default.createElement(Typography, { variant: "h5" }, "Errors:")), podAndErrors.errors.length > 0 && /* @__PURE__ */ React__default.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React__default.createElement(ErrorList, { podAndErrors: [podAndErrors] }))))
1567
1600
  );
1568
1601
  };
1569
1602
 
@@ -1682,6 +1715,22 @@ const podStatusToMemoryUtil = (podStatus) => {
1682
1715
  );
1683
1716
  };
1684
1717
 
1718
+ const DetectedErrorsContext = React__default.createContext([]);
1719
+ const useMatchingErrors = (matcher) => {
1720
+ var _a, _b, _c, _d;
1721
+ const targetRef = {
1722
+ name: (_b = (_a = matcher.metadata) == null ? void 0 : _a.name) != null ? _b : "",
1723
+ namespace: (_d = (_c = matcher.metadata) == null ? void 0 : _c.namespace) != null ? _d : "",
1724
+ kind: matcher.kind,
1725
+ apiGroup: matcher.apiVersion
1726
+ };
1727
+ const errors = useContext(DetectedErrorsContext);
1728
+ return errors.filter((e) => {
1729
+ const r = e.sourceRef;
1730
+ return targetRef.apiGroup === r.apiGroup && targetRef.kind === r.kind && targetRef.name === r.name && targetRef.namespace === r.namespace;
1731
+ });
1732
+ };
1733
+
1685
1734
  const READY_COLUMNS = "READY";
1686
1735
  const RESOURCE_COLUMNS = "RESOURCE";
1687
1736
  const READY = [
@@ -1699,23 +1748,33 @@ const READY = [
1699
1748
  width: "auto"
1700
1749
  }
1701
1750
  ];
1751
+ const PodDrawerTrigger = ({ pod }) => {
1752
+ const cluster = useContext(ClusterContext);
1753
+ const errors = useMatchingErrors({
1754
+ kind: "Pod",
1755
+ apiVersion: "v1",
1756
+ metadata: pod.metadata
1757
+ });
1758
+ return /* @__PURE__ */ React__default.createElement(
1759
+ PodDrawer,
1760
+ {
1761
+ podAndErrors: {
1762
+ pod,
1763
+ clusterName: cluster.name,
1764
+ errors
1765
+ }
1766
+ }
1767
+ );
1768
+ };
1702
1769
  const PodsTable = ({ pods, extraColumns = [] }) => {
1703
1770
  const podNamesWithMetrics = useContext(PodNamesWithMetricsContext);
1704
- const cluster = useContext(ClusterContext);
1705
1771
  const defaultColumns = [
1706
1772
  {
1707
1773
  title: "name",
1708
1774
  highlight: true,
1709
- render: (pod) => /* @__PURE__ */ React__default.createElement(
1710
- PodDrawer,
1711
- {
1712
- podAndErrors: {
1713
- pod,
1714
- clusterName: cluster.name,
1715
- errors: []
1716
- }
1717
- }
1718
- )
1775
+ render: (pod) => {
1776
+ return /* @__PURE__ */ React__default.createElement(PodDrawerTrigger, { pod });
1777
+ }
1719
1778
  },
1720
1779
  {
1721
1780
  title: "phase",
@@ -1767,15 +1826,11 @@ const PodsTable = ({ pods, extraColumns = [] }) => {
1767
1826
  minWidth: "0",
1768
1827
  width: "100%"
1769
1828
  };
1770
- const usePods = pods.map((p) => {
1771
- var _a;
1772
- return { ...p, id: (_a = p.metadata) == null ? void 0 : _a.uid };
1773
- });
1774
1829
  return /* @__PURE__ */ React__default.createElement("div", { style: tableStyle }, /* @__PURE__ */ React__default.createElement(
1775
1830
  Table,
1776
1831
  {
1777
1832
  options: { paging: true, search: false, emptyRowsWhenPaging: false },
1778
- data: usePods,
1833
+ data: pods,
1779
1834
  columns
1780
1835
  }
1781
1836
  ));
@@ -2905,7 +2960,7 @@ const KubernetesContent = ({
2905
2960
  );
2906
2961
  const clustersWithErrors = (_a = kubernetesObjects == null ? void 0 : kubernetesObjects.items.filter((r) => r.errors.length > 0)) != null ? _a : [];
2907
2962
  const detectedErrors = kubernetesObjects !== void 0 ? detectErrors(kubernetesObjects) : /* @__PURE__ */ new Map();
2908
- return /* @__PURE__ */ React__default.createElement(Page, { themeId: "tool" }, /* @__PURE__ */ React__default.createElement(Content, null, kubernetesObjects === void 0 && error === void 0 && /* @__PURE__ */ React__default.createElement(Progress, null), clustersWithErrors.length > 0 && /* @__PURE__ */ React__default.createElement(Grid, { container: true, spacing: 3, direction: "column" }, /* @__PURE__ */ React__default.createElement(Grid, { item: true }, /* @__PURE__ */ React__default.createElement(
2963
+ return /* @__PURE__ */ React__default.createElement(DetectedErrorsContext.Provider, { value: [...detectedErrors.values()].flat() }, /* @__PURE__ */ React__default.createElement(Page, { themeId: "tool" }, /* @__PURE__ */ React__default.createElement(Content, null, kubernetesObjects === void 0 && error === void 0 && /* @__PURE__ */ React__default.createElement(Progress, null), clustersWithErrors.length > 0 && /* @__PURE__ */ React__default.createElement(Grid, { container: true, spacing: 3, direction: "column" }, /* @__PURE__ */ React__default.createElement(Grid, { item: true }, /* @__PURE__ */ React__default.createElement(
2909
2964
  ErrorPanel,
2910
2965
  {
2911
2966
  entityName: entity.metadata.name,
@@ -2947,7 +3002,7 @@ const KubernetesContent = ({
2947
3002
  podsWithErrors
2948
3003
  }
2949
3004
  ));
2950
- }))))));
3005
+ })))))));
2951
3006
  };
2952
3007
 
2953
3008
  const KUBERNETES_ANNOTATION = "backstage.io/kubernetes-id";