@backstage/plugin-kubernetes-react 0.5.3 → 0.5.4-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,5 +1,18 @@
1
1
  # @backstage/plugin-kubernetes-react
2
2
 
3
+ ## 0.5.4-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - f35a754: Fixed bug in string-to-integer conversion to properly handle decimal values with BigInt.
8
+ - Updated dependencies
9
+ - @backstage/plugin-kubernetes-common@0.9.3-next.0
10
+ - @backstage/catalog-model@1.7.3
11
+ - @backstage/core-components@0.16.3
12
+ - @backstage/core-plugin-api@1.10.3
13
+ - @backstage/errors@1.2.7
14
+ - @backstage/types@1.2.1
15
+
3
16
  ## 0.5.3
4
17
 
5
18
  ### Patch Changes
@@ -64,10 +64,10 @@ const currentToDeclaredResourceToPerc = (current, resource) => {
64
64
  return `${Math.round(current / resource * 100)}%`;
65
65
  }
66
66
  const numerator = BigInt(
67
- typeof current === "number" ? Math.round(current) : current
67
+ typeof current === "number" ? Math.round(current) : Number(current)
68
68
  );
69
69
  const denominator = BigInt(
70
- typeof resource === "number" ? Math.round(resource) : resource
70
+ typeof resource === "number" ? Math.round(resource) : Number(resource)
71
71
  );
72
72
  return `${numerator * BigInt(100) / denominator}%`;
73
73
  };
