@backstage/plugin-kubernetes-react 0.1.2-next.0 → 0.2.0-next.2

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
@@ -41,6 +41,9 @@ const kubernetesApiRef = createApiRef({
41
41
  const kubernetesProxyApiRef = createApiRef({
42
42
  id: "plugin.kubernetes.proxy-service"
43
43
  });
44
+ const kubernetesClusterLinkFormatterApiRef = createApiRef({
45
+ id: "plugin.kubernetes.cluster-link-formatter-service"
46
+ });
44
47
 
45
48
  const useIsPodExecTerminalSupported = () => {
46
49
  const kubernetesApi = useApi(kubernetesApiRef);
@@ -83,15 +86,15 @@ const kubernetesAuthProvidersApiRef = createApiRef({
83
86
  id: "plugin.kubernetes-auth-providers.service"
84
87
  });
85
88
 
86
- var __defProp$4 = Object.defineProperty;
87
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
88
- var __publicField$4 = (obj, key, value) => {
89
- __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
89
+ var __defProp$5 = Object.defineProperty;
90
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
91
+ var __publicField$5 = (obj, key, value) => {
92
+ __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
90
93
  return value;
91
94
  };
92
95
  class GoogleKubernetesAuthProvider {
93
96
  constructor(authProvider) {
94
- __publicField$4(this, "authProvider");
97
+ __publicField$5(this, "authProvider");
95
98
  this.authProvider = authProvider;
96
99
  }
97
100
  async decorateRequestBodyForAuth(requestBody) {
@@ -121,16 +124,16 @@ class ServerSideKubernetesAuthProvider {
121
124
  }
122
125
  }
123
126
 
124
- var __defProp$3 = Object.defineProperty;
125
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
126
- var __publicField$3 = (obj, key, value) => {
127
- __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
127
+ var __defProp$4 = Object.defineProperty;
128
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
129
+ var __publicField$4 = (obj, key, value) => {
130
+ __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
128
131
  return value;
129
132
  };
130
133
  class OidcKubernetesAuthProvider {
131
134
  constructor(providerName, authProvider) {
132
- __publicField$3(this, "providerName");
133
- __publicField$3(this, "authProvider");
135
+ __publicField$4(this, "providerName");
136
+ __publicField$4(this, "authProvider");
134
137
  this.providerName = providerName;
135
138
  this.authProvider = authProvider;
136
139
  }
@@ -171,15 +174,15 @@ class AksKubernetesAuthProvider {
171
174
  }
172
175
  }
173
176
 
174
- var __defProp$2 = Object.defineProperty;
175
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
176
- var __publicField$2 = (obj, key, value) => {
177
- __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
177
+ var __defProp$3 = Object.defineProperty;
178
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
179
+ var __publicField$3 = (obj, key, value) => {
180
+ __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
178
181
  return value;
179
182
  };
180
183
  class KubernetesAuthProviders {
181
184
  constructor(options) {
182
- __publicField$2(this, "kubernetesAuthProviderMap");
185
+ __publicField$3(this, "kubernetesAuthProviderMap");
183
186
  this.kubernetesAuthProviderMap = /* @__PURE__ */ new Map();
184
187
  this.kubernetesAuthProviderMap.set(
185
188
  "google",
@@ -367,17 +370,17 @@ const useMatchingErrors = (matcher) => {
367
370
  });
368
371
  };
369
372
 
370
- var __defProp$1 = Object.defineProperty;
371
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
372
- var __publicField$1 = (obj, key, value) => {
373
- __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
373
+ var __defProp$2 = Object.defineProperty;
374
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
375
+ var __publicField$2 = (obj, key, value) => {
376
+ __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
374
377
  return value;
375
378
  };
376
379
  class KubernetesBackendClient {
377
380
  constructor(options) {
378
- __publicField$1(this, "discoveryApi");
379
- __publicField$1(this, "identityApi");
380
- __publicField$1(this, "kubernetesAuthProvidersApi");
381
+ __publicField$2(this, "discoveryApi");
382
+ __publicField$2(this, "identityApi");
383
+ __publicField$2(this, "kubernetesAuthProvidersApi");
381
384
  this.discoveryApi = options.discoveryApi;
382
385
  this.identityApi = options.identityApi;
383
386
  this.kubernetesAuthProvidersApi = options.kubernetesAuthProvidersApi;
@@ -494,6 +497,42 @@ class KubernetesBackendClient {
494
497
  }
495
498
  }
496
499
 
500
+ var __defProp$1 = Object.defineProperty;
501
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
502
+ var __publicField$1 = (obj, key, value) => {
503
+ __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
504
+ return value;
505
+ };
506
+ class KubernetesClusterLinkFormatter {
507
+ constructor(options) {
508
+ __publicField$1(this, "formatters");
509
+ __publicField$1(this, "defaultFormatterName");
510
+ this.formatters = options.formatters;
511
+ this.defaultFormatterName = options.defaultFormatterName;
512
+ }
513
+ async formatClusterLink(options) {
514
+ var _a;
515
+ if (!options.dashboardUrl && !options.dashboardParameters) {
516
+ return void 0;
517
+ }
518
+ if (options.dashboardUrl && !options.object) {
519
+ return options.dashboardUrl;
520
+ }
521
+ const app = (_a = options.dashboardApp) != null ? _a : this.defaultFormatterName;
522
+ const formatter = this.formatters[app];
523
+ if (!formatter) {
524
+ throw new Error(`Could not find Kubernetes dashboard app named '${app}'`);
525
+ }
526
+ const url = await formatter.formatClusterLink({
527
+ dashboardUrl: options.dashboardUrl ? new URL(options.dashboardUrl) : void 0,
528
+ dashboardParameters: options.dashboardParameters,
529
+ object: options.object,
530
+ kind: options.kind
531
+ });
532
+ return url.toString();
533
+ }
534
+ }
535
+
497
536
  var __defProp = Object.defineProperty;
498
537
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
499
538
  var __publicField = (obj, key, value) => {
@@ -568,6 +607,215 @@ class KubernetesProxyClient {
568
607
  }
569
608
  }
570
609
 
610
+ const basePath = "https://portal.azure.com/#blade/Microsoft_Azure_ContainerService/AksK8ResourceMenuBlade/overview-Deployment/aksClusterId";
611
+ const requiredParams = ["subscriptionId", "resourceGroup", "clusterName"];
612
+ class AksClusterLinksFormatter {
613
+ async formatClusterLink(options) {
614
+ if (!options.dashboardParameters) {
615
+ throw new Error("AKS dashboard requires a dashboardParameters option");
616
+ }
617
+ const args = options.dashboardParameters;
618
+ for (const param of requiredParams) {
619
+ if (typeof args[param] !== "string") {
620
+ throw new Error(
621
+ `AKS dashboard requires a "${param}" of type string in the dashboardParameters option`
622
+ );
623
+ }
624
+ }
625
+ const path = `/subscriptions/${args.subscriptionId}/resourceGroups/${args.resourceGroup}/providers/Microsoft.ContainerService/managedClusters/${args.clusterName}`;
626
+ const { name, namespace, uid } = options.object.metadata;
627
+ const { selector } = options.object.spec;
628
+ const params = {
629
+ kind: options.kind,
630
+ metadata: { name, namespace, uid },
631
+ spec: {
632
+ selector
633
+ }
634
+ };
635
+ return new URL(
636
+ `${basePath}/${encodeURIComponent(path)}/resource/${encodeURIComponent(
637
+ JSON.stringify(params)
638
+ )}`
639
+ );
640
+ }
641
+ }
642
+
643
+ class EksClusterLinksFormatter {
644
+ async formatClusterLink(_options) {
645
+ throw new Error(
646
+ "EKS formatter is not yet implemented. Please, contribute!"
647
+ );
648
+ }
649
+ }
650
+
651
+ const kindMappings$3 = {
652
+ deployment: "deployment",
653
+ pod: "pod",
654
+ ingress: "ingress",
655
+ service: "service",
656
+ horizontalpodautoscaler: "deployment"
657
+ };
658
+ class GkeClusterLinksFormatter {
659
+ async formatClusterLink(options) {
660
+ var _a, _b, _c, _d;
661
+ if (!options.dashboardParameters) {
662
+ throw new Error("GKE dashboard requires a dashboardParameters option");
663
+ }
664
+ const args = options.dashboardParameters;
665
+ if (typeof args.projectId !== "string") {
666
+ throw new Error(
667
+ 'GKE dashboard requires a "projectId" of type string in the dashboardParameters option'
668
+ );
669
+ }
670
+ if (typeof args.region !== "string") {
671
+ throw new Error(
672
+ 'GKE dashboard requires a "region" of type string in the dashboardParameters option'
673
+ );
674
+ }
675
+ if (typeof args.clusterName !== "string") {
676
+ throw new Error(
677
+ 'GKE dashboard requires a "clusterName" of type string in the dashboardParameters option'
678
+ );
679
+ }
680
+ const basePath = new URL("https://console.cloud.google.com/");
681
+ const region = encodeURIComponent(args.region);
682
+ const clusterName = encodeURIComponent(args.clusterName);
683
+ const name = encodeURIComponent((_b = (_a = options.object.metadata) == null ? void 0 : _a.name) != null ? _b : "");
684
+ const namespace = encodeURIComponent(
685
+ (_d = (_c = options.object.metadata) == null ? void 0 : _c.namespace) != null ? _d : ""
686
+ );
687
+ const validKind = kindMappings$3[options.kind.toLocaleLowerCase("en-US")];
688
+ let path;
689
+ if (namespace && name && validKind) {
690
+ const kindsWithDetails = ["ingress", "pod"];
691
+ const landingPage = kindsWithDetails.includes(validKind) ? "details" : "overview";
692
+ path = `kubernetes/${validKind}/${region}/${clusterName}/${namespace}/${name}/${landingPage}`;
693
+ } else {
694
+ path = `kubernetes/clusters/details/${region}/${clusterName}/details`;
695
+ }
696
+ const result = new URL(path, basePath);
697
+ result.searchParams.set("project", args.projectId);
698
+ return result;
699
+ }
700
+ }
701
+
702
+ const kindMappings$2 = {
703
+ deployment: "deployment",
704
+ pod: "pod",
705
+ ingress: "ingress",
706
+ service: "service",
707
+ horizontalpodautoscaler: "deployment",
708
+ statefulset: "statefulset"
709
+ };
710
+ class StandardClusterLinksFormatter {
711
+ async formatClusterLink(options) {
712
+ var _a, _b, _c, _d;
713
+ if (!options.dashboardUrl) {
714
+ throw new Error("standard dashboard requires a dashboardUrl option");
715
+ }
716
+ const result = new URL(options.dashboardUrl.href);
717
+ const name = encodeURIComponent((_b = (_a = options.object.metadata) == null ? void 0 : _a.name) != null ? _b : "");
718
+ const namespace = encodeURIComponent(
719
+ (_d = (_c = options.object.metadata) == null ? void 0 : _c.namespace) != null ? _d : ""
720
+ );
721
+ const validKind = kindMappings$2[options.kind.toLocaleLowerCase("en-US")];
722
+ if (!result.pathname.endsWith("/")) {
723
+ result.pathname += "/";
724
+ }
725
+ if (validKind && name && namespace) {
726
+ result.hash = `/${validKind}/${namespace}/${name}`;
727
+ } else if (namespace) {
728
+ result.hash = "/workloads";
729
+ }
730
+ if (namespace) {
731
+ result.hash += `?namespace=${namespace}`;
732
+ }
733
+ return result;
734
+ }
735
+ }
736
+
737
+ const kindMappings$1 = {
738
+ deployment: "deployments",
739
+ ingress: "ingresses",
740
+ service: "services",
741
+ horizontalpodautoscaler: "horizontalpodautoscalers",
742
+ persistentvolume: "persistentvolumes"
743
+ };
744
+ class OpenshiftClusterLinksFormatter {
745
+ async formatClusterLink(options) {
746
+ var _a, _b, _c, _d;
747
+ if (!options.dashboardUrl) {
748
+ throw new Error("OpenShift dashboard requires a dashboardUrl option");
749
+ }
750
+ const basePath = new URL(options.dashboardUrl.href);
751
+ const name = encodeURIComponent((_b = (_a = options.object.metadata) == null ? void 0 : _a.name) != null ? _b : "");
752
+ const namespace = encodeURIComponent(
753
+ (_d = (_c = options.object.metadata) == null ? void 0 : _c.namespace) != null ? _d : ""
754
+ );
755
+ const validKind = kindMappings$1[options.kind.toLocaleLowerCase("en-US")];
756
+ if (!basePath.pathname.endsWith("/")) {
757
+ basePath.pathname += "/";
758
+ }
759
+ let path = "";
760
+ if (namespace) {
761
+ if (name && validKind) {
762
+ path = `k8s/ns/${namespace}/${validKind}/${name}`;
763
+ } else {
764
+ path = `k8s/cluster/projects/${namespace}`;
765
+ }
766
+ } else if (validKind) {
767
+ path = `k8s/cluster/${validKind}`;
768
+ if (name) {
769
+ path += `/${name}`;
770
+ }
771
+ }
772
+ return new URL(path, basePath);
773
+ }
774
+ }
775
+
776
+ const kindMappings = {
777
+ deployment: "apps.deployment",
778
+ ingress: "networking.k8s.io.ingress",
779
+ service: "service",
780
+ horizontalpodautoscaler: "autoscaling.horizontalpodautoscaler"
781
+ };
782
+ class RancherClusterLinksFormatter {
783
+ async formatClusterLink(options) {
784
+ var _a, _b, _c, _d;
785
+ if (!options.dashboardUrl) {
786
+ throw new Error("Rancher dashboard requires a dashboardUrl option");
787
+ }
788
+ const basePath = new URL(options.dashboardUrl.href);
789
+ const name = encodeURIComponent((_b = (_a = options.object.metadata) == null ? void 0 : _a.name) != null ? _b : "");
790
+ const namespace = encodeURIComponent(
791
+ (_d = (_c = options.object.metadata) == null ? void 0 : _c.namespace) != null ? _d : ""
792
+ );
793
+ const validKind = kindMappings[options.kind.toLocaleLowerCase("en-US")];
794
+ if (!basePath.pathname.endsWith("/")) {
795
+ basePath.pathname += "/";
796
+ }
797
+ let path = "";
798
+ if (validKind && name && namespace) {
799
+ path = `explorer/${validKind}/${namespace}/${name}`;
800
+ } else if (namespace) {
801
+ path = "explorer/workload";
802
+ }
803
+ return new URL(path, basePath);
804
+ }
805
+ }
806
+
807
+ const DEFAULT_FORMATTER_NAME = "standard";
808
+ function getDefaultFormatters(_deps) {
809
+ return {
810
+ standard: new StandardClusterLinksFormatter(),
811
+ aks: new AksClusterLinksFormatter(),
812
+ eks: new EksClusterLinksFormatter(),
813
+ gke: new GkeClusterLinksFormatter(),
814
+ openshift: new OpenshiftClusterLinksFormatter(),
815
+ rancher: new RancherClusterLinksFormatter()
816
+ };
817
+ }
818
+
571
819
  const currentToDeclaredResourceToPerc$1 = (current, resource) => {
572
820
  if (Number(resource) === 0)
573
821
  return 0;
@@ -1013,220 +1261,6 @@ const ContainerCard = ({
1013
1261
  )));
1014
1262
  };
1015
1263
 
1016
- const kindMappings$3 = {
1017
- deployment: "deployment",
1018
- pod: "pod",
1019
- ingress: "ingress",
1020
- service: "service",
1021
- horizontalpodautoscaler: "deployment",
1022
- statefulset: "statefulset"
1023
- };
1024
- function standardFormatter(options) {
1025
- var _a, _b, _c, _d;
1026
- if (!options.dashboardUrl) {
1027
- throw new Error("standard dashboard requires a dashboardUrl option");
1028
- }
1029
- const result = new URL(options.dashboardUrl.href);
1030
- const name = encodeURIComponent((_b = (_a = options.object.metadata) == null ? void 0 : _a.name) != null ? _b : "");
1031
- const namespace = encodeURIComponent(
1032
- (_d = (_c = options.object.metadata) == null ? void 0 : _c.namespace) != null ? _d : ""
1033
- );
1034
- const validKind = kindMappings$3[options.kind.toLocaleLowerCase("en-US")];
1035
- if (!result.pathname.endsWith("/")) {
1036
- result.pathname += "/";
1037
- }
1038
- if (validKind && name && namespace) {
1039
- result.hash = `/${validKind}/${namespace}/${name}`;
1040
- } else if (namespace) {
1041
- result.hash = "/workloads";
1042
- }
1043
- if (namespace) {
1044
- result.hash += `?namespace=${namespace}`;
1045
- }
1046
- return result;
1047
- }
1048
-
1049
- const kindMappings$2 = {
1050
- deployment: "apps.deployment",
1051
- ingress: "networking.k8s.io.ingress",
1052
- service: "service",
1053
- horizontalpodautoscaler: "autoscaling.horizontalpodautoscaler"
1054
- };
1055
- function rancherFormatter(options) {
1056
- var _a, _b, _c, _d;
1057
- if (!options.dashboardUrl) {
1058
- throw new Error("Rancher dashboard requires a dashboardUrl option");
1059
- }
1060
- const basePath = new URL(options.dashboardUrl.href);
1061
- const name = encodeURIComponent((_b = (_a = options.object.metadata) == null ? void 0 : _a.name) != null ? _b : "");
1062
- const namespace = encodeURIComponent(
1063
- (_d = (_c = options.object.metadata) == null ? void 0 : _c.namespace) != null ? _d : ""
1064
- );
1065
- const validKind = kindMappings$2[options.kind.toLocaleLowerCase("en-US")];
1066
- if (!basePath.pathname.endsWith("/")) {
1067
- basePath.pathname += "/";
1068
- }
1069
- let path = "";
1070
- if (validKind && name && namespace) {
1071
- path = `explorer/${validKind}/${namespace}/${name}`;
1072
- } else if (namespace) {
1073
- path = "explorer/workload";
1074
- }
1075
- return new URL(path, basePath);
1076
- }
1077
-
1078
- const kindMappings$1 = {
1079
- deployment: "deployments",
1080
- ingress: "ingresses",
1081
- service: "services",
1082
- horizontalpodautoscaler: "horizontalpodautoscalers",
1083
- persistentvolume: "persistentvolumes"
1084
- };
1085
- function openshiftFormatter(options) {
1086
- var _a, _b, _c, _d;
1087
- if (!options.dashboardUrl) {
1088
- throw new Error("OpenShift dashboard requires a dashboardUrl option");
1089
- }
1090
- const basePath = new URL(options.dashboardUrl.href);
1091
- const name = encodeURIComponent((_b = (_a = options.object.metadata) == null ? void 0 : _a.name) != null ? _b : "");
1092
- const namespace = encodeURIComponent(
1093
- (_d = (_c = options.object.metadata) == null ? void 0 : _c.namespace) != null ? _d : ""
1094
- );
1095
- const validKind = kindMappings$1[options.kind.toLocaleLowerCase("en-US")];
1096
- if (!basePath.pathname.endsWith("/")) {
1097
- basePath.pathname += "/";
1098
- }
1099
- let path = "";
1100
- if (namespace) {
1101
- if (name && validKind) {
1102
- path = `k8s/ns/${namespace}/${validKind}/${name}`;
1103
- } else {
1104
- path = `k8s/cluster/projects/${namespace}`;
1105
- }
1106
- } else if (validKind) {
1107
- path = `k8s/cluster/${validKind}`;
1108
- if (name) {
1109
- path += `/${name}`;
1110
- }
1111
- }
1112
- return new URL(path, basePath);
1113
- }
1114
-
1115
- const basePath = "https://portal.azure.com/#blade/Microsoft_Azure_ContainerService/AksK8ResourceMenuBlade/overview-Deployment/aksClusterId";
1116
- const requiredParams = ["subscriptionId", "resourceGroup", "clusterName"];
1117
- function aksFormatter(options) {
1118
- if (!options.dashboardParameters) {
1119
- throw new Error("AKS dashboard requires a dashboardParameters option");
1120
- }
1121
- const args = options.dashboardParameters;
1122
- for (const param of requiredParams) {
1123
- if (typeof args[param] !== "string") {
1124
- throw new Error(
1125
- `AKS dashboard requires a "${param}" of type string in the dashboardParameters option`
1126
- );
1127
- }
1128
- }
1129
- const path = `/subscriptions/${args.subscriptionId}/resourceGroups/${args.resourceGroup}/providers/Microsoft.ContainerService/managedClusters/${args.clusterName}`;
1130
- const { name, namespace, uid } = options.object.metadata;
1131
- const { selector } = options.object.spec;
1132
- const params = {
1133
- kind: options.kind,
1134
- metadata: { name, namespace, uid },
1135
- spec: {
1136
- selector
1137
- }
1138
- };
1139
- return new URL(
1140
- `${basePath}/${encodeURIComponent(path)}/resource/${encodeURIComponent(
1141
- JSON.stringify(params)
1142
- )}`
1143
- );
1144
- }
1145
-
1146
- function eksFormatter(_options) {
1147
- throw new Error("EKS formatter is not yet implemented. Please, contribute!");
1148
- }
1149
-
1150
- const kindMappings = {
1151
- deployment: "deployment",
1152
- pod: "pod",
1153
- ingress: "ingress",
1154
- service: "service",
1155
- horizontalpodautoscaler: "deployment"
1156
- };
1157
- function gkeFormatter(options) {
1158
- var _a, _b, _c, _d;
1159
- if (!options.dashboardParameters) {
1160
- throw new Error("GKE dashboard requires a dashboardParameters option");
1161
- }
1162
- const args = options.dashboardParameters;
1163
- if (typeof args.projectId !== "string") {
1164
- throw new Error(
1165
- 'GKE dashboard requires a "projectId" of type string in the dashboardParameters option'
1166
- );
1167
- }
1168
- if (typeof args.region !== "string") {
1169
- throw new Error(
1170
- 'GKE dashboard requires a "region" of type string in the dashboardParameters option'
1171
- );
1172
- }
1173
- if (typeof args.clusterName !== "string") {
1174
- throw new Error(
1175
- 'GKE dashboard requires a "clusterName" of type string in the dashboardParameters option'
1176
- );
1177
- }
1178
- const basePath = new URL("https://console.cloud.google.com/");
1179
- const region = encodeURIComponent(args.region);
1180
- const clusterName = encodeURIComponent(args.clusterName);
1181
- const name = encodeURIComponent((_b = (_a = options.object.metadata) == null ? void 0 : _a.name) != null ? _b : "");
1182
- const namespace = encodeURIComponent(
1183
- (_d = (_c = options.object.metadata) == null ? void 0 : _c.namespace) != null ? _d : ""
1184
- );
1185
- const validKind = kindMappings[options.kind.toLocaleLowerCase("en-US")];
1186
- let path = "";
1187
- if (namespace && name && validKind) {
1188
- const kindsWithDetails = ["ingress", "pod"];
1189
- const landingPage = kindsWithDetails.includes(validKind) ? "details" : "overview";
1190
- path = `kubernetes/${validKind}/${region}/${clusterName}/${namespace}/${name}/${landingPage}`;
1191
- } else {
1192
- path = `kubernetes/clusters/details/${region}/${clusterName}/details`;
1193
- }
1194
- const result = new URL(path, basePath);
1195
- result.searchParams.set("project", args.projectId);
1196
- return result;
1197
- }
1198
-
1199
- const clusterLinksFormatters = {
1200
- standard: standardFormatter,
1201
- rancher: rancherFormatter,
1202
- openshift: openshiftFormatter,
1203
- aks: aksFormatter,
1204
- eks: eksFormatter,
1205
- gke: gkeFormatter
1206
- };
1207
- const defaultFormatterName = "standard";
1208
-
1209
- function formatClusterLink(options) {
1210
- if (!options.dashboardUrl && !options.dashboardParameters) {
1211
- return void 0;
1212
- }
1213
- if (options.dashboardUrl && !options.object) {
1214
- return options.dashboardUrl;
1215
- }
1216
- const app = options.dashboardApp || defaultFormatterName;
1217
- const formatter = clusterLinksFormatters[app];
1218
- if (!formatter) {
1219
- throw new Error(`Could not find Kubernetes dashboard app named '${app}'`);
1220
- }
1221
- const url = formatter({
1222
- dashboardUrl: options.dashboardUrl ? new URL(options.dashboardUrl) : void 0,
1223
- dashboardParameters: options.dashboardParameters,
1224
- object: options.object,
1225
- kind: options.kind
1226
- });
1227
- return url.toString();
1228
- }
1229
-
1230
1264
  const ManifestYaml = ({ object }) => {
1231
1265
  const [managedFields, setManagedFields] = useState(false);
1232
1266
  return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
@@ -1319,19 +1353,6 @@ function replaceNullsWithUndefined(someObj) {
1319
1353
  const replacer = (_, value) => String(value) === "null" || String(value) === "undefined" ? void 0 : value;
1320
1354
  return JSON.parse(JSON.stringify(someObj, replacer));
1321
1355
  }
1322
- function tryFormatClusterLink(options) {
1323
- try {
1324
- return {
1325
- clusterLink: formatClusterLink(options),
1326
- errorMessage: ""
1327
- };
1328
- } catch (err) {
1329
- return {
1330
- clusterLink: "",
1331
- errorMessage: err.message || err.toString()
1332
- };
1333
- }
1334
- }
1335
1356
  const KubernetesStructuredMetadataTableDrawerContent = ({
1336
1357
  toggleDrawer,
1337
1358
  object,
@@ -1340,15 +1361,19 @@ const KubernetesStructuredMetadataTableDrawerContent = ({
1340
1361
  }) => {
1341
1362
  var _a, _b;
1342
1363
  const [isYaml, setIsYaml] = useState(false);
1364
+ const formatter = useApi(kubernetesClusterLinkFormatterApiRef);
1343
1365
  const classes = useDrawerContentStyles$2();
1344
1366
  const cluster = useContext(ClusterContext);
1345
- const { clusterLink, errorMessage } = tryFormatClusterLink({
1346
- dashboardUrl: cluster.dashboardUrl,
1347
- dashboardApp: cluster.dashboardApp,
1348
- dashboardParameters: cluster.dashboardParameters,
1349
- object,
1350
- kind
1351
- });
1367
+ const { value: clusterLink, error } = useAsync(
1368
+ async () => formatter.formatClusterLink({
1369
+ dashboardUrl: cluster.dashboardUrl,
1370
+ dashboardApp: cluster.dashboardApp,
1371
+ dashboardParameters: cluster.dashboardParameters,
1372
+ object,
1373
+ kind
1374
+ }),
1375
+ [cluster, object, kind, formatter]
1376
+ );
1352
1377
  return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("div", { className: classes.header }, /* @__PURE__ */ React__default.createElement(Grid, { container: true, justifyContent: "flex-start", alignItems: "flex-start" }, /* @__PURE__ */ React__default.createElement(Grid, { item: true, xs: 11 }, /* @__PURE__ */ React__default.createElement(Typography, { variant: "h5" }, (_b = (_a = object.metadata) == null ? void 0 : _a.name) != null ? _b : "unknown name")), /* @__PURE__ */ React__default.createElement(Grid, { item: true, xs: 1 }, /* @__PURE__ */ React__default.createElement(
1353
1378
  IconButton,
1354
1379
  {
@@ -1373,7 +1398,13 @@ const KubernetesStructuredMetadataTableDrawerContent = ({
1373
1398
  ),
1374
1399
  label: "YAML"
1375
1400
  }
1376
- )))), errorMessage && /* @__PURE__ */ React__default.createElement("div", { className: classes.errorMessage }, /* @__PURE__ */ React__default.createElement(LinkErrorPanel, { cluster, errorMessage })), /* @__PURE__ */ React__default.createElement("div", { className: classes.options }, /* @__PURE__ */ React__default.createElement("div", null, clusterLink && /* @__PURE__ */ React__default.createElement(
1401
+ )))), error && /* @__PURE__ */ React__default.createElement("div", { className: classes.errorMessage }, /* @__PURE__ */ React__default.createElement(
1402
+ LinkErrorPanel,
1403
+ {
1404
+ cluster,
1405
+ errorMessage: error.message || error.toString()
1406
+ }
1407
+ )), /* @__PURE__ */ React__default.createElement("div", { className: classes.options }, /* @__PURE__ */ React__default.createElement("div", null, clusterLink && /* @__PURE__ */ React__default.createElement(
1377
1408
  LinkButton,
1378
1409
  {
1379
1410
  variant: "outlined",
@@ -3262,5 +3293,5 @@ const ErrorReporting = ({ detectedErrors }) => {
3262
3293
  ));
3263
3294
  };
3264
3295
 
3265
- export { AksKubernetesAuthProvider, Cluster, ClusterContext, ContainerCard, CronJobsAccordions, CustomResources, DetectedErrorsContext, ErrorList, ErrorPanel, ErrorReporting, Events, EventsContent, FixDialog, GoogleKubernetesAuthProvider, GroupedResponsesContext, HorizontalPodAutoscalerDrawer, IngressesAccordions, JobsAccordions, KubernetesAuthProviders, KubernetesBackendClient, KubernetesDrawer, KubernetesProxyClient, KubernetesStructuredMetadataTableDrawer, LinkErrorPanel, ManifestYaml, OidcKubernetesAuthProvider, PendingPodContent, PodDrawer, PodExecTerminal, PodExecTerminalDialog, PodLogs, PodLogsDialog, PodMetricsContext, PodNamesWithErrorsContext, PodNamesWithMetricsContext, PodsTable, READY_COLUMNS, RESOURCE_COLUMNS, ResourceUtilization, ServerSideKubernetesAuthProvider, ServicesAccordions, clusterLinksFormatters, formatClusterLink, kubernetesApiRef, kubernetesAuthProvidersApiRef, kubernetesProxyApiRef, useCustomResources, useEvents, useIsPodExecTerminalSupported, useKubernetesObjects, useMatchingErrors, usePodLogs, usePodMetrics };
3296
+ export { AksClusterLinksFormatter, AksKubernetesAuthProvider, Cluster, ClusterContext, ContainerCard, CronJobsAccordions, CustomResources, DEFAULT_FORMATTER_NAME, DetectedErrorsContext, EksClusterLinksFormatter, ErrorList, ErrorPanel, ErrorReporting, Events, EventsContent, FixDialog, GkeClusterLinksFormatter, GoogleKubernetesAuthProvider, GroupedResponsesContext, HorizontalPodAutoscalerDrawer, IngressesAccordions, JobsAccordions, KubernetesAuthProviders, KubernetesBackendClient, KubernetesClusterLinkFormatter, KubernetesDrawer, KubernetesProxyClient, KubernetesStructuredMetadataTableDrawer, LinkErrorPanel, ManifestYaml, OidcKubernetesAuthProvider, OpenshiftClusterLinksFormatter, PendingPodContent, PodDrawer, PodExecTerminal, PodExecTerminalDialog, PodLogs, PodLogsDialog, PodMetricsContext, PodNamesWithErrorsContext, PodNamesWithMetricsContext, PodsTable, READY_COLUMNS, RESOURCE_COLUMNS, RancherClusterLinksFormatter, ResourceUtilization, ServerSideKubernetesAuthProvider, ServicesAccordions, StandardClusterLinksFormatter, getDefaultFormatters, kubernetesApiRef, kubernetesAuthProvidersApiRef, kubernetesClusterLinkFormatterApiRef, kubernetesProxyApiRef, useCustomResources, useEvents, useIsPodExecTerminalSupported, useKubernetesObjects, useMatchingErrors, usePodLogs, usePodMetrics };
3266
3297
  //# sourceMappingURL=index.esm.js.map