@backstage/plugin-kubernetes-react 0.2.1-next.1 → 0.3.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # @backstage/plugin-kubernetes-react
2
2
 
3
+ ## 0.3.0-next.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 0d526c8: **BREAKING** The pod exec terminal is now disabled by default since there are several scenarios where it is known not to work. It can be re-enabled at your own risk by setting the config parameter `kubernetes.podExecTerminal.enabled` to `true`.
8
+
9
+ ### Patch Changes
10
+
11
+ - 536f67d: Fix broken XtermJS CSS import
12
+ - db1054b: Fixed a bug where the logs dialog and any other functionality depending on the proxy endpoint would fail for clusters configured with the OIDC auth provider.
13
+ - Updated dependencies
14
+ - @backstage/plugin-kubernetes-common@0.7.4-next.0
15
+ - @backstage/core-components@0.13.10
16
+ - @backstage/catalog-model@1.4.3
17
+ - @backstage/core-plugin-api@1.8.2
18
+ - @backstage/errors@1.2.3
19
+ - @backstage/types@1.1.1
20
+
21
+ ## 0.2.1
22
+
23
+ ### Patch Changes
24
+
25
+ - d5d2c67: Add `authuser` search parameter to GKE cluster link formatter in k8s plugin
26
+
27
+ Thanks to this, people with multiple simultaneously logged-in accounts in their GCP console will automatically view objects with the same email as the one signed in to the Google auth provider in Backstage.
28
+
29
+ - Updated dependencies
30
+ - @backstage/core-components@0.13.10
31
+ - @backstage/core-plugin-api@1.8.2
32
+ - @backstage/plugin-kubernetes-common@0.7.3
33
+ - @backstage/catalog-model@1.4.3
34
+ - @backstage/errors@1.2.3
35
+ - @backstage/types@1.1.1
36
+
3
37
  ## 0.2.1-next.1
4
38
 
5
39
  ### Patch Changes
package/config.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ import { PodExecTerminal } from './src/components/PodExecTerminal/PodExecTerminal';
2
+ /*
3
+ * Copyright 2023 The Backstage Authors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ export interface Config {
19
+ kubernetes?: {
20
+ /**
21
+ * Pod Exec Terminal config
22
+ */
23
+ podExecTerminal?: {
24
+ /**
25
+ * Enable `PodExecTerminal` UI feature
26
+ * @visibility frontend
27
+ */
28
+ enabled?: boolean;
29
+ };
30
+ };
31
+ }
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createApiRef, useApi, discoveryApiRef } from '@backstage/core-plugin-api';
1
+ import { useApi, configApiRef, createApiRef, discoveryApiRef } from '@backstage/core-plugin-api';
2
2
  import useAsync from 'react-use/lib/useAsync';
3
3
  import * as React from 'react';
4
4
  import React__default, { useCallback, useContext, useState, useEffect, useMemo, Fragment } from 'react';
@@ -13,6 +13,7 @@ import { LinearGauge, DismissableBanner, EmptyState, LogViewer, StructuredMetada
13
13
  import { DateTime } from 'luxon';
14
14
  import CloseIcon from '@material-ui/icons/Close';
15
15
  import OpenInBrowserIcon from '@material-ui/icons/OpenInBrowser';
16
+ import 'xterm/css/xterm.css';
16
17
  import { Terminal } from 'xterm';
17
18
  import { FitAddon } from 'xterm-addon-fit';
18
19
  import { AttachAddon } from 'xterm-addon-attach';
@@ -35,6 +36,11 @@ import lodash from 'lodash';
35
36
  import PauseIcon from '@material-ui/icons/Pause';
36
37
  import ErrorOutlineIcon from '@material-ui/icons/ErrorOutline';
37
38
 
39
+ const useIsPodExecTerminalEnabled = () => {
40
+ const configApi = useApi(configApiRef);
41
+ return configApi.getOptionalBoolean("kubernetes.podExecTerminal.enabled");
42
+ };
43
+
38
44
  const kubernetesApiRef = createApiRef({
39
45
  id: "plugin.kubernetes.service"
40
46
  });
@@ -422,8 +428,10 @@ class KubernetesBackendClient {
422
428
  }
423
429
  return cluster;
424
430
  }
