@backstage/plugin-kubernetes 0.7.0 → 0.7.1-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/dist/index.esm.js CHANGED
@@ -52,7 +52,10 @@ class KubernetesBackendClient {
52
52
  return this.handleResponse(response);
53
53
  }
54
54
  async getObjectsByEntity(requestBody) {
55
- return await this.postRequired(`/services/${requestBody.entity.metadata.name}`, requestBody);
55
+ return await this.postRequired(
56
+ `/services/${requestBody.entity.metadata.name}`,
57
+ requestBody
58
+ );
56
59
  }
57
60
  async getClusters() {
58
61
  const { token: idToken } = await this.identityApi.getCredentials();
@@ -80,7 +83,9 @@ class GoogleKubernetesAuthProvider {
80
83
  this.authProvider = authProvider;
81
84
  }
82
85
  async decorateRequestBodyForAuth(requestBody) {
83
- const googleAuthToken = await this.authProvider.getAccessToken("https://www.googleapis.com/auth/cloud-platform");
86
+ const googleAuthToken = await this.authProvider.getAccessToken(
87
+ "https://www.googleapis.com/auth/cloud-platform"
88
+ );
84
89
  if ("auth" in requestBody) {
85
90
  requestBody.auth.google = googleAuthToken;
86
91
  } else {
@@ -117,27 +122,57 @@ class OidcKubernetesAuthProvider {
117
122
  class KubernetesAuthProviders {
118
123
  constructor(options) {
119
124
  this.kubernetesAuthProviderMap = /* @__PURE__ */ new Map();
120
- this.kubernetesAuthProviderMap.set("google", new GoogleKubernetesAuthProvider(options.googleAuthApi));
121
- this.kubernetesAuthProviderMap.set("serviceAccount", new ServerSideKubernetesAuthProvider());
122
- this.kubernetesAuthProviderMap.set("googleServiceAccount", new ServerSideKubernetesAuthProvider());
123
- this.kubernetesAuthProviderMap.set("aws", new ServerSideKubernetesAuthProvider());
124
- this.kubernetesAuthProviderMap.set("azure", new ServerSideKubernetesAuthProvider());
125
- this.kubernetesAuthProviderMap.set("localKubectlProxy", new ServerSideKubernetesAuthProvider());
125
+ this.kubernetesAuthProviderMap.set(
126
+ "google",
127
+ new GoogleKubernetesAuthProvider(options.googleAuthApi)
128
+ );
129
+ this.kubernetesAuthProviderMap.set(
130
+ "serviceAccount",
131
+ new ServerSideKubernetesAuthProvider()
132
+ );
133
+ this.kubernetesAuthProviderMap.set(
134
+ "googleServiceAccount",
135
+ new ServerSideKubernetesAuthProvider()
136
+ );
137
+ this.kubernetesAuthProviderMap.set(
138
+ "aws",
139
+ new ServerSideKubernetesAuthProvider()
140
+ );
141
+ this.kubernetesAuthProviderMap.set(
142
+ "azure",
143
+ new ServerSideKubernetesAuthProvider()
144
+ );
145
+ this.kubernetesAuthProviderMap.set(
146
+ "localKubectlProxy",
147
+ new ServerSideKubernetesAuthProvider()
148
+ );
126
149
  if (options.oidcProviders) {
127
150
  Object.keys(options.oidcProviders).forEach((provider) => {
128
- this.kubernetesAuthProviderMap.set(`oidc.${provider}`, new OidcKubernetesAuthProvider(provider, options.oidcProviders[provider]));
151
+ this.kubernetesAuthProviderMap.set(
152
+ `oidc.${provider}`,
153
+ new OidcKubernetesAuthProvider(
154
+ provider,
155
+ options.oidcProviders[provider]
156
+ )
157
+ );
129
158
  });
130
159
  }
131
160
  }
132
161
  async decorateRequestBodyForAuth(authProvider, requestBody) {
133
162
  const kubernetesAuthProvider = this.kubernetesAuthProviderMap.get(authProvider);
134
163
  if (kubernetesAuthProvider) {
135
- return await kubernetesAuthProvider.decorateRequestBodyForAuth(requestBody);
164
+ return await kubernetesAuthProvider.decorateRequestBodyForAuth(
165
+ requestBody
166
+ );
136
167
  }
137
168
  if (authProvider.startsWith("oidc.")) {
138
- throw new Error(`KubernetesAuthProviders has no oidcProvider configured for ${authProvider}`);
169
+ throw new Error(
170
+ `KubernetesAuthProviders has no oidcProvider configured for ${authProvider}`
171
+ );
139
172
  }
140
- throw new Error(`authProvider "${authProvider}" has no KubernetesAuthProvider defined for it`);
173
+ throw new Error(
174
+ `authProvider "${authProvider}" has no KubernetesAuthProvider defined for it`
175
+ );
141
176
  }
142
177
  }
143
178
 
@@ -183,11 +218,13 @@ const kubernetesPlugin = createPlugin({
183
218
  entityContent: rootCatalogKubernetesRouteRef
184
219
  }
185
220
  });
186
- const EntityKubernetesContent = kubernetesPlugin.provide(createRoutableExtension({
187
- name: "EntityKubernetesContent",
188
- component: () => Promise.resolve().then(function () { return Router$1; }).then((m) => m.Router),
189
- mountPoint: rootCatalogKubernetesRouteRef
190
- }));
221
+ const EntityKubernetesContent = kubernetesPlugin.provide(
222
+ createRoutableExtension({
223
+ name: "EntityKubernetesContent",
224
+ component: () => Promise.resolve().then(function () { return Router$1; }).then((m) => m.Router),
225
+ mountPoint: rootCatalogKubernetesRouteRef
226
+ })
227
+ );
191
228
 
192
229
  const clustersWithErrorsToErrorMessage = (clustersWithErrors) => {
193
230
  return clustersWithErrors.map((c, i) => {
@@ -291,56 +328,59 @@ const ErrorReporting = ({ detectedErrors }) => {
291
328
  };
292
329
 
293
330
  const groupResponses = (fetchResponse) => {
294
- return fetchResponse.reduce((prev, next) => {
295
- switch (next.type) {
296
- case "deployments":
297
- prev.deployments.push(...next.resources);
298
- break;
299
- case "pods":
300
- prev.pods.push(...next.resources);
301
- break;
302
- case "replicasets":
303
- prev.replicaSets.push(...next.resources);
304
- break;
305
- case "services":
306
- prev.services.push(...next.resources);
307
- break;
308
- case "configmaps":
309
- prev.configMaps.push(...next.resources);
310
- break;
311
- case "horizontalpodautoscalers":
312
- prev.horizontalPodAutoscalers.push(...next.resources);
313
- break;
314
- case "ingresses":
315
- prev.ingresses.push(...next.resources);
316
- break;
317
- case "jobs":
318
- prev.jobs.push(...next.resources);
319
- break;
320
- case "cronjobs":
321
- prev.cronJobs.push(...next.resources);
322
- break;
323
- case "customresources":
324
- prev.customResources.push(...next.resources);
325
- break;
326
- case "statefulsets":
327
- prev.statefulsets.push(...next.resources);
328
- break;
331
+ return fetchResponse.reduce(
332
+ (prev, next) => {
333
+ switch (next.type) {
334
+ case "deployments":
335
+ prev.deployments.push(...next.resources);
336
+ break;
337
+ case "pods":
338
+ prev.pods.push(...next.resources);
339
+ break;
340
+ case "replicasets":
341
+ prev.replicaSets.push(...next.resources);
342
+ break;
343
+ case "services":
344
+ prev.services.push(...next.resources);
345
+ break;
346
+ case "configmaps":
347
+ prev.configMaps.push(...next.resources);
348
+ break;
349
+ case "horizontalpodautoscalers":
350
+ prev.horizontalPodAutoscalers.push(...next.resources);
351
+ break;
352
+ case "ingresses":
353
+ prev.ingresses.push(...next.resources);
354
+ break;
355
+ case "jobs":
356
+ prev.jobs.push(...next.resources);
357
+ break;
358
+ case "cronjobs":
359
+ prev.cronJobs.push(...next.resources);
360
+ break;
361
+ case "customresources":
362
+ prev.customResources.push(...next.resources);
363
+ break;
364
+ case "statefulsets":
365
+ prev.statefulsets.push(...next.resources);
366
+ break;
367
+ }
368
+ return prev;
369
+ },
370
+ {
371
+ pods: [],
372
+ replicaSets: [],
373
+ deployments: [],
374
+ services: [],
375
+ configMaps: [],
376
+ horizontalPodAutoscalers: [],
377
+ ingresses: [],
378
+ jobs: [],
379
+ cronJobs: [],
380
+ customResources: [],
381
+ statefulsets: []
329
382
  }
330
- return prev;
331
- }, {
332
- pods: [],
333
- replicaSets: [],
334
- deployments: [],
335
- services: [],
336
- configMaps: [],
337
- horizontalPodAutoscalers: [],
338
- ingresses: [],
339
- jobs: [],
340
- cronJobs: [],
341
- customResources: [],
342
- statefulsets: []
343
- });
383
+ );
344
384
  };
345
385
 
346
386
  const imageChips = (pod) => {
@@ -433,8 +473,14 @@ const podStatusToCpuUtil = (podStatus) => {
433
473
  currentUsage = cpuUtil.currentUsage / 10;
434
474
  }
435
475
  return /* @__PURE__ */ React__default.createElement(SubvalueCell, {
436
- value: `requests: ${currentToDeclaredResourceToPerc(currentUsage, cpuUtil.requestTotal)} of ${formatMilicores(cpuUtil.requestTotal)}`,
437
- subvalue: `limits: ${currentToDeclaredResourceToPerc(currentUsage, cpuUtil.limitTotal)} of ${formatMilicores(cpuUtil.limitTotal)}`
476
+ value: `requests: ${currentToDeclaredResourceToPerc(
477
+ currentUsage,
478
+ cpuUtil.requestTotal
479
+ )} of ${formatMilicores(cpuUtil.requestTotal)}`,
480
+ subvalue: `limits: ${currentToDeclaredResourceToPerc(
481
+ currentUsage,
482
+ cpuUtil.limitTotal
483
+ )} of ${formatMilicores(cpuUtil.limitTotal)}`
438
484
  });
439
485
  };
440
486
  const bytesToMiB = (value) => {
@@ -443,8 +489,14 @@ const bytesToMiB = (value) => {
443
489
  const podStatusToMemoryUtil = (podStatus) => {
444
490
  const memUtil = podStatus.memory;
445
491
  return /* @__PURE__ */ React__default.createElement(SubvalueCell, {
446
- value: `requests: ${currentToDeclaredResourceToPerc(memUtil.currentUsage, memUtil.requestTotal)} of ${bytesToMiB(memUtil.requestTotal)}`,
447
- subvalue: `limits: ${currentToDeclaredResourceToPerc(memUtil.currentUsage, memUtil.limitTotal)} of ${bytesToMiB(memUtil.limitTotal)}`
492
+ value: `requests: ${currentToDeclaredResourceToPerc(
493
+ memUtil.currentUsage,
494
+ memUtil.requestTotal
495
+ )} of ${bytesToMiB(memUtil.requestTotal)}`,
496
+ subvalue: `limits: ${currentToDeclaredResourceToPerc(
497
+ memUtil.currentUsage,
498
+ memUtil.limitTotal
499
+ )} of ${bytesToMiB(memUtil.limitTotal)}`
448
500
  });
449
501
  };
450
502
 
@@ -520,10 +572,12 @@ const podErrorMappers = [
520
572
  errorExplanation: "container-waiting",
521
573
  errorExists: (pod) => {
522
574
  var _a, _b;
523
- return ((_b = (_a = pod.status) == null ? void 0 : _a.containerStatuses) != null ? _b : []).some((cs) => {
524
- var _a2, _b2;
525
- return ((_b2 = (_a2 = cs.state) == null ? void 0 : _a2.waiting) == null ? void 0 : _b2.message) !== void 0;
526
- });
575
+ return ((_b = (_a = pod.status) == null ? void 0 : _a.containerStatuses) != null ? _b : []).some(
576
+ (cs) => {
577
+ var _a2, _b2;
578
+ return ((_b2 = (_a2 = cs.state) == null ? void 0 : _a2.waiting) == null ? void 0 : _b2.message) !== void 0;
579
+ }
580
+ );
527
581
  },
528
582
  messageAccessor: (pod) => {
529
583
  var _a, _b;
@@ -541,20 +595,24 @@ const podErrorMappers = [
541
595
  errorExplanation: "container-last-state-error",
542
596
  errorExists: (pod) => {
543
597
  var _a, _b;
544
- return ((_b = (_a = pod.status) == null ? void 0 : _a.containerStatuses) != null ? _b : []).some((cs) => {
545
- var _a2, _b2, _c;
546
- return ((_c = (_b2 = (_a2 = cs.lastState) == null ? void 0 : _a2.terminated) == null ? void 0 : _b2.reason) != null ? _c : "") === "Error";
547
- });
598
+ return ((_b = (_a = pod.status) == null ? void 0 : _a.containerStatuses) != null ? _b : []).some(
599
+ (cs) => {
600
+ var _a2, _b2, _c;
601
+ return ((_c = (_b2 = (_a2 = cs.lastState) == null ? void 0 : _a2.terminated) == null ? void 0 : _b2.reason) != null ? _c : "") === "Error";
602
+ }
603
+ );
548
604
  },
549
605
  messageAccessor: (pod) => {
550
606
  var _a, _b;
551
607
  return ((_b = (_a = pod.status) == null ? void 0 : _a.containerStatuses) != null ? _b : []).filter((cs) => {
552
608
  var _a2, _b2, _c;
553
609
  return ((_c = (_b2 = (_a2 = cs.lastState) == null ? void 0 : _a2.terminated) == null ? void 0 : _b2.reason) != null ? _c : "") === "Error";
554
- }).map((cs) => {
555
- var _a2, _b2;
556
- return `container=${cs.name} exited with error code (${(_b2 = (_a2 = cs.lastState) == null ? void 0 : _a2.terminated) == null ? void 0 : _b2.exitCode})`;
557
- });
610
+ }).map(
611
+ (cs) => {
612
+ var _a2, _b2;
613
+ return `container=${cs.name} exited with error code (${(_b2 = (_a2 = cs.lastState) == null ? void 0 : _a2.terminated) == null ? void 0 : _b2.exitCode})`;
614
+ }
615
+ );
558
616
  }
559
617
  }
560
618
  ];
@@ -577,7 +635,12 @@ const deploymentErrorMappers = [
577
635
  }
578
636
  }
579
637
  ];
580
- const detectErrorsInDeployments = (deployments, clusterName) => detectErrorsInObjects(deployments, "Deployment", clusterName, deploymentErrorMappers);
638
+ const detectErrorsInDeployments = (deployments, clusterName) => detectErrorsInObjects(
639
+ deployments,
640
+ "Deployment",
641
+ clusterName,
642
+ deploymentErrorMappers
643
+ );
581
644
 
582
645
  const hpaErrorMappers = [
583
646
  {
@@ -595,16 +658,33 @@ const hpaErrorMappers = [
595
658
  }
596
659
  }
597
660
  ];
598
- const detectErrorsInHpa = (hpas, clusterName) => detectErrorsInObjects(hpas, "HorizontalPodAutoscaler", clusterName, hpaErrorMappers);
661
+ const detectErrorsInHpa = (hpas, clusterName) => detectErrorsInObjects(
662
+ hpas,
663
+ "HorizontalPodAutoscaler",
664
+ clusterName,
665
+ hpaErrorMappers
666
+ );
599
667
 
600
668
  const detectErrors = (objects) => {
601
669
  const errors = /* @__PURE__ */ new Map();
602
670
  for (const clusterResponse of objects.items) {
603
671
  let clusterErrors = [];
604
672
  const groupedResponses = groupResponses(clusterResponse.resources);
605
- clusterErrors = clusterErrors.concat(detectErrorsInPods(groupedResponses.pods, clusterResponse.cluster.name));
606
- clusterErrors = clusterErrors.concat(detectErrorsInDeployments(groupedResponses.deployments, clusterResponse.cluster.name));
607
- clusterErrors = clusterErrors.concat(detectErrorsInHpa(groupedResponses.horizontalPodAutoscalers, clusterResponse.cluster.name));
673
+ clusterErrors = clusterErrors.concat(
674
+ detectErrorsInPods(groupedResponses.pods, clusterResponse.cluster.name)
675
+ );
676
+ clusterErrors = clusterErrors.concat(
677
+ detectErrorsInDeployments(
678
+ groupedResponses.deployments,
679
+ clusterResponse.cluster.name
680
+ )
681
+ );
682
+ clusterErrors = clusterErrors.concat(
683
+ detectErrorsInHpa(
684
+ groupedResponses.horizontalPodAutoscalers,
685
+ clusterResponse.cluster.name
686
+ )
687
+ );
608
688
  errors.set(clusterResponse.cluster.name, clusterErrors);
609
689
  }
610
690
  return errors;
@@ -624,14 +704,21 @@ const useKubernetesObjects = (entity, intervalMs = 1e4) => {
624
704
  return;
625
705
  }
626
706
  const authProviders = [
627
- ...new Set(clusters.map((c) => `${c.authProvider}${c.oidcTokenProvider ? `.${c.oidcTokenProvider}` : ""}`))
707
+ ...new Set(
708
+ clusters.map(
709
+ (c) => `${c.authProvider}${c.oidcTokenProvider ? `.${c.oidcTokenProvider}` : ""}`
710
+ )
711
+ )
628
712
  ];
629
713
  let requestBody = {
630
714
  entity
631
715
  };
632
716
  for (const authProviderStr of authProviders) {
633
717
  try {
634
- requestBody = await kubernetesAuthProvidersApi.decorateRequestBodyForAuth(authProviderStr, requestBody);
718
+ requestBody = await kubernetesAuthProvidersApi.decorateRequestBodyForAuth(
719
+ authProviderStr,
720
+ requestBody
721
+ );
635
722
  } catch (e) {
636
723
  setError(e.message);
637
724
  return;
@@ -656,7 +743,9 @@ const useKubernetesObjects = (entity, intervalMs = 1e4) => {
656
743
  };
657
744
  };
658
745
 
659
- const PodNamesWithErrorsContext = React__default.createContext(/* @__PURE__ */ new Set());
746
+ const PodNamesWithErrorsContext = React__default.createContext(
747
+ /* @__PURE__ */ new Set()
748
+ );
660
749
 
661
750
  const PodNamesWithMetricsContext = React__default.createContext(/* @__PURE__ */ new Map());
662
751
 
@@ -693,7 +782,9 @@ function standardFormatter(options) {
693
782
  }
694
783
  const result = new URL(options.dashboardUrl.href);
695
784
  const name = encodeURIComponent((_b = (_a = options.object.metadata) == null ? void 0 : _a.name) != null ? _b : "");
696
- const namespace = encodeURIComponent((_d = (_c = options.object.metadata) == null ? void 0 : _c.namespace) != null ? _d : "");
785
+ const namespace = encodeURIComponent(
786
+ (_d = (_c = options.object.metadata) == null ? void 0 : _c.namespace) != null ? _d : ""
787
+ );
697
788
  const validKind = kindMappings$3[options.kind.toLocaleLowerCase("en-US")];
698
789
  if (!result.pathname.endsWith("/")) {
699
790
  result.pathname += "/";
@@ -722,7 +813,9 @@ function rancherFormatter(options) {
722
813
  }
723
814
  const basePath = new URL(options.dashboardUrl.href);
724
815
  const name = encodeURIComponent((_b = (_a = options.object.metadata) == null ? void 0 : _a.name) != null ? _b : "");
725
- const namespace = encodeURIComponent((_d = (_c = options.object.metadata) == null ? void 0 : _c.namespace) != null ? _d : "");
816
+ const namespace = encodeURIComponent(
817
+ (_d = (_c = options.object.metadata) == null ? void 0 : _c.namespace) != null ? _d : ""
818
+ );
726
819
  const validKind = kindMappings$2[options.kind.toLocaleLowerCase("en-US")];
727
820
  if (!basePath.pathname.endsWith("/")) {
728
821
  basePath.pathname += "/";
@@ -750,7 +843,9 @@ function openshiftFormatter(options) {
750
843
  }
751
844
  const basePath = new URL(options.dashboardUrl.href);
752
845
  const name = encodeURIComponent((_b = (_a = options.object.metadata) == null ? void 0 : _a.name) != null ? _b : "");
753
- const namespace = encodeURIComponent((_d = (_c = options.object.metadata) == null ? void 0 : _c.namespace) != null ? _d : "");
846
+ const namespace = encodeURIComponent(
847
+ (_d = (_c = options.object.metadata) == null ? void 0 : _c.namespace) != null ? _d : ""
848
+ );
754
849
  const validKind = kindMappings$1[options.kind.toLocaleLowerCase("en-US")];
755
850
  if (!basePath.pathname.endsWith("/")) {
756
851
  basePath.pathname += "/";
@@ -780,7 +875,9 @@ function aksFormatter(options) {
780
875
  const args = options.dashboardParameters;
781
876
  for (const param of requiredParams) {
782
877
  if (typeof args[param] !== "string") {
783
- throw new Error(`AKS dashboard requires a "${param}" of type string in the dashboardParameters option`);
878
+ throw new Error(
879
+ `AKS dashboard requires a "${param}" of type string in the dashboardParameters option`
880
+ );
784
881
  }
785
882
  }
786
883
  const path = `/subscriptions/${args.subscriptionId}/resourceGroups/${args.resourceGroup}/providers/Microsoft.ContainerService/managedClusters/${args.clusterName}`;
@@ -793,7 +890,11 @@ function aksFormatter(options) {
793
890
  selector
794
891
  }
795
892
  };
796
- return new URL(`${basePath}/${encodeURIComponent(path)}/resource/${encodeURIComponent(JSON.stringify(params))}`);
893
+ return new URL(
894
+ `${basePath}/${encodeURIComponent(path)}/resource/${encodeURIComponent(
895
+ JSON.stringify(params)
896
+ )}`
897
+ );
797
898
  }
798
899
 
799
900
  function eksFormatter(_options) {
@@ -814,19 +915,27 @@ function gkeFormatter(options) {
814
915
  }
815
916
  const args = options.dashboardParameters;
816
917
  if (typeof args.projectId !== "string") {
817
- throw new Error('GKE dashboard requires a "projectId" of type string in the dashboardParameters option');
918
+ throw new Error(
919
+ 'GKE dashboard requires a "projectId" of type string in the dashboardParameters option'
920
+ );
818
921
  }
819
922
  if (typeof args.region !== "string") {
820
- throw new Error('GKE dashboard requires a "region" of type string in the dashboardParameters option');
923
+ throw new Error(
924
+ 'GKE dashboard requires a "region" of type string in the dashboardParameters option'
925
+ );
821
926
  }
822
927
  if (typeof args.clusterName !== "string") {
823
- throw new Error('GKE dashboard requires a "clusterName" of type string in the dashboardParameters option');
928
+ throw new Error(
929
+ 'GKE dashboard requires a "clusterName" of type string in the dashboardParameters option'
930
+ );
824
931
  }
825
932
  const basePath = new URL("https://console.cloud.google.com/");
826
933
  const region = encodeURIComponent(args.region);
827
934
  const clusterName = encodeURIComponent(args.clusterName);
828
935
  const name = encodeURIComponent((_b = (_a = options.object.metadata) == null ? void 0 : _a.name) != null ? _b : "");
829
- const namespace = encodeURIComponent((_d = (_c = options.object.metadata) == null ? void 0 : _c.namespace) != null ? _d : "");
936
+ const namespace = encodeURIComponent(
937
+ (_d = (_c = options.object.metadata) == null ? void 0 : _c.namespace) != null ? _d : ""
938
+ );
830
939
  const validKind = kindMappings[options.kind.toLocaleLowerCase("en-US")];
831
940
  let path = "";
832
941
  if (namespace && name && validKind) {
@@ -872,35 +981,39 @@ function formatClusterLink(options) {
872
981
  return url.toString();
873
982
  }
874
983
 
875
- const useDrawerStyles = makeStyles((theme) => createStyles({
876
- paper: {
877
- width: "50%",
878
- justifyContent: "space-between",
879
- padding: theme.spacing(2.5)
880
- }
881
- }));
882
- const useDrawerContentStyles = makeStyles((_) => createStyles({
883
- header: {
884
- display: "flex",
885
- flexDirection: "row",
886
- justifyContent: "space-between"
887
- },
888
- errorMessage: {
889
- marginTop: "1em",
890
- marginBottom: "1em"
891
- },
892
- options: {
893
- display: "flex",
894
- flexDirection: "row",
895
- justifyContent: "space-between"
896
- },
897
- icon: {
898
- fontSize: 20
899
- },
900
- content: {
901
- height: "80%"
902
- }
903
- }));
984
+ const useDrawerStyles = makeStyles(
985
+ (theme) => createStyles({
986
+ paper: {
987
+ width: "50%",
988
+ justifyContent: "space-between",
989
+ padding: theme.spacing(2.5)
990
+ }
991
+ })
992
+ );
993
+ const useDrawerContentStyles = makeStyles(
994
+ (_) => createStyles({
995
+ header: {
996
+ display: "flex",
997
+ flexDirection: "row",
998
+ justifyContent: "space-between"
999
+ },
1000
+ errorMessage: {
1001
+ marginTop: "1em",
1002
+ marginBottom: "1em"
1003
+ },
1004
+ options: {
1005
+ display: "flex",
1006
+ flexDirection: "row",
1007
+ justifyContent: "space-between"
1008
+ },
1009
+ icon: {
1010
+ fontSize: 20
1011
+ },
1012
+ content: {
1013
+ height: "80%"
1014
+ }
1015
+ })
1016
+ );
904
1017
  const PodDrawerButton = withStyles({
905
1018
  root: {
906
1019
  padding: "6px 5px"
@@ -1223,16 +1336,23 @@ const HorizontalPodAutoscalerDrawer = ({
1223
1336
  };
1224
1337
 
1225
1338
  function getOwnedResources(potentialOwner, possiblyOwned) {
1226
- return possiblyOwned.filter((p) => {
1227
- var _a, _b, _c;
1228
- return (_c = (_b = (_a = p.metadata) == null ? void 0 : _a.ownerReferences) == null ? void 0 : _b.some((o) => {
1229
- var _a2;
1230
- return o.uid === ((_a2 = potentialOwner.metadata) == null ? void 0 : _a2.uid);
1231
- })) != null ? _c : false;
1232
- });
1339
+ return possiblyOwned.filter(
1340
+ (p) => {
1341
+ var _a, _b, _c;
1342
+ return (_c = (_b = (_a = p.metadata) == null ? void 0 : _a.ownerReferences) == null ? void 0 : _b.some(
1343
+ (o) => {
1344
+ var _a2;
1345
+ return o.uid === ((_a2 = potentialOwner.metadata) == null ? void 0 : _a2.uid);
1346
+ }
1347
+ )) != null ? _c : false;
1348
+ }
1349
+ );
1233
1350
  }
1234
1351
  const getOwnedPodsThroughReplicaSets = (potentialOwner, replicaSets, pods) => {
1235
- return getOwnedResources(potentialOwner, replicaSets.filter((rs) => rs.status && rs.status.replicas > 0)).reduce((accum, rs) => {
1352
+ return getOwnedResources(
1353
+ potentialOwner,
1354
+ replicaSets.filter((rs) => rs.status && rs.status.replicas > 0)
1355
+ ).reduce((accum, rs) => {
1236
1356
  return accum.concat(getOwnedResources(rs, pods));
1237
1357
  }, []);
1238
1358
  };
@@ -1309,10 +1429,12 @@ const DeploymentAccordion = ({
1309
1429
  matchingHpa
1310
1430
  }) => {
1311
1431
  const podNamesWithErrors = useContext(PodNamesWithErrorsContext);
1312
- const podsWithErrors = ownedPods.filter((p) => {
1313
- var _a, _b;
1314
- return podNamesWithErrors.has((_b = (_a = p.metadata) == null ? void 0 : _a.name) != null ? _b : "");
1315
- });
1432
+ const podsWithErrors = ownedPods.filter(
1433
+ (p) => {
1434
+ var _a, _b;
1435
+ return podNamesWithErrors.has((_b = (_a = p.metadata) == null ? void 0 : _a.name) != null ? _b : "");
1436
+ }
1437
+ );
1316
1438
  return /* @__PURE__ */ React__default.createElement(Accordion, {
1317
1439
  TransitionProps: { unmountOnExit: true }
1318
1440
  }, /* @__PURE__ */ React__default.createElement(AccordionSummary, {
@@ -1345,12 +1467,19 @@ const DeploymentsAccordions = ({}) => {
1345
1467
  item: true,
1346
1468
  xs: true
1347
1469
  }, /* @__PURE__ */ React__default.createElement(DeploymentAccordion, {
1348
- matchingHpa: getMatchingHpa({
1349
- name: (_a = deployment.metadata) == null ? void 0 : _a.name,
1350
- namespace: (_b = deployment.metadata) == null ? void 0 : _b.namespace,
1351
- kind: "deployment"
1352
- }, groupedResponses.horizontalPodAutoscalers),
1353
- ownedPods: getOwnedPodsThroughReplicaSets(deployment, groupedResponses.replicaSets, groupedResponses.pods),
1470
+ matchingHpa: getMatchingHpa(
1471
+ {
1472
+ name: (_a = deployment.metadata) == null ? void 0 : _a.name,
1473
+ namespace: (_b = deployment.metadata) == null ? void 0 : _b.namespace,
1474
+ kind: "deployment"
1475
+ },
1476
+ groupedResponses.horizontalPodAutoscalers
1477
+ ),
1478
+ ownedPods: getOwnedPodsThroughReplicaSets(
1479
+ deployment,
1480
+ groupedResponses.replicaSets,
1481
+ groupedResponses.pods
1482
+ ),
1354
1483
  deployment
1355
1484
  })));
1356
1485
  }));
@@ -1470,10 +1599,12 @@ const StatefulSetAccordion = ({
1470
1599
  matchingHpa
1471
1600
  }) => {
1472
1601
  const podNamesWithErrors = useContext(PodNamesWithErrorsContext);
1473
- const podsWithErrors = ownedPods.filter((p) => {
1474
- var _a, _b;
1475
- return podNamesWithErrors.has((_b = (_a = p.metadata) == null ? void 0 : _a.name) != null ? _b : "");
1476
- });
1602
+ const podsWithErrors = ownedPods.filter(
1603
+ (p) => {
1604
+ var _a, _b;
1605
+ return podNamesWithErrors.has((_b = (_a = p.metadata) == null ? void 0 : _a.name) != null ? _b : "");
1606
+ }
1607
+ );
1477
1608
  return /* @__PURE__ */ React__default.createElement(Accordion, {
1478
1609
  TransitionProps: { unmountOnExit: true }
1479
1610
  }, /* @__PURE__ */ React__default.createElement(AccordionSummary, {
@@ -1506,11 +1637,14 @@ const StatefulSetsAccordions = ({}) => {
1506
1637
  item: true,
1507
1638
  xs: true
1508
1639
  }, /* @__PURE__ */ React__default.createElement(StatefulSetAccordion, {
1509
- matchingHpa: getMatchingHpa({
1510
- name: (_a = statefulset.metadata) == null ? void 0 : _a.name,
1511
- namespace: (_b = statefulset.metadata) == null ? void 0 : _b.namespace,
1512
- kind: "statefulset"
1513
- }, groupedResponses.horizontalPodAutoscalers),
1640
+ matchingHpa: getMatchingHpa(
1641
+ {
1642
+ name: (_a = statefulset.metadata) == null ? void 0 : _a.name,
1643
+ namespace: (_b = statefulset.metadata) == null ? void 0 : _b.namespace,
1644
+ kind: "statefulset"
1645
+ },
1646
+ groupedResponses.horizontalPodAutoscalers
1647
+ ),
1514
1648
  ownedPods: getOwnedResources(statefulset, groupedResponses.pods),
1515
1649
  statefulset
1516
1650
  })));
@@ -1875,7 +2009,9 @@ const CronJobSummary = ({ cronJob }) => {
1875
2009
  item: true
1876
2010
  }, /* @__PURE__ */ React__default.createElement(Typography, {
1877
2011
  variant: "body1"
1878
- }, "Schedule:", " ", ((_b = cronJob.spec) == null ? void 0 : _b.schedule) ? `${cronJob.spec.schedule} (${cronstrue.toString(cronJob.spec.schedule)})` : "N/A"))));
2012
+ }, "Schedule:", " ", ((_b = cronJob.spec) == null ? void 0 : _b.schedule) ? `${cronJob.spec.schedule} (${cronstrue.toString(
2013
+ cronJob.spec.schedule
2014
+ )})` : "N/A"))));
1879
2015
  };
1880
2016
  const CronJobAccordion = ({ cronJob, ownedJobs }) => {
1881
2017
  return /* @__PURE__ */ React__default.createElement(Accordion, {
@@ -1965,11 +2101,13 @@ const StepsProgress = ({
1965
2101
  key: i
1966
2102
  }, /* @__PURE__ */ React__default.createElement(StepLabel, {
1967
2103
  "data-testid": `step-${i}`
1968
- }, createLabelForStep(step)))).concat(/* @__PURE__ */ React__default.createElement(Step, {
1969
- key: "-1"
1970
- }, /* @__PURE__ */ React__default.createElement(StepLabel, {
1971
- "data-testid": "step--1"
1972
- }, "Canary promoted"))));
2104
+ }, createLabelForStep(step)))).concat(
2105
+ /* @__PURE__ */ React__default.createElement(Step, {
2106
+ key: "-1"
2107
+ }, /* @__PURE__ */ React__default.createElement(StepLabel, {
2108
+ "data-testid": "step--1"
2109
+ }, "Canary promoted"))
2110
+ ));
1973
2111
  };
1974
2112
 
1975
2113
  const AbortedTitle = /* @__PURE__ */ React__default.createElement("div", {
@@ -1983,7 +2121,9 @@ const AbortedTitle = /* @__PURE__ */ React__default.createElement("div", {
1983
2121
  }, "Aborted"));
1984
2122
  const findAbortedMessage = (rollout) => {
1985
2123
  var _a, _b, _c;
1986
- return (_c = (_b = (_a = rollout.status) == null ? void 0 : _a.conditions) == null ? void 0 : _b.find((c) => c.type === "Progressing" && c.status === "False" && c.reason === "RolloutAborted")) == null ? void 0 : _c.message;
2124
+ return (_c = (_b = (_a = rollout.status) == null ? void 0 : _a.conditions) == null ? void 0 : _b.find(
2125
+ (c) => c.type === "Progressing" && c.status === "False" && c.reason === "RolloutAborted"
2126
+ )) == null ? void 0 : _c.message;
1987
2127
  };
1988
2128
  const RolloutSummary = ({
1989
2129
  rollout,
@@ -1992,7 +2132,9 @@ const RolloutSummary = ({
1992
2132
  hpa
1993
2133
  }) => {
1994
2134
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
1995
- const pauseTime = (_c = (_b = (_a = rollout.status) == null ? void 0 : _a.pauseConditions) == null ? void 0 : _b.find((p) => p.reason === "CanaryPauseStep")) == null ? void 0 : _c.startTime;
2135
+ const pauseTime = (_c = (_b = (_a = rollout.status) == null ? void 0 : _a.pauseConditions) == null ? void 0 : _b.find(
2136
+ (p) => p.reason === "CanaryPauseStep"
2137
+ )) == null ? void 0 : _c.startTime;
1996
2138
  const abortedMessage = findAbortedMessage(rollout);
1997
2139
  return /* @__PURE__ */ React__default.createElement(Grid, {
1998
2140
  container: true,
@@ -2069,10 +2211,12 @@ const RolloutAccordion = ({
2069
2211
  }) => {
2070
2212
  var _a, _b, _c, _d, _e, _f;
2071
2213
  const podNamesWithErrors = useContext(PodNamesWithErrorsContext);
2072
- const podsWithErrors = ownedPods.filter((p) => {
2073
- var _a2, _b2;
2074
- return podNamesWithErrors.has((_b2 = (_a2 = p.metadata) == null ? void 0 : _a2.name) != null ? _b2 : "");
2075
- });
2214
+ const podsWithErrors = ownedPods.filter(
2215
+ (p) => {
2216
+ var _a2, _b2;
2217
+ return podNamesWithErrors.has((_b2 = (_a2 = p.metadata) == null ? void 0 : _a2.name) != null ? _b2 : "");
2218
+ }
2219
+ );
2076
2220
  const currentStepIndex = (_b = (_a = rollout.status) == null ? void 0 : _a.currentStepIndex) != null ? _b : 0;
2077
2221
  const abortedMessage = findAbortedMessage(rollout);
2078
2222
  return /* @__PURE__ */ React__default.createElement(Accordion, {
@@ -2124,12 +2268,19 @@ const RolloutAccordions = ({
2124
2268
  xs: true
2125
2269
  }, /* @__PURE__ */ React__default.createElement(RolloutAccordion, {
2126
2270
  defaultExpanded,
2127
- matchingHpa: getMatchingHpa({
2128
- name: (_a = rollout.metadata) == null ? void 0 : _a.name,
2129
- namespace: (_b = rollout.metadata) == null ? void 0 : _b.namespace,
2130
- kind: "rollout"
2131
- }, groupedResponses.horizontalPodAutoscalers),
2132
- ownedPods: getOwnedPodsThroughReplicaSets(rollout, groupedResponses.replicaSets, groupedResponses.pods),
2271
+ matchingHpa: getMatchingHpa(
2272
+ {
2273
+ name: (_a = rollout.metadata) == null ? void 0 : _a.name,
2274
+ namespace: (_b = rollout.metadata) == null ? void 0 : _b.namespace,
2275
+ kind: "rollout"
2276
+ },
2277
+ groupedResponses.horizontalPodAutoscalers
2278
+ ),
2279
+ ownedPods: getOwnedPodsThroughReplicaSets(
2280
+ rollout,
2281
+ groupedResponses.replicaSets,
2282
+ groupedResponses.pods
2283
+ ),
2133
2284
  rollout
2134
2285
  })));
2135
2286
  }));
@@ -2350,7 +2501,10 @@ const KubernetesContent = ({
2350
2501
  refreshIntervalMs
2351
2502
  }) => {
2352
2503
  var _a;
2353
- const { kubernetesObjects, error } = useKubernetesObjects(entity, refreshIntervalMs);
2504
+ const { kubernetesObjects, error } = useKubernetesObjects(
2505
+ entity,
2506
+ refreshIntervalMs
2507
+ );
2354
2508
  const clustersWithErrors = (_a = kubernetesObjects == null ? void 0 : kubernetesObjects.items.filter((r) => r.errors.length > 0)) != null ? _a : [];
2355
2509
  const detectedErrors = kubernetesObjects !== void 0 ? detectErrors(kubernetesObjects) : /* @__PURE__ */ new Map();
2356
2510
  return /* @__PURE__ */ React__default.createElement(Page, {
@@ -2410,7 +2564,9 @@ const KubernetesContent = ({
2410
2564
  "data-testid": "emptyStateImg"
2411
2565
  }))), (kubernetesObjects == null ? void 0 : kubernetesObjects.items.length) > 0 && (kubernetesObjects == null ? void 0 : kubernetesObjects.items.map((item, i) => {
2412
2566
  var _a2, _b;
2413
- const podsWithErrors = new Set((_b = (_a2 = detectedErrors.get(item.cluster.name)) == null ? void 0 : _a2.filter((de) => de.kind === "Pod").map((de) => de.names).flat()) != null ? _b : []);
2567
+ const podsWithErrors = new Set(
2568
+ (_b = (_a2 = detectedErrors.get(item.cluster.name)) == null ? void 0 : _a2.filter((de) => de.kind === "Pod").map((de) => de.names).flat()) != null ? _b : []
2569
+ );
2414
2570
  return /* @__PURE__ */ React__default.createElement(Grid, {
2415
2571
  item: true,
2416
2572
  key: i,
@@ -2426,7 +2582,9 @@ const KUBERNETES_ANNOTATION = "backstage.io/kubernetes-id";
2426
2582
  const KUBERNETES_LABEL_SELECTOR_QUERY_ANNOTATION = "backstage.io/kubernetes-label-selector";
2427
2583
  const isKubernetesAvailable = (entity) => {
2428
2584
  var _a, _b;
2429
- return Boolean((_a = entity.metadata.annotations) == null ? void 0 : _a[KUBERNETES_ANNOTATION]) || Boolean((_b = entity.metadata.annotations) == null ? void 0 : _b[KUBERNETES_LABEL_SELECTOR_QUERY_ANNOTATION]);
2585
+ return Boolean((_a = entity.metadata.annotations) == null ? void 0 : _a[KUBERNETES_ANNOTATION]) || Boolean(
2586
+ (_b = entity.metadata.annotations) == null ? void 0 : _b[KUBERNETES_LABEL_SELECTOR_QUERY_ANNOTATION]
2587
+ );
2430
2588
  };
2431
2589
  const Router = (props) => {
2432
2590
  var _a, _b;