@backstage/plugin-kubernetes-react 0.3.4 → 0.3.5-next.1

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.
Files changed (154) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/api/KubernetesBackendClient.esm.js +137 -0
  3. package/dist/api/KubernetesBackendClient.esm.js.map +1 -0
  4. package/dist/api/KubernetesClusterLinkFormatter.esm.js +38 -0
  5. package/dist/api/KubernetesClusterLinkFormatter.esm.js.map +1 -0
  6. package/dist/api/KubernetesProxyClient.esm.js +76 -0
  7. package/dist/api/KubernetesProxyClient.esm.js.map +1 -0
  8. package/dist/api/formatters/AksClusterLinksFormatter.esm.js +35 -0
  9. package/dist/api/formatters/AksClusterLinksFormatter.esm.js.map +1 -0
  10. package/dist/api/formatters/EksClusterLinksFormatter.esm.js +10 -0
  11. package/dist/api/formatters/EksClusterLinksFormatter.esm.js.map +1 -0
  12. package/dist/api/formatters/GkeClusterLinksFormatter.esm.js +62 -0
  13. package/dist/api/formatters/GkeClusterLinksFormatter.esm.js.map +1 -0
  14. package/dist/api/formatters/OpenshiftClusterLinksFormatter.esm.js +41 -0
  15. package/dist/api/formatters/OpenshiftClusterLinksFormatter.esm.js.map +1 -0
  16. package/dist/api/formatters/RancherClusterLinksFormatter.esm.js +33 -0
  17. package/dist/api/formatters/RancherClusterLinksFormatter.esm.js.map +1 -0
  18. package/dist/api/formatters/StandardClusterLinksFormatter.esm.js +37 -0
  19. package/dist/api/formatters/StandardClusterLinksFormatter.esm.js.map +1 -0
  20. package/dist/api/formatters/index.esm.js +21 -0
  21. package/dist/api/formatters/index.esm.js.map +1 -0
  22. package/dist/api/types.esm.js +14 -0
  23. package/dist/api/types.esm.js.map +1 -0
  24. package/dist/components/Cluster/Cluster.esm.js +88 -0
  25. package/dist/components/Cluster/Cluster.esm.js.map +1 -0
  26. package/dist/components/CronJobsAccordions/CronJobsAccordions.esm.js +80 -0
  27. package/dist/components/CronJobsAccordions/CronJobsAccordions.esm.js.map +1 -0
  28. package/dist/components/CronJobsAccordions/CronJobsDrawer.esm.js +51 -0
  29. package/dist/components/CronJobsAccordions/CronJobsDrawer.esm.js.map +1 -0
  30. package/dist/components/CustomResources/ArgoRollouts/Rollout.esm.js +222 -0
  31. package/dist/components/CustomResources/ArgoRollouts/Rollout.esm.js.map +1 -0
  32. package/dist/components/CustomResources/ArgoRollouts/RolloutDrawer.esm.js +40 -0
  33. package/dist/components/CustomResources/ArgoRollouts/RolloutDrawer.esm.js.map +1 -0
  34. package/dist/components/CustomResources/ArgoRollouts/StepsProgress.esm.js +32 -0
  35. package/dist/components/CustomResources/ArgoRollouts/StepsProgress.esm.js.map +1 -0
  36. package/dist/components/CustomResources/CustomResources.esm.js +44 -0
  37. package/dist/components/CustomResources/CustomResources.esm.js.map +1 -0
  38. package/dist/components/CustomResources/DefaultCustomResource.esm.js +79 -0
  39. package/dist/components/CustomResources/DefaultCustomResource.esm.js.map +1 -0
  40. package/dist/components/CustomResources/DefaultCustomResourceDrawer.esm.js +43 -0
  41. package/dist/components/CustomResources/DefaultCustomResourceDrawer.esm.js.map +1 -0
  42. package/dist/components/DaemonSetsAccordions/DaemonSetsAccordions.esm.js +126 -0
  43. package/dist/components/DaemonSetsAccordions/DaemonSetsAccordions.esm.js.map +1 -0
  44. package/dist/components/DaemonSetsAccordions/DaemonSetsDrawer.esm.js +55 -0
  45. package/dist/components/DaemonSetsAccordions/DaemonSetsDrawer.esm.js.map +1 -0
  46. package/dist/components/DeploymentsAccordions/DeploymentDrawer.esm.js +56 -0
  47. package/dist/components/DeploymentsAccordions/DeploymentDrawer.esm.js.map +1 -0
  48. package/dist/components/DeploymentsAccordions/DeploymentsAccordions.esm.js +160 -0
  49. package/dist/components/DeploymentsAccordions/DeploymentsAccordions.esm.js.map +1 -0
  50. package/dist/components/ErrorPanel/ErrorPanel.esm.js +27 -0
  51. package/dist/components/ErrorPanel/ErrorPanel.esm.js.map +1 -0
  52. package/dist/components/ErrorReporting/ErrorReporting.esm.js +63 -0
  53. package/dist/components/ErrorReporting/ErrorReporting.esm.js.map +1 -0
  54. package/dist/components/HorizontalPodAutoscalers/HorizontalPodAutoscalerDrawer.esm.js +34 -0
  55. package/dist/components/HorizontalPodAutoscalers/HorizontalPodAutoscalerDrawer.esm.js.map +1 -0
  56. package/dist/components/IngressesAccordions/IngressDrawer.esm.js +45 -0
  57. package/dist/components/IngressesAccordions/IngressDrawer.esm.js.map +1 -0
  58. package/dist/components/IngressesAccordions/IngressesAccordions.esm.js +62 -0
  59. package/dist/components/IngressesAccordions/IngressesAccordions.esm.js.map +1 -0
  60. package/dist/components/JobsAccordions/JobsAccordions.esm.js +101 -0
  61. package/dist/components/JobsAccordions/JobsAccordions.esm.js.map +1 -0
  62. package/dist/components/JobsAccordions/JobsDrawer.esm.js +48 -0
  63. package/dist/components/JobsAccordions/JobsDrawer.esm.js.map +1 -0
  64. package/dist/components/KubernetesDialog/KubernetesDialog.esm.js +72 -0
  65. package/dist/components/KubernetesDialog/KubernetesDialog.esm.js.map +1 -0
  66. package/dist/components/KubernetesDrawer/KubernetesDrawer.esm.js +117 -0
  67. package/dist/components/KubernetesDrawer/KubernetesDrawer.esm.js.map +1 -0
  68. package/dist/components/KubernetesDrawer/KubernetesStructuredMetadataTableDrawer.esm.js +199 -0
  69. package/dist/components/KubernetesDrawer/KubernetesStructuredMetadataTableDrawer.esm.js.map +1 -0
  70. package/dist/components/KubernetesDrawer/ManifestYaml.esm.js +44 -0
  71. package/dist/components/KubernetesDrawer/ManifestYaml.esm.js.map +1 -0
  72. package/dist/components/PodExecTerminal/PodExecTerminal.esm.js +88 -0
  73. package/dist/components/PodExecTerminal/PodExecTerminal.esm.js.map +1 -0
  74. package/dist/components/PodExecTerminal/PodExecTerminalAttachAddon.esm.js +40 -0
  75. package/dist/components/PodExecTerminal/PodExecTerminalAttachAddon.esm.js.map +1 -0
  76. package/dist/components/PodExecTerminal/PodExecTerminalDialog.esm.js +35 -0
  77. package/dist/components/PodExecTerminal/PodExecTerminalDialog.esm.js.map +1 -0
  78. package/dist/components/Pods/ErrorList/ErrorList.esm.js +52 -0
  79. package/dist/components/Pods/ErrorList/ErrorList.esm.js.map +1 -0
  80. package/dist/components/Pods/Events/Events.esm.js +74 -0
  81. package/dist/components/Pods/Events/Events.esm.js.map +1 -0
  82. package/dist/components/Pods/Events/useEvents.esm.js +21 -0
  83. package/dist/components/Pods/Events/useEvents.esm.js.map +1 -0
  84. package/dist/components/Pods/FixDialog/FixDialog.esm.js +107 -0
  85. package/dist/components/Pods/FixDialog/FixDialog.esm.js.map +1 -0
  86. package/dist/components/Pods/PodDrawer/ContainerCard.esm.js +166 -0
  87. package/dist/components/Pods/PodDrawer/ContainerCard.esm.js.map +1 -0
  88. package/dist/components/Pods/PodDrawer/PendingPodContent.esm.js +30 -0
  89. package/dist/components/Pods/PodDrawer/PendingPodContent.esm.js.map +1 -0
  90. package/dist/components/Pods/PodDrawer/PodDrawer.esm.js +114 -0
  91. package/dist/components/Pods/PodDrawer/PodDrawer.esm.js.map +1 -0
  92. package/dist/components/Pods/PodLogs/PodLogs.esm.js +44 -0
  93. package/dist/components/Pods/PodLogs/PodLogs.esm.js.map +1 -0
  94. package/dist/components/Pods/PodLogs/PodLogsDialog.esm.js +21 -0
  95. package/dist/components/Pods/PodLogs/PodLogsDialog.esm.js.map +1 -0
  96. package/dist/components/Pods/PodLogs/usePodLogs.esm.js +19 -0
  97. package/dist/components/Pods/PodLogs/usePodLogs.esm.js.map +1 -0
  98. package/dist/components/Pods/PodsTable.esm.js +153 -0
  99. package/dist/components/Pods/PodsTable.esm.js.map +1 -0
  100. package/dist/components/ResourceUtilization/ResourceUtilization.esm.js +50 -0
  101. package/dist/components/ResourceUtilization/ResourceUtilization.esm.js.map +1 -0
  102. package/dist/components/ServicesAccordions/ServiceDrawer.esm.js +45 -0
  103. package/dist/components/ServicesAccordions/ServiceDrawer.esm.js.map +1 -0
  104. package/dist/components/ServicesAccordions/ServicesAccordions.esm.js +79 -0
  105. package/dist/components/ServicesAccordions/ServicesAccordions.esm.js.map +1 -0
  106. package/dist/components/StatefulSetsAccordions/StatefulSetDrawer.esm.js +58 -0
  107. package/dist/components/StatefulSetsAccordions/StatefulSetDrawer.esm.js.map +1 -0
  108. package/dist/components/StatefulSetsAccordions/StatefulSetsAccordions.esm.js +156 -0
  109. package/dist/components/StatefulSetsAccordions/StatefulSetsAccordions.esm.js.map +1 -0
  110. package/dist/hooks/Cluster.esm.js +8 -0
  111. package/dist/hooks/Cluster.esm.js.map +1 -0
  112. package/dist/hooks/GroupedResponses.esm.js +19 -0
  113. package/dist/hooks/GroupedResponses.esm.js.map +1 -0
  114. package/dist/hooks/PodNamesWithErrors.esm.js +8 -0
  115. package/dist/hooks/PodNamesWithErrors.esm.js.map +1 -0
  116. package/dist/hooks/PodNamesWithMetrics.esm.js +6 -0
  117. package/dist/hooks/PodNamesWithMetrics.esm.js.map +1 -0
  118. package/dist/hooks/auth.esm.js +24 -0
  119. package/dist/hooks/auth.esm.js.map +1 -0
  120. package/dist/hooks/useCustomResources.esm.js +42 -0
  121. package/dist/hooks/useCustomResources.esm.js.map +1 -0
  122. package/dist/hooks/useIsPodExecTerminalEnabled.esm.js +9 -0
  123. package/dist/hooks/useIsPodExecTerminalEnabled.esm.js.map +1 -0
  124. package/dist/hooks/useIsPodExecTerminalSupported.esm.js +21 -0
  125. package/dist/hooks/useIsPodExecTerminalSupported.esm.js.map +1 -0
  126. package/dist/hooks/useKubernetesObjects.esm.js +36 -0
  127. package/dist/hooks/useKubernetesObjects.esm.js.map +1 -0
  128. package/dist/hooks/useMatchingErrors.esm.js +20 -0
  129. package/dist/hooks/useMatchingErrors.esm.js.map +1 -0
  130. package/dist/hooks/usePodMetrics.esm.js +20 -0
  131. package/dist/hooks/usePodMetrics.esm.js.map +1 -0
  132. package/dist/index.esm.js +53 -3465
  133. package/dist/index.esm.js.map +1 -1
  134. package/dist/kubernetes-auth-provider/AksKubernetesAuthProvider.esm.js +21 -0
  135. package/dist/kubernetes-auth-provider/AksKubernetesAuthProvider.esm.js.map +1 -0
  136. package/dist/kubernetes-auth-provider/GoogleKubernetesAuthProvider.esm.js +31 -0
  137. package/dist/kubernetes-auth-provider/GoogleKubernetesAuthProvider.esm.js.map +1 -0
  138. package/dist/kubernetes-auth-provider/KubernetesAuthProviders.esm.js +89 -0
  139. package/dist/kubernetes-auth-provider/KubernetesAuthProviders.esm.js.map +1 -0
  140. package/dist/kubernetes-auth-provider/OidcKubernetesAuthProvider.esm.js +33 -0
  141. package/dist/kubernetes-auth-provider/OidcKubernetesAuthProvider.esm.js.map +1 -0
  142. package/dist/kubernetes-auth-provider/ServerSideAuthProvider.esm.js +11 -0
  143. package/dist/kubernetes-auth-provider/ServerSideAuthProvider.esm.js.map +1 -0
  144. package/dist/kubernetes-auth-provider/types.esm.js +8 -0
  145. package/dist/kubernetes-auth-provider/types.esm.js.map +1 -0
  146. package/dist/utils/crons.esm.js +22 -0
  147. package/dist/utils/crons.esm.js.map +1 -0
  148. package/dist/utils/owner.esm.js +30 -0
  149. package/dist/utils/owner.esm.js.map +1 -0
  150. package/dist/utils/pod.esm.js +120 -0
  151. package/dist/utils/pod.esm.js.map +1 -0
  152. package/dist/utils/resources.esm.js +19 -0
  153. package/dist/utils/resources.esm.js.map +1 -0
  154. package/package.json +6 -6
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StatefulSetsAccordions.esm.js","sources":["../../../src/components/StatefulSetsAccordions/StatefulSetsAccordions.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 React, { useContext } from 'react';\nimport Accordion from '@material-ui/core/Accordion';\nimport AccordionDetails from '@material-ui/core/AccordionDetails';\nimport AccordionSummary from '@material-ui/core/AccordionSummary';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport {\n V1Pod,\n V1HorizontalPodAutoscaler,\n V1StatefulSet,\n} from '@kubernetes/client-node';\nimport { PodsTable } from '../Pods';\nimport { StatefulSetDrawer } from './StatefulSetDrawer';\nimport { HorizontalPodAutoscalerDrawer } from '../HorizontalPodAutoscalers';\nimport { getMatchingHpa, getOwnedResources } from '../../utils/owner';\nimport {\n GroupedResponsesContext,\n PodNamesWithErrorsContext,\n} from '../../hooks';\nimport { StatusError, StatusOK } from '@backstage/core-components';\nimport { READY_COLUMNS, RESOURCE_COLUMNS } from '../Pods/PodsTable';\n\ntype StatefulSetsAccordionsProps = {\n children?: React.ReactNode;\n};\n\ntype StatefulSetAccordionProps = {\n statefulset: V1StatefulSet;\n ownedPods: V1Pod[];\n matchingHpa?: V1HorizontalPodAutoscaler;\n children?: React.ReactNode;\n};\n\ntype StatefulSetSummaryProps = {\n statefulset: V1StatefulSet;\n numberOfCurrentPods: number;\n numberOfPodsWithErrors: number;\n hpa?: V1HorizontalPodAutoscaler;\n children?: React.ReactNode;\n};\n\nconst StatefulSetSummary = ({\n statefulset,\n numberOfCurrentPods,\n numberOfPodsWithErrors,\n hpa,\n}: StatefulSetSummaryProps) => {\n return (\n <Grid\n container\n direction=\"row\"\n justifyContent=\"space-between\"\n alignItems=\"center\"\n spacing={0}\n >\n <Grid xs={6} item>\n <StatefulSetDrawer statefulset={statefulset} />\n </Grid>\n {hpa && (\n <Grid item xs={3}>\n <HorizontalPodAutoscalerDrawer hpa={hpa}>\n <Grid\n item\n container\n direction=\"column\"\n justifyContent=\"flex-start\"\n alignItems=\"flex-start\"\n spacing={0}\n >\n <Grid item>\n <Typography variant=\"subtitle2\">\n min replicas {hpa.spec?.minReplicas ?? '?'} / max replicas{' '}\n {hpa.spec?.maxReplicas ?? '?'}\n </Typography>\n </Grid>\n <Grid item>\n <Typography variant=\"subtitle2\">\n current CPU usage:{' '}\n {hpa.status?.currentCPUUtilizationPercentage ?? '?'}%\n </Typography>\n </Grid>\n <Grid item>\n <Typography variant=\"subtitle2\">\n target CPU usage:{' '}\n {hpa.spec?.targetCPUUtilizationPercentage ?? '?'}%\n </Typography>\n </Grid>\n </Grid>\n </HorizontalPodAutoscalerDrawer>\n </Grid>\n )}\n <Grid\n item\n container\n xs={3}\n direction=\"column\"\n justifyContent=\"flex-start\"\n alignItems=\"flex-start\"\n spacing={0}\n >\n <Grid item>\n <StatusOK>{numberOfCurrentPods} pods</StatusOK>\n </Grid>\n <Grid item>\n {numberOfPodsWithErrors > 0 ? (\n <StatusError>\n {numberOfPodsWithErrors} pod\n {numberOfPodsWithErrors > 1 ? 's' : ''} with errors\n </StatusError>\n ) : (\n <StatusOK>No pods with errors</StatusOK>\n )}\n </Grid>\n </Grid>\n </Grid>\n );\n};\n\nconst StatefulSetAccordion = ({\n statefulset,\n ownedPods,\n matchingHpa,\n}: StatefulSetAccordionProps) => {\n const podNamesWithErrors = useContext(PodNamesWithErrorsContext);\n\n const podsWithErrors = ownedPods.filter(p =>\n podNamesWithErrors.has(p.metadata?.name ?? ''),\n );\n\n return (\n <Accordion TransitionProps={{ unmountOnExit: true }} variant=\"outlined\">\n <AccordionSummary expandIcon={<ExpandMoreIcon />}>\n <StatefulSetSummary\n statefulset={statefulset}\n numberOfCurrentPods={ownedPods.length}\n numberOfPodsWithErrors={podsWithErrors.length}\n hpa={matchingHpa}\n />\n </AccordionSummary>\n <AccordionDetails>\n <PodsTable\n pods={ownedPods}\n extraColumns={[READY_COLUMNS, RESOURCE_COLUMNS]}\n />\n </AccordionDetails>\n </Accordion>\n );\n};\n\nexport const StatefulSetsAccordions = ({}: StatefulSetsAccordionsProps) => {\n const groupedResponses = useContext(GroupedResponsesContext);\n\n return (\n <Grid\n container\n direction=\"column\"\n justifyContent=\"flex-start\"\n alignItems=\"flex-start\"\n >\n {groupedResponses.statefulsets.map((statefulset, i) => (\n <Grid container item key={i} xs>\n <Grid item xs>\n <StatefulSetAccordion\n matchingHpa={getMatchingHpa(\n {\n name: statefulset.metadata?.name,\n namespace: statefulset.metadata?.namespace,\n kind: 'statefulset',\n },\n groupedResponses.horizontalPodAutoscalers,\n )}\n ownedPods={getOwnedResources(statefulset, groupedResponses.pods)}\n statefulset={statefulset}\n />\n </Grid>\n </Grid>\n ))}\n </Grid>\n );\n};\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,MAAM,qBAAqB,CAAC;AAAA,EAC1B,WAAA;AAAA,EACA,mBAAA;AAAA,EACA,sBAAA;AAAA,EACA,GAAA;AACF,CAA+B,KAAA;AA/D/B,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AAgEE,EACE,uBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,SAAS,EAAA,IAAA;AAAA,MACT,SAAU,EAAA,KAAA;AAAA,MACV,cAAe,EAAA,eAAA;AAAA,MACf,UAAW,EAAA,QAAA;AAAA,MACX,OAAS,EAAA,CAAA;AAAA,KAAA;AAAA,oBAETA,cAAA,CAAA,aAAA,CAAC,QAAK,EAAI,EAAA,CAAA,EAAG,MAAI,IACf,EAAA,kBAAAA,cAAA,CAAA,aAAA,CAAC,iBAAkB,EAAA,EAAA,WAAA,EAA0B,CAC/C,CAAA;AAAA,IACC,GAAA,iDACE,IAAK,EAAA,EAAA,IAAA,EAAI,MAAC,EAAI,EAAA,CAAA,EAAA,kBACZA,cAAA,CAAA,aAAA,CAAA,6BAAA,EAAA,EAA8B,GAC7B,EAAA,kBAAAA,cAAA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,EAAA,kBAC5BA,cAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAK,IAAI,EAAA,IAAA,EAAC,IAAE,IACX,EAAA,kBAAAA,cAAA,CAAA,aAAA;AAAA,QAAC,oBAAA;AAAA,QAAA;AAAA,UACC,WAAa,EAAA,cAAA;AAAA,YACX;AAAA,cACE,IAAA,EAAA,CAAM,EAAY,GAAA,WAAA,CAAA,QAAA,KAAZ,IAAsB,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAA;AAAA,cAC5B,SAAA,EAAA,CAAW,EAAY,GAAA,WAAA,CAAA,QAAA,KAAZ,IAAsB,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,SAAA;AAAA,cACjC,IAAM,EAAA,aAAA;AAAA,aACR;AAAA,YACA,gBAAiB,CAAA,wBAAA;AAAA,WACnB;AAAA,UACA,SAAW,EAAA,iBAAA,CAAkB,WAAa,EAAA,gBAAA,CAAiB,IAAI,CAAA;AAAA,UAC/D,WAAA;AAAA,SAAA;AAAA,OAEJ,CACF,CAAA,CAAA;AAAA,KACD,CAAA;AAAA,GACH,CAAA;AAEJ;;;;"}
@@ -0,0 +1,8 @@
1
+ import React__default from 'react';
2
+
3
+ const ClusterContext = React__default.createContext({
4
+ name: ""
5
+ });
6
+
7
+ export { ClusterContext };
8
+ //# sourceMappingURL=Cluster.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Cluster.esm.js","sources":["../../src/hooks/Cluster.ts"],"sourcesContent":["/*\n * Copyright 2021 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 */\nimport React from 'react';\nimport { ClusterAttributes } from '@backstage/plugin-kubernetes-common';\n\n/**\n * @public\n */\nexport const ClusterContext = React.createContext<ClusterAttributes>({\n name: '',\n});\n"],"names":["React"],"mappings":";;AAqBa,MAAA,cAAA,GAAiBA,eAAM,aAAiC,CAAA;AAAA,EACnE,IAAM,EAAA,EAAA;AACR,CAAC;;;;"}
@@ -0,0 +1,19 @@
1
+ import React__default from 'react';
2
+
3
+ const GroupedResponsesContext = React__default.createContext({
4
+ pods: [],
5
+ replicaSets: [],
6
+ deployments: [],
7
+ daemonSets: [],
8
+ services: [],
9
+ configMaps: [],
10
+ horizontalPodAutoscalers: [],
11
+ ingresses: [],
12
+ jobs: [],
13
+ cronJobs: [],
14
+ customResources: [],
15
+ statefulsets: []
16
+ });
17
+
18
+ export { GroupedResponsesContext };
19
+ //# sourceMappingURL=GroupedResponses.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GroupedResponses.esm.js","sources":["../../src/hooks/GroupedResponses.ts"],"sourcesContent":["/*\n * Copyright 2021 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 */\nimport React from 'react';\nimport { GroupedResponses } from '@backstage/plugin-kubernetes-common';\n\n/**\n *\n *\n * @public\n */\nexport const GroupedResponsesContext = React.createContext<GroupedResponses>({\n pods: [],\n replicaSets: [],\n deployments: [],\n daemonSets: [],\n services: [],\n configMaps: [],\n horizontalPodAutoscalers: [],\n ingresses: [],\n jobs: [],\n cronJobs: [],\n customResources: [],\n statefulsets: [],\n});\n"],"names":["React"],"mappings":";;AAuBa,MAAA,uBAAA,GAA0BA,eAAM,aAAgC,CAAA;AAAA,EAC3E,MAAM,EAAC;AAAA,EACP,aAAa,EAAC;AAAA,EACd,aAAa,EAAC;AAAA,EACd,YAAY,EAAC;AAAA,EACb,UAAU,EAAC;AAAA,EACX,YAAY,EAAC;AAAA,EACb,0BAA0B,EAAC;AAAA,EAC3B,WAAW,EAAC;AAAA,EACZ,MAAM,EAAC;AAAA,EACP,UAAU,EAAC;AAAA,EACX,iBAAiB,EAAC;AAAA,EAClB,cAAc,EAAC;AACjB,CAAC;;;;"}
@@ -0,0 +1,8 @@
1
+ import React__default from 'react';
2
+
3
+ const PodNamesWithErrorsContext = React__default.createContext(
4
+ /* @__PURE__ */ new Set()
5
+ );
6
+
7
+ export { PodNamesWithErrorsContext };
8
+ //# sourceMappingURL=PodNamesWithErrors.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PodNamesWithErrors.esm.js","sources":["../../src/hooks/PodNamesWithErrors.ts"],"sourcesContent":["/*\n * Copyright 2021 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 */\nimport React from 'react';\n\n/**\n * @public\n */\nexport const PodNamesWithErrorsContext = React.createContext<Set<string>>(\n new Set<string>(),\n);\n"],"names":["React"],"mappings":";;AAoBO,MAAM,4BAA4BA,cAAM,CAAA,aAAA;AAAA,sBACzC,GAAY,EAAA;AAClB;;;;"}
@@ -0,0 +1,6 @@
1
+ import React__default from 'react';
2
+
3
+ const PodNamesWithMetricsContext = React__default.createContext(/* @__PURE__ */ new Map());
4
+
5
+ export { PodNamesWithMetricsContext };
6
+ //# sourceMappingURL=PodNamesWithMetrics.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PodNamesWithMetrics.esm.js","sources":["../../src/hooks/PodNamesWithMetrics.ts"],"sourcesContent":["/*\n * Copyright 2021 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 */\nimport React from 'react';\nimport { ClientPodStatus } from '@backstage/plugin-kubernetes-common';\n\n/**\n * @public\n */\nexport const PodNamesWithMetricsContext = React.createContext<\n Map<string, ClientPodStatus>\n>(new Map<string, ClientPodStatus>());\n"],"names":["React"],"mappings":";;AAqBO,MAAM,0BAA6B,GAAAA,cAAA,CAAM,aAE9C,iBAAA,IAAI,KAA8B;;;;"}
@@ -0,0 +1,24 @@
1
+ const generateAuth = async (entity, kubernetesApi, kubernetesAuthProvidersApi) => {
2
+ var _a;
3
+ const clusters = await kubernetesApi.getClusters();
4
+ const authProviders = [
5
+ ...new Set(
6
+ clusters.map(
7
+ (c) => `${c.authProvider}${c.oidcTokenProvider ? `.${c.oidcTokenProvider}` : ""}`
8
+ )
9
+ )
10
+ ];
11
+ let requestBody = {
12
+ entity
13
+ };
14
+ for (const authProviderStr of authProviders) {
15
+ requestBody = await kubernetesAuthProvidersApi.decorateRequestBodyForAuth(
16
+ authProviderStr,
17
+ requestBody
18
+ );
19
+ }
20
+ return (_a = requestBody.auth) != null ? _a : {};
21
+ };
22
+
23
+ export { generateAuth };
24
+ //# sourceMappingURL=auth.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.esm.js","sources":["../../src/hooks/auth.ts"],"sourcesContent":["/*\n * Copyright 2022 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 { Entity } from '@backstage/catalog-model';\nimport { KubernetesRequestBody } from '@backstage/plugin-kubernetes-common';\nimport { KubernetesAuthProvidersApi } from '../kubernetes-auth-provider';\nimport { KubernetesApi } from '../api/types';\n\nexport const generateAuth = async (\n entity: Entity,\n kubernetesApi: KubernetesApi,\n kubernetesAuthProvidersApi: KubernetesAuthProvidersApi,\n) => {\n const clusters = await kubernetesApi.getClusters();\n\n const authProviders: string[] = [\n ...new Set(\n clusters.map(\n c =>\n `${c.authProvider}${\n c.oidcTokenProvider ? `.${c.oidcTokenProvider}` : ''\n }`,\n ),\n ),\n ];\n\n let requestBody: KubernetesRequestBody = {\n entity,\n };\n for (const authProviderStr of authProviders) {\n requestBody = await kubernetesAuthProvidersApi.decorateRequestBodyForAuth(\n authProviderStr,\n requestBody,\n );\n }\n return requestBody.auth ?? {};\n};\n"],"names":[],"mappings":"AAqBO,MAAM,YAAe,GAAA,OAC1B,MACA,EAAA,aAAA,EACA,0BACG,KAAA;AAzBL,EAAA,IAAA,EAAA,CAAA;AA0BE,EAAM,MAAA,QAAA,GAAW,MAAM,aAAA,CAAc,WAAY,EAAA,CAAA;AAEjD,EAAA,MAAM,aAA0B,GAAA;AAAA,IAC9B,GAAG,IAAI,GAAA;AAAA,MACL,QAAS,CAAA,GAAA;AAAA,QACP,CAAA,CAAA,KACE,CAAG,EAAA,CAAA,CAAE,YAAY,CAAA,EACf,CAAE,CAAA,iBAAA,GAAoB,CAAI,CAAA,EAAA,CAAA,CAAE,iBAAiB,CAAA,CAAA,GAAK,EACpD,CAAA,CAAA;AAAA,OACJ;AAAA,KACF;AAAA,GACF,CAAA;AAEA,EAAA,IAAI,WAAqC,GAAA;AAAA,IACvC,MAAA;AAAA,GACF,CAAA;AACA,EAAA,KAAA,MAAW,mBAAmB,aAAe,EAAA;AAC3C,IAAA,WAAA,GAAc,MAAM,0BAA2B,CAAA,0BAAA;AAAA,MAC7C,eAAA;AAAA,MACA,WAAA;AAAA,KACF,CAAA;AAAA,GACF;AACA,EAAO,OAAA,CAAA,EAAA,GAAA,WAAA,CAAY,IAAZ,KAAA,IAAA,GAAA,EAAA,GAAoB,EAAC,CAAA;AAC9B;;;;"}
@@ -0,0 +1,42 @@
1
+ import { useCallback } from 'react';
2
+ import useInterval from 'react-use/esm/useInterval';
3
+ import { useApi } from '@backstage/core-plugin-api';
4
+ import { generateAuth } from './auth.esm.js';
5
+ import useAsyncRetry from 'react-use/esm/useAsyncRetry';
6
+ import { kubernetesAuthProvidersApiRef } from '../kubernetes-auth-provider/types.esm.js';
7
+ import { kubernetesApiRef } from '../api/types.esm.js';
8
+
9
+ const useCustomResources = (entity, customResourceMatchers, intervalMs = 1e4) => {
10
+ const kubernetesApi = useApi(kubernetesApiRef);
11
+ const kubernetesAuthProvidersApi = useApi(kubernetesAuthProvidersApiRef);
12
+ const matchersString = JSON.stringify(customResourceMatchers);
13
+ const getCustomObjects = useCallback(
14
+ async () => {
15
+ const auth = await generateAuth(
16
+ entity,
17
+ kubernetesApi,
18
+ kubernetesAuthProvidersApi
19
+ );
20
+ return await kubernetesApi.getCustomObjectsByEntity({
21
+ auth,
22
+ customResources: customResourceMatchers,
23
+ entity
24
+ });
25
+ },
26
+ // eslint-disable-next-line react-hooks/exhaustive-deps
27
+ [kubernetesApi, entity, kubernetesAuthProvidersApi, matchersString]
28
+ );
29
+ const { value, loading, error, retry } = useAsyncRetry(
30
+ () => getCustomObjects(),
31
+ [getCustomObjects]
32
+ );
33
+ useInterval(() => retry(), intervalMs);
34
+ return {
35
+ kubernetesObjects: value,
36
+ loading,
37
+ error: error == null ? void 0 : error.message
38
+ };
39
+ };
40
+
41
+ export { useCustomResources };
42
+ //# sourceMappingURL=useCustomResources.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCustomResources.esm.js","sources":["../../src/hooks/useCustomResources.ts"],"sourcesContent":["/*\n * Copyright 2022 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 { Entity } from '@backstage/catalog-model';\nimport { useCallback } from 'react';\nimport useInterval from 'react-use/esm/useInterval';\nimport {\n CustomResourceMatcher,\n ObjectsByEntityResponse,\n} from '@backstage/plugin-kubernetes-common';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { KubernetesObjects } from './useKubernetesObjects';\nimport { generateAuth } from './auth';\nimport useAsyncRetry from 'react-use/esm/useAsyncRetry';\nimport { kubernetesAuthProvidersApiRef } from '../kubernetes-auth-provider';\nimport { kubernetesApiRef } from '../api/types';\n\n/**\n * Retrieves the provided custom resources related to the provided entity, refreshes at an interval.\n *\n * @public\n */\nexport const useCustomResources = (\n entity: Entity,\n customResourceMatchers: CustomResourceMatcher[],\n intervalMs: number = 10000,\n): KubernetesObjects => {\n const kubernetesApi = useApi(kubernetesApiRef);\n const kubernetesAuthProvidersApi = useApi(kubernetesAuthProvidersApiRef);\n const matchersString = JSON.stringify(customResourceMatchers);\n const getCustomObjects = useCallback(\n async (): Promise<ObjectsByEntityResponse> => {\n const auth = await generateAuth(\n entity,\n kubernetesApi,\n kubernetesAuthProvidersApi,\n );\n return await kubernetesApi.getCustomObjectsByEntity({\n auth,\n customResources: customResourceMatchers,\n entity,\n });\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [kubernetesApi, entity, kubernetesAuthProvidersApi, matchersString],\n );\n\n const { value, loading, error, retry } = useAsyncRetry(\n () => getCustomObjects(),\n [getCustomObjects],\n );\n\n useInterval(() => retry(), intervalMs);\n\n return {\n kubernetesObjects: value,\n loading,\n error: error?.message,\n };\n};\n"],"names":[],"mappings":";;;;;;;;AAmCO,MAAM,kBAAqB,GAAA,CAChC,MACA,EAAA,sBAAA,EACA,aAAqB,GACC,KAAA;AACtB,EAAM,MAAA,aAAA,GAAgB,OAAO,gBAAgB,CAAA,CAAA;AAC7C,EAAM,MAAA,0BAAA,GAA6B,OAAO,6BAA6B,CAAA,CAAA;AACvE,EAAM,MAAA,cAAA,GAAiB,IAAK,CAAA,SAAA,CAAU,sBAAsB,CAAA,CAAA;AAC5D,EAAA,MAAM,gBAAmB,GAAA,WAAA;AAAA,IACvB,YAA8C;AAC5C,MAAA,MAAM,OAAO,MAAM,YAAA;AAAA,QACjB,MAAA;AAAA,QACA,aAAA;AAAA,QACA,0BAAA;AAAA,OACF,CAAA;AACA,MAAO,OAAA,MAAM,cAAc,wBAAyB,CAAA;AAAA,QAClD,IAAA;AAAA,QACA,eAAiB,EAAA,sBAAA;AAAA,QACjB,MAAA;AAAA,OACD,CAAA,CAAA;AAAA,KACH;AAAA;AAAA,IAEA,CAAC,aAAA,EAAe,MAAQ,EAAA,0BAAA,EAA4B,cAAc,CAAA;AAAA,GACpE,CAAA;AAEA,EAAA,MAAM,EAAE,KAAA,EAAO,OAAS,EAAA,KAAA,EAAO,OAAU,GAAA,aAAA;AAAA,IACvC,MAAM,gBAAiB,EAAA;AAAA,IACvB,CAAC,gBAAgB,CAAA;AAAA,GACnB,CAAA;AAEA,EAAY,WAAA,CAAA,MAAM,KAAM,EAAA,EAAG,UAAU,CAAA,CAAA;AAErC,EAAO,OAAA;AAAA,IACL,iBAAmB,EAAA,KAAA;AAAA,IACnB,OAAA;AAAA,IACA,OAAO,KAAO,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,KAAA,CAAA,OAAA;AAAA,GAChB,CAAA;AACF;;;;"}
@@ -0,0 +1,9 @@
1
+ import { useApi, configApiRef } from '@backstage/core-plugin-api';
2
+
3
+ const useIsPodExecTerminalEnabled = () => {
4
+ const configApi = useApi(configApiRef);
5
+ return configApi.getOptionalBoolean("kubernetes.podExecTerminal.enabled");
6
+ };
7
+
8
+ export { useIsPodExecTerminalEnabled };
9
+ //# sourceMappingURL=useIsPodExecTerminalEnabled.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIsPodExecTerminalEnabled.esm.js","sources":["../../src/hooks/useIsPodExecTerminalEnabled.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 */\nimport { configApiRef, useApi } from '@backstage/core-plugin-api';\n\n/**\n * Check if conditions for a pod exec call through the proxy endpoint are met\n *\n * @internal\n */\nexport const useIsPodExecTerminalEnabled = (): boolean | undefined => {\n const configApi = useApi(configApiRef);\n\n return configApi.getOptionalBoolean('kubernetes.podExecTerminal.enabled');\n};\n"],"names":[],"mappings":";;AAsBO,MAAM,8BAA8B,MAA2B;AACpE,EAAM,MAAA,SAAA,GAAY,OAAO,YAAY,CAAA,CAAA;AAErC,EAAO,OAAA,SAAA,CAAU,mBAAmB,oCAAoC,CAAA,CAAA;AAC1E;;;;"}
@@ -0,0 +1,21 @@
1
+ import { useApi } from '@backstage/core-plugin-api';
2
+ import useAsync from 'react-use/esm/useAsync';
3
+ import { kubernetesApiRef } from '../api/types.esm.js';
4
+
5
+ const useIsPodExecTerminalSupported = () => {
6
+ const kubernetesApi = useApi(kubernetesApiRef);
7
+ return useAsync(async () => {
8
+ const clusters = await kubernetesApi.getClusters();
9
+ if (clusters.length !== 1) {
10
+ return false;
11
+ }
12
+ const { authProvider } = clusters[0];
13
+ const isClientAuthProvider = ["aks", "google", "oidc"].some(
14
+ (authProviderName) => authProvider.includes(authProviderName)
15
+ );
16
+ return !isClientAuthProvider;
17
+ });
18
+ };
19
+
20
+ export { useIsPodExecTerminalSupported };
21
+ //# sourceMappingURL=useIsPodExecTerminalSupported.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIsPodExecTerminalSupported.esm.js","sources":["../../src/hooks/useIsPodExecTerminalSupported.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 */\nimport { useApi } from '@backstage/core-plugin-api';\nimport useAsync, { AsyncState } from 'react-use/esm/useAsync';\n\nimport { kubernetesApiRef } from '../api/types';\n\n/**\n * Check if conditions for a pod exec call through the proxy endpoint are met\n *\n * @internal\n */\nexport const useIsPodExecTerminalSupported = (): AsyncState<boolean> => {\n const kubernetesApi = useApi(kubernetesApiRef);\n\n return useAsync(async () => {\n const clusters = await kubernetesApi.getClusters();\n\n if (clusters.length !== 1) {\n return false;\n }\n\n const { authProvider } = clusters[0];\n const isClientAuthProvider = ['aks', 'google', 'oidc'].some(\n authProviderName => authProvider.includes(authProviderName),\n );\n\n return !isClientAuthProvider;\n });\n};\n"],"names":[],"mappings":";;;;AAyBO,MAAM,gCAAgC,MAA2B;AACtE,EAAM,MAAA,aAAA,GAAgB,OAAO,gBAAgB,CAAA,CAAA;AAE7C,EAAA,OAAO,SAAS,YAAY;AAC1B,IAAM,MAAA,QAAA,GAAW,MAAM,aAAA,CAAc,WAAY,EAAA,CAAA;AAEjD,IAAI,IAAA,QAAA,CAAS,WAAW,CAAG,EAAA;AACzB,MAAO,OAAA,KAAA,CAAA;AAAA,KACT;AAEA,IAAA,MAAM,EAAE,YAAA,EAAiB,GAAA,QAAA,CAAS,CAAC,CAAA,CAAA;AACnC,IAAA,MAAM,oBAAuB,GAAA,CAAC,KAAO,EAAA,QAAA,EAAU,MAAM,CAAE,CAAA,IAAA;AAAA,MACrD,CAAA,gBAAA,KAAoB,YAAa,CAAA,QAAA,CAAS,gBAAgB,CAAA;AAAA,KAC5D,CAAA;AAEA,IAAA,OAAO,CAAC,oBAAA,CAAA;AAAA,GACT,CAAA,CAAA;AACH;;;;"}
@@ -0,0 +1,36 @@
1
+ import { useCallback } from 'react';
2
+ import useInterval from 'react-use/esm/useInterval';
3
+ import { useApi } from '@backstage/core-plugin-api';
4
+ import { generateAuth } from './auth.esm.js';
5
+ import useAsyncRetry from 'react-use/esm/useAsyncRetry';
6
+ import { kubernetesAuthProvidersApiRef } from '../kubernetes-auth-provider/types.esm.js';
7
+ import { kubernetesApiRef } from '../api/types.esm.js';
8
+
9
+ const useKubernetesObjects = (entity, intervalMs = 1e4) => {
10
+ const kubernetesApi = useApi(kubernetesApiRef);
11
+ const kubernetesAuthProvidersApi = useApi(kubernetesAuthProvidersApiRef);
12
+ const getObjects = useCallback(async () => {
13
+ const auth = await generateAuth(
14
+ entity,
15
+ kubernetesApi,
16
+ kubernetesAuthProvidersApi
17
+ );
18
+ return await kubernetesApi.getObjectsByEntity({
19
+ auth,
20
+ entity
21
+ });
22
+ }, [kubernetesApi, entity, kubernetesAuthProvidersApi]);
23
+ const { value, loading, error, retry } = useAsyncRetry(
24
+ () => getObjects(),
25
+ [getObjects]
26
+ );
27
+ useInterval(() => retry(), intervalMs);
28
+ return {
29
+ kubernetesObjects: value,
30
+ loading,
31
+ error: error == null ? void 0 : error.message
32
+ };
33
+ };
34
+
35
+ export { useKubernetesObjects };
36
+ //# sourceMappingURL=useKubernetesObjects.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useKubernetesObjects.esm.js","sources":["../../src/hooks/useKubernetesObjects.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { Entity } from '@backstage/catalog-model';\nimport { useCallback } from 'react';\nimport useInterval from 'react-use/esm/useInterval';\nimport { ObjectsByEntityResponse } from '@backstage/plugin-kubernetes-common';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { generateAuth } from './auth';\nimport useAsyncRetry from 'react-use/esm/useAsyncRetry';\nimport { kubernetesAuthProvidersApiRef } from '../kubernetes-auth-provider';\nimport { kubernetesApiRef } from '../api/types';\n\n/**\n *\n * @public\n */\nexport interface KubernetesObjects {\n kubernetesObjects?: ObjectsByEntityResponse;\n loading: boolean;\n error?: string;\n}\n\n/**\n *\n * @public\n */\nexport const useKubernetesObjects = (\n entity: Entity,\n intervalMs: number = 10000,\n): KubernetesObjects => {\n const kubernetesApi = useApi(kubernetesApiRef);\n const kubernetesAuthProvidersApi = useApi(kubernetesAuthProvidersApiRef);\n const getObjects = useCallback(async (): Promise<ObjectsByEntityResponse> => {\n const auth = await generateAuth(\n entity,\n kubernetesApi,\n kubernetesAuthProvidersApi,\n );\n return await kubernetesApi.getObjectsByEntity({\n auth,\n entity,\n });\n }, [kubernetesApi, entity, kubernetesAuthProvidersApi]);\n\n const { value, loading, error, retry } = useAsyncRetry(\n () => getObjects(),\n [getObjects],\n );\n\n useInterval(() => retry(), intervalMs);\n\n return {\n kubernetesObjects: value,\n loading,\n error: error?.message,\n };\n};\n"],"names":[],"mappings":";;;;;;;;AAwCO,MAAM,oBAAuB,GAAA,CAClC,MACA,EAAA,UAAA,GAAqB,GACC,KAAA;AACtB,EAAM,MAAA,aAAA,GAAgB,OAAO,gBAAgB,CAAA,CAAA;AAC7C,EAAM,MAAA,0BAAA,GAA6B,OAAO,6BAA6B,CAAA,CAAA;AACvE,EAAM,MAAA,UAAA,GAAa,YAAY,YAA8C;AAC3E,IAAA,MAAM,OAAO,MAAM,YAAA;AAAA,MACjB,MAAA;AAAA,MACA,aAAA;AAAA,MACA,0BAAA;AAAA,KACF,CAAA;AACA,IAAO,OAAA,MAAM,cAAc,kBAAmB,CAAA;AAAA,MAC5C,IAAA;AAAA,MACA,MAAA;AAAA,KACD,CAAA,CAAA;AAAA,GACA,EAAA,CAAC,aAAe,EAAA,MAAA,EAAQ,0BAA0B,CAAC,CAAA,CAAA;AAEtD,EAAA,MAAM,EAAE,KAAA,EAAO,OAAS,EAAA,KAAA,EAAO,OAAU,GAAA,aAAA;AAAA,IACvC,MAAM,UAAW,EAAA;AAAA,IACjB,CAAC,UAAU,CAAA;AAAA,GACb,CAAA;AAEA,EAAY,WAAA,CAAA,MAAM,KAAM,EAAA,EAAG,UAAU,CAAA,CAAA;AAErC,EAAO,OAAA;AAAA,IACL,iBAAmB,EAAA,KAAA;AAAA,IACnB,OAAA;AAAA,IACA,OAAO,KAAO,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,KAAA,CAAA,OAAA;AAAA,GAChB,CAAA;AACF;;;;"}
@@ -0,0 +1,20 @@
1
+ import React__default, { useContext } from 'react';
2
+
3
+ const DetectedErrorsContext = React__default.createContext([]);
4
+ const useMatchingErrors = (matcher) => {
5
+ var _a, _b, _c, _d;
6
+ const targetRef = {
7
+ name: (_b = (_a = matcher.metadata) == null ? void 0 : _a.name) != null ? _b : "",
8
+ namespace: (_d = (_c = matcher.metadata) == null ? void 0 : _c.namespace) != null ? _d : "",
9
+ kind: matcher.kind,
10
+ apiGroup: matcher.apiVersion
11
+ };
12
+ const errors = useContext(DetectedErrorsContext);
13
+ return errors.filter((e) => {
14
+ const r = e.sourceRef;
15
+ return targetRef.apiGroup === r.apiGroup && targetRef.kind === r.kind && targetRef.name === r.name && targetRef.namespace === r.namespace;
16
+ });
17
+ };
18
+
19
+ export { DetectedErrorsContext, useMatchingErrors };
20
+ //# sourceMappingURL=useMatchingErrors.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMatchingErrors.esm.js","sources":["../../src/hooks/useMatchingErrors.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 */\nimport React, { useContext } from 'react';\nimport {\n DetectedError,\n ResourceRef,\n} from '@backstage/plugin-kubernetes-common';\nimport { TypeMeta } from '@kubernetes-models/base';\nimport { IIoK8sApimachineryPkgApisMetaV1ObjectMeta as V1ObjectMeta } from '@kubernetes-models/apimachinery/apis/meta/v1/ObjectMeta';\n\n/**\n * Context for detected errors\n *\n * @public\n */\nexport const DetectedErrorsContext = React.createContext<DetectedError[]>([]);\n\n/**\n *\n * @public\n */\nexport type ErrorMatcher = {\n metadata?: V1ObjectMeta;\n} & TypeMeta;\n\n/**\n * Find errors which match the resource\n *\n * @public\n */\nexport const useMatchingErrors = (matcher: ErrorMatcher): DetectedError[] => {\n const targetRef: ResourceRef = {\n name: matcher.metadata?.name ?? '',\n namespace: matcher.metadata?.namespace ?? '',\n kind: matcher.kind,\n apiGroup: matcher.apiVersion,\n };\n\n const errors = useContext(DetectedErrorsContext);\n\n return errors.filter(e => {\n const r = e.sourceRef;\n return (\n targetRef.apiGroup === r.apiGroup &&\n targetRef.kind === r.kind &&\n targetRef.name === r.name &&\n targetRef.namespace === r.namespace\n );\n });\n};\n"],"names":["React"],"mappings":";;AA4BO,MAAM,qBAAwB,GAAAA,cAAA,CAAM,aAA+B,CAAA,EAAE,EAAA;AAe/D,MAAA,iBAAA,GAAoB,CAAC,OAA2C,KAAA;AA3C7E,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AA4CE,EAAA,MAAM,SAAyB,GAAA;AAAA,IAC7B,IAAM,EAAA,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,OAAA,CAAQ,QAAR,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAkB,SAAlB,IAA0B,GAAA,EAAA,GAAA,EAAA;AAAA,IAChC,SAAW,EAAA,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,OAAA,CAAQ,QAAR,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAkB,cAAlB,IAA+B,GAAA,EAAA,GAAA,EAAA;AAAA,IAC1C,MAAM,OAAQ,CAAA,IAAA;AAAA,IACd,UAAU,OAAQ,CAAA,UAAA;AAAA,GACpB,CAAA;AAEA,EAAM,MAAA,MAAA,GAAS,WAAW,qBAAqB,CAAA,CAAA;AAE/C,EAAO,OAAA,MAAA,CAAO,OAAO,CAAK,CAAA,KAAA;AACxB,IAAA,MAAM,IAAI,CAAE,CAAA,SAAA,CAAA;AACZ,IAAA,OACE,SAAU,CAAA,QAAA,KAAa,CAAE,CAAA,QAAA,IACzB,UAAU,IAAS,KAAA,CAAA,CAAE,IACrB,IAAA,SAAA,CAAU,IAAS,KAAA,CAAA,CAAE,IACrB,IAAA,SAAA,CAAU,cAAc,CAAE,CAAA,SAAA,CAAA;AAAA,GAE7B,CAAA,CAAA;AACH;;;;"}
@@ -0,0 +1,20 @@
1
+ import React__default, { useContext } from 'react';
2
+
3
+ const PodMetricsContext = React__default.createContext(/* @__PURE__ */ new Map());
4
+ const usePodMetrics = (clusterName, matcher) => {
5
+ var _a, _b, _c, _d;
6
+ const targetRef = {
7
+ name: (_b = (_a = matcher.metadata) == null ? void 0 : _a.name) != null ? _b : "",
8
+ namespace: (_d = (_c = matcher.metadata) == null ? void 0 : _c.namespace) != null ? _d : ""
9
+ };
10
+ const metricsMap = useContext(PodMetricsContext);
11
+ const metrics = metricsMap.get(clusterName);
12
+ return metrics == null ? void 0 : metrics.find((m) => {
13
+ var _a2, _b2, _c2, _d2;
14
+ const pod = m.pod;
15
+ return targetRef.name === ((_b2 = (_a2 = pod.metadata) == null ? void 0 : _a2.name) != null ? _b2 : "") && targetRef.namespace === ((_d2 = (_c2 = pod.metadata) == null ? void 0 : _c2.namespace) != null ? _d2 : "");
16
+ });
17
+ };
18
+
19
+ export { PodMetricsContext, usePodMetrics };
20
+ //# sourceMappingURL=usePodMetrics.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePodMetrics.esm.js","sources":["../../src/hooks/usePodMetrics.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 */\nimport React, { useContext } from 'react';\nimport { IObjectMeta } from '@kubernetes-models/apimachinery/apis/meta/v1/ObjectMeta';\nimport { ClientPodStatus } from '@backstage/plugin-kubernetes-common';\n\n/**\n * Context for Pod Metrics\n *\n * @public\n */\nexport const PodMetricsContext = React.createContext<\n Map<string, ClientPodStatus[]>\n>(new Map());\n\n/**\n * @public\n */\nexport type PodMetricsMatcher = {\n metadata?: IObjectMeta;\n};\n\n/**\n * Find metrics matching the provided pod\n *\n * @public\n */\nexport const usePodMetrics = (\n clusterName: string,\n matcher: PodMetricsMatcher,\n): ClientPodStatus | undefined => {\n const targetRef = {\n name: matcher.metadata?.name ?? '',\n namespace: matcher.metadata?.namespace ?? '',\n };\n\n const metricsMap = useContext(PodMetricsContext);\n\n const metrics = metricsMap.get(clusterName);\n\n return metrics?.find(m => {\n const pod = m.pod;\n return (\n targetRef.name === (pod.metadata?.name ?? '') &&\n targetRef.namespace === (pod.metadata?.namespace ?? '')\n );\n });\n};\n"],"names":["React","_a","_b","_c","_d"],"mappings":";;AAwBO,MAAM,iBAAoB,GAAAA,cAAA,CAAM,aAErC,iBAAA,IAAI,KAAK,EAAA;AAcE,MAAA,aAAA,GAAgB,CAC3B,WAAA,EACA,OACgC,KAAA;AA3ClC,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AA4CE,EAAA,MAAM,SAAY,GAAA;AAAA,IAChB,IAAM,EAAA,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,OAAA,CAAQ,QAAR,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAkB,SAAlB,IAA0B,GAAA,EAAA,GAAA,EAAA;AAAA,IAChC,SAAW,EAAA,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,OAAA,CAAQ,QAAR,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAkB,cAAlB,IAA+B,GAAA,EAAA,GAAA,EAAA;AAAA,GAC5C,CAAA;AAEA,EAAM,MAAA,UAAA,GAAa,WAAW,iBAAiB,CAAA,CAAA;AAE/C,EAAM,MAAA,OAAA,GAAU,UAAW,CAAA,GAAA,CAAI,WAAW,CAAA,CAAA;AAE1C,EAAO,OAAA,OAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,OAAA,CAAS,KAAK,CAAK,CAAA,KAAA;AArD5B,IAAAC,IAAAA,GAAAA,EAAAC,KAAAC,GAAAC,EAAAA,GAAAA,CAAAA;AAsDI,IAAA,MAAM,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