425
- async getCredentials(authProvider) {
426
- return await this.kubernetesAuthProvidersApi.getCredentials(authProvider);
431
+ async getCredentials(authProvider, oidcTokenProvider) {
432
+ return await this.kubernetesAuthProvidersApi.getCredentials(
433
+ authProvider === "oidc" ? `${authProvider}.${oidcTokenProvider}` : authProvider
434
+ );
427
435
  }
428
436
  async getObjectsByEntity(requestBody) {
429
437
  return await this.postRequired(
@@ -459,7 +467,10 @@ class KubernetesBackendClient {
459
467
  const { authProvider, oidcTokenProvider } = await this.getCluster(
460
468
  options.clusterName
461
469
  );
462
- const kubernetesCredentials = await this.getCredentials(authProvider);
470
+ const kubernetesCredentials = await this.getCredentials(
471
+ authProvider,
472
+ oidcTokenProvider
473
+ );
463
474
  const url = `${await this.discoveryApi.getBaseUrl("kubernetes")}/proxy${options.path}`;
464
475
  const identityResponse = await this.identityApi.getCredentials();
465
476
  const headers = KubernetesBackendClient.getKubernetesHeaders(
@@ -879,7 +890,17 @@ class PodExecTerminalAttachAddon extends AttachAddon {
879
890
  _textEncoder = new WeakMap();
880
891
 
881
892
  const hasSocketProtocol = (url) => /wss?:\/\//.test(url.toString());
893
+ const useStyles$4 = makeStyles(
894
+ (theme) => createStyles({
895
+ podExecTerminal: {
896
+ width: "100%",
897
+ height: "100%",
898
+ "& .xterm-screen": { padding: theme.spacing(1) }
899
+ }
900
+ })
901
+ );
882
902
  const PodExecTerminal = (props) => {
903
+ const classes = useStyles$4();
883
904
  const { containerName, podNamespace, podName } = props;
884
905
  const [baseUrl, setBaseUrl] = useState(window.location.host);
885
906
  const terminalRef = React__default.useRef(null);
@@ -941,10 +962,7 @@ const PodExecTerminal = (props) => {
941
962
  {
942
963
  "data-testid": "terminal",
943
964
  ref: terminalRef,
944
- style: {
945
- width: "100%",
946
- height: "100%"
947
- }
965
+ className: classes.podExecTerminal
948
966
  }
949
967
  );
950
968
  };
@@ -1172,6 +1190,7 @@ const ContainerCard = ({
1172
1190
  containerMetrics
1173
1191
  }) => {
1174
1192
  var _a, _b;
1193
+ const isPodExecTerminalEnabled = useIsPodExecTerminalEnabled();
1175
1194
  if (containerSpec === void 0) {
1176
1195
  return /* @__PURE__ */ React__default.createElement(Typography, null, "error reading pod from cluster");
1177
1196
  }
@@ -1259,7 +1278,7 @@ const ContainerCard = ({
1259
1278
  ...podScope
1260
1279
  }
1261
1280
  }
1262
- ), /* @__PURE__ */ React__default.createElement(
1281
+ ), isPodExecTerminalEnabled && /* @__PURE__ */ React__default.createElement(
1263
1282
  PodExecTerminalDialog,
1264
1283
  {
1265
1284
  clusterName: podScope.clusterName,
@@ -3302,5 +3321,5 @@ const ErrorReporting = ({ detectedErrors }) => {
3302
3321
  ));
3303
3322
  };
3304
3323
 
3305
- 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 };
3324
+ 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, useIsPodExecTerminalEnabled, useIsPodExecTerminalSupported, useKubernetesObjects, useMatchingErrors, usePodLogs, usePodMetrics };
3306
3325
  //# sourceMappingURL=index.esm.js.map