@@ -1 +1 @@
1
- {"version":3,"file":"pod.esm.js","sources":["../../src/utils/pod.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n V1Pod,\n V1PodCondition,\n V1DeploymentCondition,\n} from '@kubernetes/client-node';\nimport React, { Fragment, ReactNode } from 'react';\nimport Chip from '@material-ui/core/Chip';\nimport {\n StatusAborted,\n StatusError,\n StatusOK,\n SubvalueCell,\n} from '@backstage/core-components';\nimport { ClientPodStatus } from '@backstage/plugin-kubernetes-common';\nimport { Pod } from 'kubernetes-models/v1/Pod';\nimport { bytesToMiB, formatMillicores } from './resources';\n\nexport const imageChips = (pod: V1Pod): ReactNode => {\n const containerStatuses = pod.status?.containerStatuses ?? [];\n const images = containerStatuses.map((cs, i) => {\n return <Chip key={i} label={`${cs.name}=${cs.image}`} size=\"small\" />;\n });\n\n return <div>{images}</div>;\n};\n\nexport const containersReady = (pod: Pod): string => {\n const containerStatuses = pod.status?.containerStatuses ?? [];\n const containersReadyItem = containerStatuses.filter(cs => cs.ready).length;\n\n return `${containersReadyItem}/${containerStatuses.length}`;\n};\n\nexport const totalRestarts = (pod: Pod): number => {\n const containerStatuses = pod.status?.containerStatuses ?? [];\n return containerStatuses?.reduce((a, b) => a + b.restartCount, 0);\n};\n\nexport const containerStatuses = (pod: Pod): ReactNode => {\n const containerStatusesItem = pod.status?.containerStatuses ?? [];\n const errors = containerStatusesItem.reduce((accum, next) => {\n if (next.state === undefined) {\n return accum;\n }\n\n const waiting = next.state.waiting;\n const terminated = next.state.terminated;\n\n const renderCell = (reason: string | undefined) => (\n <Fragment key={`${pod.metadata?.name}-${next.name}`}>\n <SubvalueCell\n value={\n reason === 'Completed' ? (\n <StatusOK>Container: {next.name}</StatusOK>\n ) : (\n <StatusError>Container: {next.name}</StatusError>\n )\n }\n subvalue={reason}\n />\n <br />\n </Fragment>\n );\n\n if (waiting) {\n accum.push(renderCell(waiting.reason));\n }\n\n if (terminated) {\n accum.push(renderCell(terminated.reason));\n }\n\n return accum;\n }, [] as React.ReactNode[]);\n\n if (errors.length === 0) {\n return <StatusOK>OK</StatusOK>;\n }\n\n return errors;\n};\n\nexport const renderCondition = (\n condition: V1PodCondition | V1DeploymentCondition,\n): [string, ReactNode] => {\n const status = condition.status;\n\n if (status === 'True') {\n return [condition.type, <StatusOK>True</StatusOK>];\n } else if (status === 'False') {\n return [\n condition.type,\n <SubvalueCell\n value={<StatusError>False</StatusError>}\n subvalue={condition.message ?? ''}\n />,\n ];\n }\n return [condition.type, <StatusAborted />];\n};\n\n// visible for testing\nexport const currentToDeclaredResourceToPerc = (\n current: number | string,\n resource: number | string,\n): string => {\n if (Number(resource) === 0) return `0%`;\n\n if (typeof current === 'number' && typeof resource === 'number') {\n return `${Math.round((current / resource) * 100)}%`;\n }\n\n const numerator: bigint = BigInt(\n typeof current === 'number' ? Math.round(current) : current,\n );\n const denominator: bigint = BigInt(\n typeof resource === 'number' ? Math.round(resource) : resource,\n );\n\n return `${(numerator * BigInt(100)) / denominator}%`;\n};\n\nexport const podStatusToCpuUtil = (podStatus: ClientPodStatus): ReactNode => {\n const cpuUtil = podStatus.cpu;\n\n let currentUsage: number | string = cpuUtil.currentUsage;\n\n // current usage number for CPU is a different unit than request/limit total\n // this might be a bug in the k8s library\n if (typeof cpuUtil.currentUsage === 'number') {\n currentUsage = cpuUtil.currentUsage / 10;\n }\n\n return (\n <SubvalueCell\n value={`requests: ${currentToDeclaredResourceToPerc(\n currentUsage,\n cpuUtil.requestTotal,\n )} of ${formatMillicores(cpuUtil.requestTotal)}`}\n subvalue={`limits: ${currentToDeclaredResourceToPerc(\n currentUsage,\n cpuUtil.limitTotal,\n )} of ${formatMillicores(cpuUtil.limitTotal)}`}\n />\n );\n};\n\nexport const podStatusToMemoryUtil = (\n podStatus: ClientPodStatus,\n): ReactNode => {\n const memUtil = podStatus.memory;\n\n return (\n <SubvalueCell\n value={`requests: ${currentToDeclaredResourceToPerc(\n memUtil.currentUsage,\n memUtil.requestTotal,\n )} of ${bytesToMiB(memUtil.requestTotal)}`}\n subvalue={`limits: ${currentToDeclaredResourceToPerc(\n memUtil.currentUsage,\n memUtil.limitTotal,\n )} of ${bytesToMiB(memUtil.limitTotal)}`}\n />\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AAA,MACC,OAAO,CAAa,UAAA,EAAA,+BAAA;AAAA,QAClB,YAAA;AAAA,QACA,OAAQ,CAAA;AAAA,OACT,CAAA,IAAA,EAAO,gBAAiB,CAAA,OAAA,CAAQ,YAAY,CAAC,CAAA,CAAA;AAAA,MAC9C,UAAU,CAAW,QAAA,EAAA,+BAAA;AAAA,QACnB,YAAA;AAAA,QACA,OAAQ,CAAA;AAAA,OACT,CAAA,IAAA,EAAO,gBAAiB,CAAA,OAAA,CAAQ,UAAU,CAAC,CAAA;AAAA;AAAA,GAC9C;AAEJ;AAEa,MAAA,qBAAA,GAAwB,CACnC,SACc,KAAA;AACd,EAAA,MAAM,UAAU,SAAU,CAAA,MAAA;AAE1B,EACE,uBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,YAAA;AAAA,IAAA;AAAA,MACC,OAAO,CAAa,UAAA,EAAA,+BAAA;AAAA,QAClB,OAAQ,CAAA,YAAA;AAAA,QACR,OAAQ,CAAA;AAAA,OACT,CAAA,IAAA,EAAO,UAAW,CAAA,OAAA,CAAQ,YAAY,CAAC,CAAA,CAAA;AAAA,MACxC,UAAU,CAAW,QAAA,EAAA,+BAAA;AAAA,QACnB,OAAQ,CAAA,YAAA;AAAA,QACR,OAAQ,CAAA;AAAA,OACT,CAAA,IAAA,EAAO,UAAW,CAAA,OAAA,CAAQ,UAAU,CAAC,CAAA;AAAA;AAAA,GACxC;AAEJ;;;;"}
1
+ {"version":3,"file":"pod.esm.js","sources":["../../src/utils/pod.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n V1Pod,\n V1PodCondition,\n V1DeploymentCondition,\n} from '@kubernetes/client-node';\nimport React, { Fragment, ReactNode } from 'react';\nimport Chip from '@material-ui/core/Chip';\nimport {\n StatusAborted,\n StatusError,\n StatusOK,\n SubvalueCell,\n} from '@backstage/core-components';\nimport { ClientPodStatus } from '@backstage/plugin-kubernetes-common';\nimport { Pod } from 'kubernetes-models/v1/Pod';\nimport { bytesToMiB, formatMillicores } from './resources';\n\nexport const imageChips = (pod: V1Pod): ReactNode => {\n const containerStatuses = pod.status?.containerStatuses ?? [];\n const images = containerStatuses.map((cs, i) => {\n return <Chip key={i} label={`${cs.name}=${cs.image}`} size=\"small\" />;\n });\n\n return <div>{images}</div>;\n};\n\nexport const containersReady = (pod: Pod): string => {\n const containerStatuses = pod.status?.containerStatuses ?? [];\n const containersReadyItem = containerStatuses.filter(cs => cs.ready).length;\n\n return `${containersReadyItem}/${containerStatuses.length}`;\n};\n\nexport const totalRestarts = (pod: Pod): number => {\n const containerStatuses = pod.status?.containerStatuses ?? [];\n return containerStatuses?.reduce((a, b) => a + b.restartCount, 0);\n};\n\nexport const containerStatuses = (pod: Pod): ReactNode => {\n const containerStatusesItem = pod.status?.containerStatuses ?? [];\n const errors = containerStatusesItem.reduce((accum, next) => {\n if (next.state === undefined) {\n return accum;\n }\n\n const waiting = next.state.waiting;\n const terminated = next.state.terminated;\n\n const renderCell = (reason: string | undefined) => (\n <Fragment key={`${pod.metadata?.name}-${next.name}`}>\n <SubvalueCell\n value={\n reason === 'Completed' ? (\n <StatusOK>Container: {next.name}</StatusOK>\n ) : (\n <StatusError>Container: {next.name}</StatusError>\n )\n }\n subvalue={reason}\n />\n <br />\n </Fragment>\n );\n\n if (waiting) {\n accum.push(renderCell(waiting.reason));\n }\n\n if (terminated) {\n accum.push(renderCell(terminated.reason));\n }\n\n return accum;\n }, [] as React.ReactNode[]);\n\n if (errors.length === 0) {\n return <StatusOK>OK</StatusOK>;\n }\n\n return errors;\n};\n\nexport const renderCondition = (\n condition: V1PodCondition | V1DeploymentCondition,\n): [string, ReactNode] => {\n const status = condition.status;\n\n if (status === 'True') {\n return [condition.type, <StatusOK>True</StatusOK>];\n } else if (status === 'False') {\n return [\n condition.type,\n <SubvalueCell\n value={<StatusError>False</StatusError>}\n subvalue={condition.message ?? ''}\n />,\n ];\n }\n return [condition.type, <StatusAborted />];\n};\n\n// visible for testing\nexport const currentToDeclaredResourceToPerc = (\n current: number | string,\n resource: number | string,\n): string => {\n if (Number(resource) === 0) return `0%`;\n\n if (typeof current === 'number' && typeof resource === 'number') {\n return `${Math.round((current / resource) * 100)}%`;\n }\n\n const numerator: bigint = BigInt(\n typeof current === 'number' ? Math.round(current) : Number(current),\n );\n const denominator: bigint = BigInt(\n typeof resource === 'number' ? Math.round(resource) : Number(resource),\n );\n\n return `${(numerator * BigInt(100)) / denominator}%`;\n};\n\nexport const podStatusToCpuUtil = (podStatus: ClientPodStatus): ReactNode => {\n const cpuUtil = podStatus.cpu;\n\n let currentUsage: number | string = cpuUtil.currentUsage;\n\n // current usage number for CPU is a different unit than request/limit total\n // this might be a bug in the k8s library\n if (typeof cpuUtil.currentUsage === 'number') {\n currentUsage = cpuUtil.currentUsage / 10;\n }\n\n return (\n <SubvalueCell\n value={`requests: ${currentToDeclaredResourceToPerc(\n currentUsage,\n cpuUtil.requestTotal,\n )} of ${formatMillicores(cpuUtil.requestTotal)}`}\n subvalue={`limits: ${currentToDeclaredResourceToPerc(\n currentUsage,\n cpuUtil.limitTotal,\n )} of ${formatMillicores(cpuUtil.limitTotal)}`}\n />\n );\n};\n\nexport const podStatusToMemoryUtil = (\n podStatus: ClientPodStatus,\n): ReactNode => {\n const memUtil = podStatus.memory;\n\n return (\n <SubvalueCell\n value={`requests: ${currentToDeclaredResourceToPerc(\n memUtil.currentUsage,\n memUtil.requestTotal,\n )} of ${bytesToMiB(memUtil.requestTotal)}`}\n subvalue={`limits: ${currentToDeclaredResourceToPerc(\n memUtil.currentUsage,\n memUtil.limitTotal,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AA,aAAA;AAAA,IAAC,YAAA;AAAA,IAAA;AAAA,MACC,OAAO,CAAa,UAAA,EAAA,+BAAA;AAAA,QAClB,YAAA;AAAA,QACA,OAAQ,CAAA;AAAA,OACT,CAAA,IAAA,EAAO,gBAAiB,CAAA,OAAA,CAAQ,YAAY,CAAC,CAAA,CAAA;AAAA,MAC9C,UAAU,CAAW,QAAA,EAAA,+BAAA;AAAA,QACnB,YAAA;AAAA,QACA,OAAQ,CAAA;AAAA,OACT,CAAA,IAAA,EAAO,gBAAiB,CAAA,OAAA,CAAQ,UAAU,CAAC,CAAA;AAAA;AAAA,GAC9C;AAEJ;AAEa,MAAA,qBAAA,GAAwB,CACnC,SACc,KAAA;AACd,EAAA,MAAM,UAAU,SAAU,CAAA,MAAA;AAE1B,EACE,uBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,YAAA;AAAA,IAAA;AAAA,MACC,OAAO,CAAa,UAAA,EAAA,+BAAA;AAAA,QAClB,OAAQ,CAAA,YAAA;AAAA,QACR,OAAQ,CAAA;AAAA,OACT,CAAA,IAAA,EAAO,UAAW,CAAA,OAAA,CAAQ,YAAY,CAAC,CAAA,CAAA;AAAA,MACxC,UAAU,CAAW,QAAA,EAAA,+BAAA;AAAA,QACnB,OAAQ,CAAA,YAAA;AAAA,QACR,OAAQ,CAAA;AAAA,OACT,CAAA,IAAA,EAAO,UAAW,CAAA,OAAA,CAAQ,UAAU,CAAC,CAAA;AAAA;AAAA,GACxC;AAEJ;;;;"}
@@ -3,8 +3,12 @@ const currentToDeclaredResourceToPerc = (current, resource) => {
3
3
  if (typeof current === "number" && typeof resource === "number") {
4
4
  return Math.round(current / resource * 100);
5
5
  }
6
- const numerator = BigInt(current);
7
- const denominator = BigInt(resource);
6
+ const numerator = BigInt(
7
+ typeof current === "number" ? Math.round(current) : Number(current)
8
+ );
9
+ const denominator = BigInt(
10
+ typeof resource === "number" ? Math.round(resource) : Number(resource)
11
+ );
8
12
  return Number(numerator * BigInt(100) / denominator);
9
13
  };
10
14
  const bytesToMiB = (value) => {
@@ -1 +1 @@
1
- {"version":3,"file":"resources.esm.js","sources":["../../src/utils/resources.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport const currentToDeclaredResourceToPerc = (\n current: number | string,\n resource: number | string,\n): number => {\n if (Number(resource) === 0) return 0;\n\n if (typeof current === 'number' && typeof resource === 'number') {\n return Math.round((current / resource) * 100);\n }\n\n const numerator: bigint = BigInt(current);\n const denominator: bigint = BigInt(resource);\n\n return Number((numerator * BigInt(100)) / denominator);\n};\n\nexport const bytesToMiB = (value: string | number): string => {\n return `${(parseFloat(value.toString()) / 1024 / 1024).toFixed(0)}MiB`;\n};\n\nexport const formatMillicores = (value: string | number): string => {\n return `${(parseFloat(value.toString()) * 1000).toFixed(0)}m`;\n};\n"],"names":[],"mappings":"AAea,MAAA,+BAAA,GAAkC,CAC7C,OAAA,EACA,QACW,KAAA;AACX,EAAA,IAAI,MAAO,CAAA,QAAQ,CAAM,KAAA,CAAA,EAAU,OAAA,CAAA;AAEnC,EAAA,IAAI,OAAO,OAAA,KAAY,QAAY,IAAA,OAAO,aAAa,QAAU,EAAA;AAC/D,IAAA,OAAO,IAAK,CAAA,KAAA,CAAO,OAAU,GAAA,QAAA,GAAY,GAAG,CAAA;AAAA;AAG9C,EAAM,MAAA,SAAA,GAAoB,OAAO,OAAO,CAAA;AACxC,EAAM,MAAA,WAAA,GAAsB,OAAO,QAAQ,CAAA;AAE3C,EAAA,OAAO,MAAQ,CAAA,SAAA,GAAY,MAAO,CAAA,GAAG,IAAK,WAAW,CAAA;AACvD;AAEa,MAAA,UAAA,GAAa,CAAC,KAAmC,KAAA;AAC5D,EAAO,OAAA,CAAA,EAAA,CAAI,UAAW,CAAA,KAAA,CAAM,QAAS,EAAC,IAAI,IAAO,GAAA,IAAA,EAAM,OAAQ,CAAA,CAAC,CAAC,CAAA,GAAA,CAAA;AACnE;AAEa,MAAA,gBAAA,GAAmB,CAAC,KAAmC,KAAA;AAClE,EAAO,OAAA,CAAA,EAAA,CAAI,WAAW,KAAM,CAAA,QAAA,EAAU,CAAI,GAAA,GAAA,EAAM,OAAQ,CAAA,CAAC,CAAC,CAAA,CAAA,CAAA;AAC5D;;;;"}
1
+ {"version":3,"file":"resources.esm.js","sources":["../../src/utils/resources.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport const currentToDeclaredResourceToPerc = (\n current: number | string,\n resource: number | string,\n): number => {\n if (Number(resource) === 0) return 0;\n\n if (typeof current === 'number' && typeof resource === 'number') {\n return Math.round((current / resource) * 100);\n }\n\n const numerator: bigint = BigInt(\n typeof current === 'number' ? Math.round(current) : Number(current),\n );\n const denominator: bigint = BigInt(\n typeof resource === 'number' ? Math.round(resource) : Number(resource),\n );\n\n return Number((numerator * BigInt(100)) / denominator);\n};\n\nexport const bytesToMiB = (value: string | number): string => {\n return `${(parseFloat(value.toString()) / 1024 / 1024).toFixed(0)}MiB`;\n};\n\nexport const formatMillicores = (value: string | number): string => {\n return `${(parseFloat(value.toString()) * 1000).toFixed(0)}m`;\n};\n"],"names":[],"mappings":"AAea,MAAA,+BAAA,GAAkC,CAC7C,OAAA,EACA,QACW,KAAA;AACX,EAAA,IAAI,MAAO,CAAA,QAAQ,CAAM,KAAA,CAAA,EAAU,OAAA,CAAA;AAEnC,EAAA,IAAI,OAAO,OAAA,KAAY,QAAY,IAAA,OAAO,aAAa,QAAU,EAAA;AAC/D,IAAA,OAAO,IAAK,CAAA,KAAA,CAAO,OAAU,GAAA,QAAA,GAAY,GAAG,CAAA;AAAA;AAG9C,EAAA,MAAM,SAAoB,GAAA,MAAA;AAAA,IACxB,OAAO,YAAY,QAAW,GAAA,IAAA,CAAK,MAAM,OAAO,CAAA,GAAI,OAAO,OAAO;AAAA,GACpE;AACA,EAAA,MAAM,WAAsB,GAAA,MAAA;AAAA,IAC1B,OAAO,aAAa,QAAW,GAAA,IAAA,CAAK,MAAM,QAAQ,CAAA,GAAI,OAAO,QAAQ;AAAA,GACvE;AAEA,EAAA,OAAO,MAAQ,CAAA,SAAA,GAAY,MAAO,CAAA,GAAG,IAAK,WAAW,CAAA;AACvD;AAEa,MAAA,UAAA,GAAa,CAAC,KAAmC,KAAA;AAC5D,EAAO,OAAA,CAAA,EAAA,CAAI,UAAW,CAAA,KAAA,CAAM,QAAS,EAAC,IAAI,IAAO,GAAA,IAAA,EAAM,OAAQ,CAAA,CAAC,CAAC,CAAA,GAAA,CAAA;AACnE;AAEa,MAAA,gBAAA,GAAmB,CAAC,KAAmC,KAAA;AAClE,EAAO,OAAA,CAAA,EAAA,CAAI,WAAW,KAAM,CAAA,QAAA,EAAU,CAAI,GAAA,GAAA,EAAM,OAAQ,CAAA,CAAC,CAAC,CAAA,CAAA,CAAA;AAC5D;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-kubernetes-react",
3
- "version": "0.5.3",
3
+ "version": "0.5.4-next.0",
4
4
  "description": "Web library for the kubernetes-react plugin",
5
5
  "backstage": {
6
6
  "role": "web-library",
@@ -62,12 +62,12 @@
62
62
  "test": "backstage-cli package test"
63
63
  },
64
64
  "dependencies": {
65
- "@backstage/catalog-model": "^1.7.3",
66
- "@backstage/core-components": "^0.16.3",
67
- "@backstage/core-plugin-api": "^1.10.3",
68
- "@backstage/errors": "^1.2.7",
69
- "@backstage/plugin-kubernetes-common": "^0.9.2",
70
- "@backstage/types": "^1.2.1",
65
+ "@backstage/catalog-model": "1.7.3",
66
+ "@backstage/core-components": "0.16.3",
67
+ "@backstage/core-plugin-api": "1.10.3",
68
+ "@backstage/errors": "1.2.7",
69
+ "@backstage/plugin-kubernetes-common": "0.9.3-next.0",
70
+ "@backstage/types": "1.2.1",
71
71
  "@kubernetes-models/apimachinery": "^2.0.0",
72
72
  "@kubernetes-models/base": "^5.0.0",
73
73
  "@kubernetes/client-node": "1.0.0-rc7",
@@ -85,9 +85,9 @@
85
85
  "xterm-addon-fit": "^0.8.0"
86
86
  },
87
87
  "devDependencies": {
88
- "@backstage/cli": "^0.29.5",
89
- "@backstage/core-app-api": "^1.15.4",
90
- "@backstage/test-utils": "^1.7.4",
88
+ "@backstage/cli": "0.30.0-next.0",
89
+ "@backstage/core-app-api": "1.15.4",
90
+ "@backstage/test-utils": "1.7.4",
91
91
  "@testing-library/jest-dom": "^6.0.0",
92
92
  "@testing-library/react": "^16.0.0",
93
93
  "@types/react": "^18.0.0",