@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/CHANGELOG.md +9 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +334 -176
- package/dist/index.esm.js.map +1 -1
- package/package.json +9 -9
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(
|
|
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(
|
|
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(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
this.kubernetesAuthProviderMap.set(
|
|
125
|
-
|
|
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(
|
|
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(
|
|
164
|
+
return await kubernetesAuthProvider.decorateRequestBodyForAuth(
|
|
165
|
+
requestBody
|
|
166
|
+
);
|
|
136
167
|
}
|
|
137
168
|
if (authProvider.startsWith("oidc.")) {
|
|
138
|
-
throw new Error(
|
|
169
|
+
throw new Error(
|
|
170
|
+
`KubernetesAuthProviders has no oidcProvider configured for ${authProvider}`
|
|
171
|
+
);
|
|
139
172
|
}
|
|
140
|
-
throw new Error(
|
|
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(
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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(
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
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
|
-
|
|
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(
|
|
437
|
-
|
|
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(
|
|
447
|
-
|
|
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(
|
|
524
|
-
|
|
525
|
-
|
|
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(
|
|
545
|
-
|
|
546
|
-
|
|
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(
|
|
555
|
-
|
|
556
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
606
|
-
|
|
607
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
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(
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
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(
|
|
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(
|
|
1313
|
-
|
|
1314
|
-
|
|
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
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
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(
|
|
1474
|
-
|
|
1475
|
-
|
|
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
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
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(
|
|
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(
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
2073
|
-
|
|
2074
|
-
|
|
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
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
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;
|