@backstage/plugin-kubernetes-backend 0.19.9-next.0 → 0.20.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @backstage/plugin-kubernetes-backend
2
2
 
3
+ ## 0.20.0-next.1
4
+
5
+ ### Minor Changes
6
+
7
+ - 759568d: **BREAKING CHANGE**: Removed support for the legacy backend system. This means that the deprecated `createRouter` and `KubernetesBuilder` and related types have been removed. Please refer to the [relevant documentation](https://backstage.io/docs/features/kubernetes/installation/#adding-kubernetes-backend-plugin) to configure the Kubernetes plugin.
8
+
9
+ **BREAKING CHANGE**: The deprecated types `AuthenticationStrategy`, `AuthMetadata`, `ClusterDetails`, `CustomResource`, `CustomResourcesByEntity`, `FetchResponseWrapper`, `KubernetesBuilder`, `KubernetesBuilderReturn`, `KubernetesClustersSupplier`, `KubernetesCredential`, `KubernetesEnvironment`, `KubernetesFetcher`, `KubernetesObjectsProvider`, `KubernetesObjectTypes`, `KubernetesServiceLocator`,`ObjectFetchParams`, `ObjectToFetch`,`RouterOptions` and `ServiceLocatorRequestContext` should all now be imported from `@backstage/plugin-kubernetes-node`.
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+ - @backstage/plugin-kubernetes-node@0.3.3-next.0
15
+
3
16
  ## 0.19.9-next.0
4
17
 
5
18
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"CatalogClusterLocator.cjs.js","sources":["../../src/cluster-locator/CatalogClusterLocator.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n AuthService,\n BackstageCredentials,\n} from '@backstage/backend-plugin-api';\nimport { ClusterDetails, KubernetesClustersSupplier } from '../types/types';\nimport { CATALOG_FILTER_EXISTS, CatalogApi } from '@backstage/catalog-client';\nimport {\n ANNOTATION_KUBERNETES_API_SERVER,\n ANNOTATION_KUBERNETES_API_SERVER_CA,\n ANNOTATION_KUBERNETES_AUTH_PROVIDER,\n ANNOTATION_KUBERNETES_SKIP_METRICS_LOOKUP,\n ANNOTATION_KUBERNETES_SKIP_TLS_VERIFY,\n ANNOTATION_KUBERNETES_DASHBOARD_URL,\n ANNOTATION_KUBERNETES_DASHBOARD_APP,\n ANNOTATION_KUBERNETES_DASHBOARD_PARAMETERS,\n} from '@backstage/plugin-kubernetes-common';\nimport { JsonObject } from '@backstage/types';\n\nfunction isObject(obj: unknown): obj is JsonObject {\n return typeof obj === 'object' && obj !== null && !Array.isArray(obj);\n}\n\nexport class CatalogClusterLocator implements KubernetesClustersSupplier {\n private catalogClient: CatalogApi;\n private auth: AuthService;\n\n constructor(catalogClient: CatalogApi, auth: AuthService) {\n this.catalogClient = catalogClient;\n this.auth = auth;\n }\n\n static fromConfig(\n catalogApi: CatalogApi,\n auth: AuthService,\n ): CatalogClusterLocator {\n return new CatalogClusterLocator(catalogApi, auth);\n }\n\n async getClusters(options?: {\n credentials: BackstageCredentials;\n }): Promise<ClusterDetails[]> {\n const apiServerKey = `metadata.annotations.${ANNOTATION_KUBERNETES_API_SERVER}`;\n const apiServerCaKey = `metadata.annotations.${ANNOTATION_KUBERNETES_API_SERVER_CA}`;\n const authProviderKey = `metadata.annotations.${ANNOTATION_KUBERNETES_AUTH_PROVIDER}`;\n\n const filter: Record<string, symbol | string> = {\n kind: 'Resource',\n 'spec.type': 'kubernetes-cluster',\n [apiServerKey]: CATALOG_FILTER_EXISTS,\n [apiServerCaKey]: CATALOG_FILTER_EXISTS,\n [authProviderKey]: CATALOG_FILTER_EXISTS,\n };\n\n const clusters = await this.catalogClient.getEntities(\n {\n filter: [filter],\n },\n options?.credentials\n ? {\n token: (\n await this.auth.getPluginRequestToken({\n onBehalfOf: options.credentials,\n targetPluginId: 'catalog',\n })\n ).token,\n }\n : undefined,\n );\n return clusters.items.map(entity => {\n const annotations = entity.metadata.annotations!;\n const clusterDetails: ClusterDetails = {\n name: entity.metadata.name,\n title: entity.metadata.title,\n url: annotations[ANNOTATION_KUBERNETES_API_SERVER],\n authMetadata: annotations,\n caData: annotations[ANNOTATION_KUBERNETES_API_SERVER_CA],\n skipMetricsLookup:\n annotations[ANNOTATION_KUBERNETES_SKIP_METRICS_LOOKUP] === 'true',\n skipTLSVerify:\n annotations[ANNOTATION_KUBERNETES_SKIP_TLS_VERIFY] === 'true',\n dashboardUrl: annotations[ANNOTATION_KUBERNETES_DASHBOARD_URL],\n dashboardApp: annotations[ANNOTATION_KUBERNETES_DASHBOARD_APP],\n dashboardParameters: this.getDashboardParameters(annotations),\n };\n\n return clusterDetails;\n });\n }\n\n private getDashboardParameters(\n annotations: Record<string, string>,\n ): JsonObject | undefined {\n const dashboardParamsString =\n annotations[ANNOTATION_KUBERNETES_DASHBOARD_PARAMETERS];\n if (dashboardParamsString) {\n try {\n const dashboardParams = JSON.parse(dashboardParamsString);\n return isObject(dashboardParams) ? dashboardParams : undefined;\n } catch {\n return undefined;\n }\n }\n return undefined;\n }\n}\n"],"names":["ANNOTATION_KUBERNETES_API_SERVER","ANNOTATION_KUBERNETES_API_SERVER_CA","ANNOTATION_KUBERNETES_AUTH_PROVIDER","CATALOG_FILTER_EXISTS","ANNOTATION_KUBERNETES_SKIP_METRICS_LOOKUP","ANNOTATION_KUBERNETES_SKIP_TLS_VERIFY","ANNOTATION_KUBERNETES_DASHBOARD_URL","ANNOTATION_KUBERNETES_DASHBOARD_APP","ANNOTATION_KUBERNETES_DASHBOARD_PARAMETERS"],"mappings":";;;;;AAkCA,SAAS,SAAS,GAAiC,EAAA;AACj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AAM,CAAA,GAAA,CAAI,CAAU,MAAA,KAAA;AAClC,MAAM,MAAA,WAAA,GAAc,OAAO,QAAS,CAAA,WAAA;AACpC,MAAA,MAAM,cAAiC,GAAA;AAAA,QACrC,IAAA,EAAM,OAAO,QAAS,CAAA,IAAA;AAAA,QACtB,KAAA,EAAO,OAAO,QAAS,CAAA,KAAA;AAAA,QACvB,GAAA,EAAK,YAAYH,uDAAgC,CAAA;AAAA,QACjD,YAAc,EAAA,WAAA;AAAA,QACd,MAAA,EAAQ,YAAYC,0DAAmC,CAAA;AAAA,QACvD,iBAAA,EACE,WAAY,CAAAG,gEAAyC,CAAM,KAAA,MAAA;AAAA,QAC7D,aAAA,EACE,WAAY,CAAAC,4DAAqC,CAAM,KAAA,MAAA;AAAA,QACzD,YAAA,EAAc,YAAYC,0DAAmC,CAAA;AAAA,QAC7D,YAAA,EAAc,YAAYC,0DAAmC,CAAA;AAAA,QAC7D,mBAAA,EAAqB,IAAK,CAAA,sBAAA,CAAuB,WAAW;AAAA,OAC9D;AAEA,MAAO,OAAA,cAAA;AAAA,KACR,CAAA;AAAA;AACH,EAEQ,uBACN,WACwB,EAAA;AACxB,IAAM,MAAA,qBAAA,GACJ,YAAYC,iEAA0C,CAAA;AACxD,IAAA,IAAI,qBAAuB,EAAA;AACzB,MAAI,IAAA;AACF,QAAM,MAAA,eAAA,GAAkB,IAAK,CAAA,KAAA,CAAM,qBAAqB,CAAA;AACxD,QAAO,OAAA,QAAA,CAAS,eAAe,CAAA,GAAI,eAAkB,GAAA,KAAA,CAAA;AAAA,OAC/C,CAAA,MAAA;AACN,QAAO,OAAA,KAAA,CAAA;AAAA;AACT;AAEF,IAAO,OAAA,KAAA,CAAA;AAAA;AAEX;;;;"}
1
+ {"version":3,"file":"CatalogClusterLocator.cjs.js","sources":["../../src/cluster-locator/CatalogClusterLocator.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n AuthService,\n BackstageCredentials,\n} from '@backstage/backend-plugin-api';\nimport {\n ClusterDetails,\n KubernetesClustersSupplier,\n} from '@backstage/plugin-kubernetes-node';\nimport { CATALOG_FILTER_EXISTS, CatalogApi } from '@backstage/catalog-client';\nimport {\n ANNOTATION_KUBERNETES_API_SERVER,\n ANNOTATION_KUBERNETES_API_SERVER_CA,\n ANNOTATION_KUBERNETES_AUTH_PROVIDER,\n ANNOTATION_KUBERNETES_SKIP_METRICS_LOOKUP,\n ANNOTATION_KUBERNETES_SKIP_TLS_VERIFY,\n ANNOTATION_KUBERNETES_DASHBOARD_URL,\n ANNOTATION_KUBERNETES_DASHBOARD_APP,\n ANNOTATION_KUBERNETES_DASHBOARD_PARAMETERS,\n} from '@backstage/plugin-kubernetes-common';\nimport { JsonObject } from '@backstage/types';\n\nfunction isObject(obj: unknown): obj is JsonObject {\n return typeof obj === 'object' && obj !== null && !Array.isArray(obj);\n}\n\nexport class CatalogClusterLocator implements KubernetesClustersSupplier {\n private catalogClient: CatalogApi;\n private auth: AuthService;\n\n constructor(catalogClient: CatalogApi, auth: AuthService) {\n this.catalogClient = catalogClient;\n this.auth = auth;\n }\n\n static fromConfig(\n catalogApi: CatalogApi,\n auth: AuthService,\n ): CatalogClusterLocator {\n return new CatalogClusterLocator(catalogApi, auth);\n }\n\n async getClusters(options?: {\n credentials: BackstageCredentials;\n }): Promise<ClusterDetails[]> {\n const apiServerKey = `metadata.annotations.${ANNOTATION_KUBERNETES_API_SERVER}`;\n const apiServerCaKey = `metadata.annotations.${ANNOTATION_KUBERNETES_API_SERVER_CA}`;\n const authProviderKey = `metadata.annotations.${ANNOTATION_KUBERNETES_AUTH_PROVIDER}`;\n\n const filter: Record<string, symbol | string> = {\n kind: 'Resource',\n 'spec.type': 'kubernetes-cluster',\n [apiServerKey]: CATALOG_FILTER_EXISTS,\n [apiServerCaKey]: CATALOG_FILTER_EXISTS,\n [authProviderKey]: CATALOG_FILTER_EXISTS,\n };\n\n const clusters = await this.catalogClient.getEntities(\n {\n filter: [filter],\n },\n options?.credentials\n ? {\n token: (\n await this.auth.getPluginRequestToken({\n onBehalfOf: options.credentials,\n targetPluginId: 'catalog',\n })\n ).token,\n }\n : undefined,\n );\n return clusters.items.map(entity => {\n const annotations = entity.metadata.annotations!;\n const clusterDetails: ClusterDetails = {\n name: entity.metadata.name,\n title: entity.metadata.title,\n url: annotations[ANNOTATION_KUBERNETES_API_SERVER],\n authMetadata: annotations,\n caData: annotations[ANNOTATION_KUBERNETES_API_SERVER_CA],\n skipMetricsLookup:\n annotations[ANNOTATION_KUBERNETES_SKIP_METRICS_LOOKUP] === 'true',\n skipTLSVerify:\n annotations[ANNOTATION_KUBERNETES_SKIP_TLS_VERIFY] === 'true',\n dashboardUrl: annotations[ANNOTATION_KUBERNETES_DASHBOARD_URL],\n dashboardApp: annotations[ANNOTATION_KUBERNETES_DASHBOARD_APP],\n dashboardParameters: this.getDashboardParameters(annotations),\n };\n\n return clusterDetails;\n });\n }\n\n private getDashboardParameters(\n annotations: Record<string, string>,\n ): JsonObject | undefined {\n const dashboardParamsString =\n annotations[ANNOTATION_KUBERNETES_DASHBOARD_PARAMETERS];\n if (dashboardParamsString) {\n try {\n const dashboardParams = JSON.parse(dashboardParamsString);\n return isObject(dashboardParams) ? dashboardParams : undefined;\n } catch {\n return undefined;\n }\n }\n return undefined;\n }\n}\n"],"names":["ANNOTATION_KUBERNETES_API_SERVER","ANNOTATION_KUBERNETES_API_SERVER_CA","ANNOTATION_KUBERNETES_AUTH_PROVIDER","CATALOG_FILTER_EXISTS","ANNOTATION_KUBERNETES_SKIP_METRICS_LOOKUP","ANN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AA,CAAA;AAAA;AAEX;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigClusterLocator.cjs.js","sources":["../../src/cluster-locator/ConfigClusterLocator.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport {\n ANNOTATION_KUBERNETES_AUTH_PROVIDER,\n ANNOTATION_KUBERNETES_AWS_ASSUME_ROLE,\n ANNOTATION_KUBERNETES_AWS_EXTERNAL_ID,\n ANNOTATION_KUBERNETES_OIDC_TOKEN_PROVIDER,\n} from '@backstage/plugin-kubernetes-common';\nimport { ClusterDetails, KubernetesClustersSupplier } from '../types/types';\nimport { AuthenticationStrategy } from '../auth';\n\nexport class ConfigClusterLocator implements KubernetesClustersSupplier {\n private readonly clusterDetails: ClusterDetails[];\n\n constructor(clusterDetails: ClusterDetails[]) {\n this.clusterDetails = clusterDetails;\n }\n\n static fromConfig(\n config: Config,\n authStrategy: AuthenticationStrategy,\n ): ConfigClusterLocator {\n const clusterNames = new Set();\n return new ConfigClusterLocator(\n config.getConfigArray('clusters').map(c => {\n const authMetadataBlock = c.getOptional<{\n [ANNOTATION_KUBERNETES_AUTH_PROVIDER]?: string;\n }>('authMetadata');\n const name = c.getString('name');\n if (clusterNames.has(name)) {\n throw new Error(`Duplicate cluster name '${name}'`);\n }\n clusterNames.add(name);\n const authProvider =\n authMetadataBlock?.[ANNOTATION_KUBERNETES_AUTH_PROVIDER] ??\n c.getOptionalString('authProvider');\n if (!authProvider) {\n throw new Error(\n `cluster '${name}' has no auth provider configured; this must be ` +\n `specified via the 'authProvider' or ` +\n `'authMetadata.${ANNOTATION_KUBERNETES_AUTH_PROVIDER}' parameter`,\n );\n }\n const title = c.getOptionalString('title');\n const clusterDetails: ClusterDetails = {\n name,\n ...(title && { title }),\n url: c.getString('url'),\n skipTLSVerify: c.getOptionalBoolean('skipTLSVerify') ?? false,\n skipMetricsLookup: c.getOptionalBoolean('skipMetricsLookup') ?? false,\n caData: c.getOptionalString('caData'),\n caFile: c.getOptionalString('caFile'),\n authMetadata: {\n [ANNOTATION_KUBERNETES_AUTH_PROVIDER]: authProvider,\n ...ConfigClusterLocator.parseAuthMetadata(c),\n ...authMetadataBlock,\n },\n };\n\n const customResources = c.getOptionalConfigArray('customResources');\n if (customResources) {\n clusterDetails.customResources = customResources.map(cr => {\n return {\n group: cr.getString('group'),\n apiVersion: cr.getString('apiVersion'),\n plural: cr.getString('plural'),\n };\n });\n }\n\n const dashboardUrl = c.getOptionalString('dashboardUrl');\n if (dashboardUrl) {\n clusterDetails.dashboardUrl = dashboardUrl;\n }\n const dashboardApp = c.getOptionalString('dashboardApp');\n if (dashboardApp) {\n clusterDetails.dashboardApp = dashboardApp;\n }\n if (c.has('dashboardParameters')) {\n clusterDetails.dashboardParameters = c.get('dashboardParameters');\n }\n\n const validationErrors = authStrategy.validateCluster(\n clusterDetails.authMetadata,\n );\n if (validationErrors.length !== 0) {\n throw new Error(\n `Invalid cluster '${clusterDetails.name}': ${validationErrors\n .map(e => e.message)\n .join(', ')}`,\n );\n }\n return clusterDetails;\n }),\n );\n }\n\n private static parseAuthMetadata(\n clusterConfig: Config,\n ): Record<string, string> | undefined {\n const serviceAccountToken = clusterConfig.getOptionalString(\n 'serviceAccountToken',\n );\n const assumeRole = clusterConfig.getOptionalString('assumeRole');\n const externalId = clusterConfig.getOptionalString('externalId');\n const oidcTokenProvider =\n clusterConfig.getOptionalString('oidcTokenProvider');\n\n return serviceAccountToken || assumeRole || externalId || oidcTokenProvider\n ? {\n ...(serviceAccountToken && { serviceAccountToken }),\n ...(assumeRole && {\n [ANNOTATION_KUBERNETES_AWS_ASSUME_ROLE]: assumeRole,\n }),\n ...(externalId && {\n [ANNOTATION_KUBERNETES_AWS_EXTERNAL_ID]: externalId,\n }),\n ...(oidcTokenProvider && {\n [ANNOTATION_KUBERNETES_OIDC_TOKEN_PROVIDER]: oidcTokenProvider,\n }),\n }\n : undefined;\n }\n\n async getClusters(): Promise<ClusterDetails[]> {\n return this.clusterDetails;\n }\n}\n"],"names":["ANNOTATION_KUBERNETES_AUTH_PROVIDER","ANNOTATION_KUBERNETES_AWS_ASSUME_ROLE","ANNOTATION_KUBERNETES_AWS_EXTERNAL_ID","ANNOTATION_KUBERNETES_OIDC_TOKEN_PROVIDER"],"mappings":";;;;AA0BO,MAAM,oBAA2D,CAAA;AAAA,EACrD,cAAA;AAAA,EAEjB,YAAY,cAAkC,EAAA;AAC5C,IAAA,IAAA,CAAK,cAAiB,GAAA,cAAA;AAAA;AACxB,EAEA,OAAO,UACL,CAAA,MAAA,EACA,YACsB,EAAA;AACtB,IAAM,MAAA,YAAA,uBAAmB,GAAI,EAAA;AAC7B,IAAA,OAAO,IAAI,oBAAA;AAAA,MACT,MAAO,CAAA,cAAA,CAAe,UAAU,CAAA,CAAE,IAAI,CAAK,CAAA,KAAA;AACzC,QAAM,MAAA,iBAAA,GAAoB,CAAE,CAAA,WAAA,CAEzB,cAAc,CAAA;AACjB,QAAM,MAAA,IAAA,GAAO,CAAE,CAAA,SAAA,CAAU,MAAM,CAAA;AAC/B,QAAI,IAAA,YAAA,CAAa,GAAI,CAAA,IAAI,CAAG,EAAA;AAC1B,UAAA,MAAM,IAAI,KAAA,CAAM,CAA2B,wBAAA,EAAA,IAAI,CAAG,CAAA,CAAA,CAAA;AAAA;AAEpD,QAAA,YAAA,CAAa,IAAI,IAAI,CAAA;AACrB,QAAA,MAAM,eACJ,iBAAoB,GAAAA,0DAAmC,CACvD,IAAA,CAAA,CAAE,kBAAkB,cAAc,CAAA;AACpC,QAAA,IAAI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AAI,mBAAuB,IAAA,EAAE,mBAAoB,EAAA;AAAA,MACjD,GAAI,UAAc,IAAA;AAAA,QAChB,CAACC,4DAAqC,GAAG;AAAA,OAC3C;AAAA,MACA,GAAI,UAAc,IAAA;AAAA,QAChB,CAACC,4DAAqC,GAAG;AAAA,OAC3C;AAAA,MACA,GAAI,iBAAqB,IAAA;AAAA,QACvB,CAACC,gEAAyC,GAAG;AAAA;AAC/C,KAEF,GAAA,KAAA,CAAA;AAAA;AACN,EAEA,MAAM,WAAyC,GAAA;AAC7C,IAAA,OAAO,IAAK,CAAA,cAAA;AAAA;AAEhB;;;;"}
1
+ {"version":3,"file":"ConfigClusterLocator.cjs.js","sources":["../../src/cluster-locator/ConfigClusterLocator.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport {\n ANNOTATION_KUBERNETES_AUTH_PROVIDER,\n ANNOTATION_KUBERNETES_AWS_ASSUME_ROLE,\n ANNOTATION_KUBERNETES_AWS_EXTERNAL_ID,\n ANNOTATION_KUBERNETES_OIDC_TOKEN_PROVIDER,\n} from '@backstage/plugin-kubernetes-common';\nimport {\n ClusterDetails,\n KubernetesClustersSupplier,\n AuthenticationStrategy,\n} from '@backstage/plugin-kubernetes-node';\n\nexport class ConfigClusterLocator implements KubernetesClustersSupplier {\n private readonly clusterDetails: ClusterDetails[];\n\n constructor(clusterDetails: ClusterDetails[]) {\n this.clusterDetails = clusterDetails;\n }\n\n static fromConfig(\n config: Config,\n authStrategy: AuthenticationStrategy,\n ): ConfigClusterLocator {\n const clusterNames = new Set();\n return new ConfigClusterLocator(\n config.getConfigArray('clusters').map(c => {\n const authMetadataBlock = c.getOptional<{\n [ANNOTATION_KUBERNETES_AUTH_PROVIDER]?: string;\n }>('authMetadata');\n const name = c.getString('name');\n if (clusterNames.has(name)) {\n throw new Error(`Duplicate cluster name '${name}'`);\n }\n clusterNames.add(name);\n const authProvider =\n authMetadataBlock?.[ANNOTATION_KUBERNETES_AUTH_PROVIDER] ??\n c.getOptionalString('authProvider');\n if (!authProvider) {\n throw new Error(\n `cluster '${name}' has no auth provider configured; this must be ` +\n `specified via the 'authProvider' or ` +\n `'authMetadata.${ANNOTATION_KUBERNETES_AUTH_PROVIDER}' parameter`,\n );\n }\n const title = c.getOptionalString('title');\n const clusterDetails: ClusterDetails = {\n name,\n ...(title && { title }),\n url: c.getString('url'),\n skipTLSVerify: c.getOptionalBoolean('skipTLSVerify') ?? false,\n skipMetricsLookup: c.getOptionalBoolean('skipMetricsLookup') ?? false,\n caData: c.getOptionalString('caData'),\n caFile: c.getOptionalString('caFile'),\n authMetadata: {\n [ANNOTATION_KUBERNETES_AUTH_PROVIDER]: authProvider,\n ...ConfigClusterLocator.parseAuthMetadata(c),\n ...authMetadataBlock,\n },\n };\n\n const customResources = c.getOptionalConfigArray('customResources');\n if (customResources) {\n clusterDetails.customResources = customResources.map(cr => {\n return {\n group: cr.getString('group'),\n apiVersion: cr.getString('apiVersion'),\n plural: cr.getString('plural'),\n };\n });\n }\n\n const dashboardUrl = c.getOptionalString('dashboardUrl');\n if (dashboardUrl) {\n clusterDetails.dashboardUrl = dashboardUrl;\n }\n const dashboardApp = c.getOptionalString('dashboardApp');\n if (dashboardApp) {\n clusterDetails.dashboardApp = dashboardApp;\n }\n if (c.has('dashboardParameters')) {\n clusterDetails.dashboardParameters = c.get('dashboardParameters');\n }\n\n const validationErrors = authStrategy.validateCluster(\n clusterDetails.authMetadata,\n );\n if (validationErrors.length !== 0) {\n throw new Error(\n `Invalid cluster '${clusterDetails.name}': ${validationErrors\n .map(e => e.message)\n .join(', ')}`,\n );\n }\n return clusterDetails;\n }),\n );\n }\n\n private static parseAuthMetadata(\n clusterConfig: Config,\n ): Record<string, string> | undefined {\n const serviceAccountToken = clusterConfig.getOptionalString(\n 'serviceAccountToken',\n );\n const assumeRole = clusterConfig.getOptionalString('assumeRole');\n const externalId = clusterConfig.getOptionalString('externalId');\n const oidcTokenProvider =\n clusterConfig.getOptionalString('oidcTokenProvider');\n\n return serviceAccountToken || assumeRole || externalId || oidcTokenProvider\n ? {\n ...(serviceAccountToken && { serviceAccountToken }),\n ...(assumeRole && {\n [ANNOTATION_KUBERNETES_AWS_ASSUME_ROLE]: assumeRole,\n }),\n ...(externalId && {\n [ANNOTATION_KUBERNETES_AWS_EXTERNAL_ID]: externalId,\n }),\n ...(oidcTokenProvider && {\n [ANNOTATION_KUBERNETES_OIDC_TOKEN_PROVIDER]: oidcTokenProvider,\n }),\n }\n : undefined;\n }\n\n async getClusters(): Promise<ClusterDetails[]> {\n return this.clusterDetails;\n }\n}\n"],"names":["ANNOTATION_KUBERNETES_AUTH_PROVIDER","ANNOTATION_KUBERNETES_AWS_ASSUME_ROLE","ANNOTATION_KUBERNETES_AWS_EXTERNAL_ID","ANNOTATION_KUBERNETES_OIDC_TOKEN_PROVIDER"],"mappings":";;;;AA6BO,MAAM,oBAA2D,CAAA;AAAA,EACrD,cAAA;AAAA,EAEjB,YAAY,cAAkC,EAAA;AAC5C,IAAA,IAAA,CAAK,cAAiB,GAAA,cAAA;AAAA;AACxB,EAEA,OAAO,UACL,CAAA,MAAA,EACA,YACsB,EAAA;AACtB,IAAM,MAAA,YAAA,uBAAmB,GAAI,EAAA;AAC7B,IAAA,OAAO,IAAI,oBAAA;AAAA,MACT,MAAO,CAAA,cAAA,CAAe,UAAU,CAAA,CAAE,IAAI,CAAK,CAAA,KAAA;AACzC,QAAM,MAAA,iBAAA,GAAoB,CAAE,CAAA,WAAA,CAEzB,cAAc,CAAA;AACjB,QAAM,MAAA,I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IAAA,MAAM,sBAAsB,aAAc,CAAA,iBAAA;AAAA,MACxC;AAAA,KACF;AACA,IAAM,MAAA,UAAA,GAAa,aAAc,CAAA,iBAAA,CAAkB,YAAY,CAAA;AAC/D,IAAM,MAAA,UAAA,GAAa,aAAc,CAAA,iBAAA,CAAkB,YAAY,CAAA;AAC/D,IAAM,MAAA,iBAAA,GACJ,aAAc,CAAA,iBAAA,CAAkB,mBAAmB,CAAA;AAErD,IAAO,OAAA,mBAAA,IAAuB,UAAc,IAAA,UAAA,IAAc,iBACtD,GAAA;AAAA,MACE,GAAI,mBAAuB,IAAA,EAAE,mBAAoB,EAAA;AAAA,MACjD,GAAI,UAAc,IAAA;AAAA,QAChB,CAACC,4DAAqC,GAAG;AAAA,OAC3C;AAAA,MACA,GAAI,UAAc,IAAA;AAAA,QAChB,CAACC,4DAAqC,GAAG;AAAA,OAC3C;AAAA,MACA,GAAI,iBAAqB,IAAA;AAAA,QACvB,CAACC,gEAAyC,GAAG;AAAA;AAC/C,KAEF,GAAA,KAAA,CAAA;AAAA;AACN,EAEA,MAAM,WAAyC,GAAA;AAC7C,IAAA,OAAO,IAAK,CAAA,cAAA;AAAA;AAEhB;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"GkeClusterLocator.cjs.js","sources":["../../src/cluster-locator/GkeClusterLocator.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ANNOTATION_KUBERNETES_AUTH_PROVIDER } from '@backstage/plugin-kubernetes-common';\nimport { Config } from '@backstage/config';\nimport { ForwardedError } from '@backstage/errors';\nimport * as container from '@google-cloud/container';\nimport { Duration } from 'luxon';\nimport { runPeriodically } from '../service/runPeriodically';\nimport { ClusterDetails, KubernetesClustersSupplier } from '../types/types';\nimport packageinfo from '../../package.json';\n\ninterface MatchResourceLabelEntry {\n key: string;\n value: string;\n}\n\ntype GkeClusterLocatorOptions = {\n projectId: string;\n authProvider: string;\n region?: string;\n skipTLSVerify?: boolean;\n skipMetricsLookup?: boolean;\n exposeDashboard?: boolean;\n matchingResourceLabels?: MatchResourceLabelEntry[];\n};\n\nexport class GkeClusterLocator implements KubernetesClustersSupplier {\n constructor(\n private readonly options: GkeClusterLocatorOptions,\n private readonly client: container.v1.ClusterManagerClient,\n private clusterDetails: ClusterDetails[] | undefined = undefined,\n private hasClusterDetails: boolean = false,\n ) {}\n\n static fromConfigWithClient(\n config: Config,\n client: container.v1.ClusterManagerClient,\n refreshInterval?: Duration,\n ): GkeClusterLocator {\n const matchingResourceLabels: MatchResourceLabelEntry[] =\n config.getOptionalConfigArray('matchingResourceLabels')?.map(mrl => {\n return { key: mrl.getString('key'), value: mrl.getString('value') };\n }) ?? [];\n\n const storeAuthProviderString =\n config.getOptionalString('authProvider') === 'googleServiceAccount'\n ? 'googleServiceAccount'\n : 'google';\n\n const options = {\n projectId: config.getString('projectId'),\n authProvider: storeAuthProviderString,\n region: config.getOptionalString('region') ?? '-',\n skipTLSVerify: config.getOptionalBoolean('skipTLSVerify') ?? false,\n skipMetricsLookup:\n config.getOptionalBoolean('skipMetricsLookup') ?? false,\n exposeDashboard: config.getOptionalBoolean('exposeDashboard') ?? false,\n matchingResourceLabels,\n };\n const gkeClusterLocator = new GkeClusterLocator(options, client);\n if (refreshInterval) {\n runPeriodically(\n () => gkeClusterLocator.refreshClusters(),\n refreshInterval.toMillis(),\n );\n }\n return gkeClusterLocator;\n }\n\n // Added an `x-goog-api-client` header to API requests made by the GKE cluster locator to clearly identify API requests from this plugin.\n static fromConfig(\n config: Config,\n refreshInterval: Duration | undefined = undefined,\n ): GkeClusterLocator {\n return GkeClusterLocator.fromConfigWithClient(\n config,\n new container.v1.ClusterManagerClient({\n libName: `backstage/kubernetes-backend.GkeClusterLocator`,\n libVersion: packageinfo.version,\n }),\n refreshInterval,\n );\n }\n\n async getClusters(): Promise<ClusterDetails[]> {\n if (!this.hasClusterDetails) {\n // refresh at least once when first called, when retries are disabled and in tests\n await this.refreshClusters();\n }\n return this.clusterDetails ?? [];\n }\n\n // TODO pass caData into the object\n async refreshClusters(): Promise<void> {\n const {\n projectId,\n region,\n authProvider,\n skipTLSVerify,\n skipMetricsLookup,\n exposeDashboard,\n matchingResourceLabels,\n } = this.options;\n const request = {\n parent: `projects/${projectId}/locations/${region}`,\n };\n\n try {\n const [response] = await this.client.listClusters(request);\n this.clusterDetails = (response.clusters ?? [])\n .filter(r => {\n return matchingResourceLabels?.every(mrl => {\n if (!r.resourceLabels) {\n return false;\n }\n return r.resourceLabels[mrl.key] === mrl.value;\n });\n })\n .map(r => ({\n // TODO filter out clusters which don't have name or endpoint\n name: r.name ?? 'unknown',\n url: `https://${r.endpoint ?? ''}`,\n authMetadata: { [ANNOTATION_KUBERNETES_AUTH_PROVIDER]: authProvider },\n skipTLSVerify,\n skipMetricsLookup,\n ...(exposeDashboard\n ? {\n dashboardApp: 'gke',\n dashboardParameters: {\n projectId,\n region,\n clusterName: r.name,\n },\n }\n : {}),\n }));\n this.hasClusterDetails = true;\n } catch (e) {\n throw new ForwardedError(\n `There was an error retrieving clusters from GKE for projectId=${projectId} region=${region}`,\n e,\n );\n }\n }\n}\n"],"names":["runPeriodically","container","packageinfo","ANNOTATION_KUBERNETES_AUTH_PROVIDER","ForwardedError"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCO,MAAM,iBAAwD,CAAA;AAAA,EACnE,YACmB,OACA,EAAA,MAAA,EACT,cAA+C,GAAA,KAAA,CAAA,EAC/C,oBAA6B,KACrC,EAAA;AAJiB,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AACA,IAAA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F,CACA,CAAA,GAAA,CAAI,CAAM,CAAA,MAAA;AAAA;AAAA,QAET,IAAA,EAAM,EAAE,IAAQ,IAAA,SAAA;AAAA,QAChB,GAAK,EAAA,CAAA,QAAA,EAAW,CAAE,CAAA,QAAA,IAAY,EAAE,CAAA,CAAA;AAAA,QAChC,YAAc,EAAA,EAAE,CAACC,0DAAmC,GAAG,YAAa,EAAA;AAAA,QACpE,aAAA;AAAA,QACA,iBAAA;AAAA,QACA,GAAI,eACA,GAAA;AAAA,UACE,YAAc,EAAA,KAAA;AAAA,UACd,mBAAqB,EAAA;AAAA,YACnB,SAAA;AAAA,YACA,MAAA;AAAA,YACA,aAAa,CAAE,CAAA;AAAA;AACjB,YAEF;AAAC,OACL,CAAA,CAAA;AACJ,MAAA,IAAA,CAAK,iBAAoB,GAAA,IAAA;AAAA,aAClB,CAAG,EAAA;AACV,MAAA,MAAM,IAAIC,qBAAA;AAAA,QACR,CAAA,8DAAA,EAAiE,SAAS,CAAA,QAAA,EAAW,MAAM,CAAA,CAAA;AAAA,QAC3F;AAAA,OACF;AAAA;AACF;AAEJ;;;;"}
1
+ {"version":3,"file":"GkeClusterLocator.cjs.js","sources":["../../src/cluster-locator/GkeClusterLocator.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ANNOTATION_KUBERNETES_AUTH_PROVIDER } from '@backstage/plugin-kubernetes-common';\nimport { Config } from '@backstage/config';\nimport { ForwardedError } from '@backstage/errors';\nimport * as container from '@google-cloud/container';\nimport { Duration } from 'luxon';\nimport { runPeriodically } from '../service/runPeriodically';\nimport {\n ClusterDetails,\n KubernetesClustersSupplier,\n} from '@backstage/plugin-kubernetes-node';\nimport packageinfo from '../../package.json';\n\ninterface MatchResourceLabelEntry {\n key: string;\n value: string;\n}\n\ntype GkeClusterLocatorOptions = {\n projectId: string;\n authProvider: string;\n region?: string;\n skipTLSVerify?: boolean;\n skipMetricsLookup?: boolean;\n exposeDashboard?: boolean;\n matchingResourceLabels?: MatchResourceLabelEntry[];\n};\n\nexport class GkeClusterLocator implements KubernetesClustersSupplier {\n constructor(\n private readonly options: GkeClusterLocatorOptions,\n private readonly client: container.v1.ClusterManagerClient,\n private clusterDetails: ClusterDetails[] | undefined = undefined,\n private hasClusterDetails: boolean = false,\n ) {}\n\n static fromConfigWithClient(\n config: Config,\n client: container.v1.ClusterManagerClient,\n refreshInterval?: Duration,\n ): GkeClusterLocator {\n const matchingResourceLabels: MatchResourceLabelEntry[] =\n config.getOptionalConfigArray('matchingResourceLabels')?.map(mrl => {\n return { key: mrl.getString('key'), value: mrl.getString('value') };\n }) ?? [];\n\n const storeAuthProviderString =\n config.getOptionalString('authProvider') === 'googleServiceAccount'\n ? 'googleServiceAccount'\n : 'google';\n\n const options = {\n projectId: config.getString('projectId'),\n authProvider: storeAuthProviderString,\n region: config.getOptionalString('region') ?? '-',\n skipTLSVerify: config.getOptionalBoolean('skipTLSVerify') ?? false,\n skipMetricsLookup:\n config.getOptionalBoolean('skipMetricsLookup') ?? false,\n exposeDashboard: config.getOptionalBoolean('exposeDashboard') ?? false,\n matchingResourceLabels,\n };\n const gkeClusterLocator = new GkeClusterLocator(options, client);\n if (refreshInterval) {\n runPeriodically(\n () => gkeClusterLocator.refreshClusters(),\n refreshInterval.toMillis(),\n );\n }\n return gkeClusterLocator;\n }\n\n // Added an `x-goog-api-client` header to API requests made by the GKE cluster locator to clearly identify API requests from this plugin.\n static fromConfig(\n config: Config,\n refreshInterval: Duration | undefined = undefined,\n ): GkeClusterLocator {\n return GkeClusterLocator.fromConfigWithClient(\n config,\n new container.v1.ClusterManagerClient({\n libName: `backstage/kubernetes-backend.GkeClusterLocator`,\n libVersion: packageinfo.version,\n }),\n refreshInterval,\n );\n }\n\n async getClusters(): Promise<ClusterDetails[]> {\n if (!this.hasClusterDetails) {\n // refresh at least once when first called, when retries are disabled and in tests\n await this.refreshClusters();\n }\n return this.clusterDetails ?? [];\n }\n\n // TODO pass caData into the object\n async refreshClusters(): Promise<void> {\n const {\n projectId,\n region,\n authProvider,\n skipTLSVerify,\n skipMetricsLookup,\n exposeDashboard,\n matchingResourceLabels,\n } = this.options;\n const request = {\n parent: `projects/${projectId}/locations/${region}`,\n };\n\n try {\n const [response] = await this.client.listClusters(request);\n this.clusterDetails = (response.clusters ?? [])\n .filter(r => {\n return matchingResourceLabels?.every(mrl => {\n if (!r.resourceLabels) {\n return false;\n }\n return r.resourceLabels[mrl.key] === mrl.value;\n });\n })\n .map(r => ({\n // TODO filter out clusters which don't have name or endpoint\n name: r.name ?? 'unknown',\n url: `https://${r.endpoint ?? ''}`,\n authMetadata: { [ANNOTATION_KUBERNETES_AUTH_PROVIDER]: authProvider },\n skipTLSVerify,\n skipMetricsLookup,\n ...(exposeDashboard\n ? {\n dashboardApp: 'gke',\n dashboardParameters: {\n projectId,\n region,\n clusterName: r.name,\n },\n }\n : {}),\n }));\n this.hasClusterDetails = true;\n } catch (e) {\n throw new ForwardedError(\n `There was an error retrieving clusters from GKE for projectId=${projectId} region=${region}`,\n e,\n );\n }\n }\n}\n"],"names":["runPeriodically","container","packageinfo","ANNOTATION_KUBERNETES_AUTH_PROVIDER","ForwardedError"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CO,MAAM,iBAAwD,CAAA;AAAA,EACnE,YACmB,OACA,EAAA,MAAA,EACT,cAA+C,GAAA,KAAA,CAAA,EAC/C,oBAA6B,KACrC,EAAA;AAJiB,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AACA,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AACT,IAAA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A;AAAA;AAAA,QAET,IAAA,EAAM,EAAE,IAAQ,IAAA,SAAA;AAAA,QAChB,GAAK,EAAA,CAAA,QAAA,EAAW,CAAE,CAAA,QAAA,IAAY,EAAE,CAAA,CAAA;AAAA,QAChC,YAAc,EAAA,EAAE,CAACC,0DAAmC,GAAG,YAAa,EAAA;AAAA,QACpE,aAAA;AAAA,QACA,iBAAA;AAAA,QACA,GAAI,eACA,GAAA;AAAA,UACE,YAAc,EAAA,KAAA;AAAA,UACd,mBAAqB,EAAA;AAAA,YACnB,SAAA;AAAA,YACA,MAAA;AAAA,YACA,aAAa,CAAE,CAAA;AAAA;AACjB,YAEF;AAAC,OACL,CAAA,CAAA;AACJ,MAAA,IAAA,CAAK,iBAAoB,GAAA,IAAA;AAAA,aAClB,CAAG,EAAA;AACV,MAAA,MAAM,IAAIC,qBAAA;AAAA,QACR,CAAA,8DAAA,EAAiE,SAAS,CAAA,QAAA,EAAW,MAAM,CAAA,CAAA;AAAA,QAC3F;AAAA,OACF;AAAA;AACF;AAEJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../../src/cluster-locator/index.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CatalogApi } from '@backstage/catalog-client';\nimport { Config } from '@backstage/config';\nimport { Duration } from 'luxon';\nimport { ClusterDetails, KubernetesClustersSupplier } from '../types/types';\nimport { AuthenticationStrategy } from '../auth/types';\nimport { ConfigClusterLocator } from './ConfigClusterLocator';\nimport { GkeClusterLocator } from './GkeClusterLocator';\nimport { CatalogClusterLocator } from './CatalogClusterLocator';\nimport { LocalKubectlProxyClusterLocator } from './LocalKubectlProxyLocator';\nimport {\n AuthService,\n BackstageCredentials,\n LoggerService,\n} from '@backstage/backend-plugin-api';\n\nclass CombinedClustersSupplier implements KubernetesClustersSupplier {\n constructor(\n readonly clusterSuppliers: KubernetesClustersSupplier[],\n readonly logger: LoggerService,\n ) {}\n\n async getClusters(options: {\n credentials: BackstageCredentials;\n }): Promise<ClusterDetails[]> {\n const clusters = await Promise.all(\n this.clusterSuppliers.map(supplier => supplier.getClusters(options)),\n )\n .then(res => {\n return res.flat();\n })\n .catch(e => {\n throw e;\n });\n return this.warnDuplicates(clusters);\n }\n\n private warnDuplicates(clusters: ClusterDetails[]): ClusterDetails[] {\n const clusterNames = new Set<string>();\n const duplicatedNames = new Set<string>();\n for (const clusterName of clusters.map(c => c.name)) {\n if (clusterNames.has(clusterName)) {\n duplicatedNames.add(clusterName);\n } else {\n clusterNames.add(clusterName);\n }\n }\n for (const clusterName of duplicatedNames) {\n this.logger.warn(`Duplicate cluster name '${clusterName}'`);\n }\n return clusters;\n }\n}\n\nexport const getCombinedClusterSupplier = (\n rootConfig: Config,\n catalogClient: CatalogApi,\n authStrategy: AuthenticationStrategy,\n logger: LoggerService,\n refreshInterval: Duration | undefined = undefined,\n auth: AuthService,\n): KubernetesClustersSupplier => {\n const clusterSuppliers = rootConfig\n .getConfigArray('kubernetes.clusterLocatorMethods')\n .map(clusterLocatorMethod => {\n const type = clusterLocatorMethod.getString('type');\n switch (type) {\n case 'catalog':\n return CatalogClusterLocator.fromConfig(catalogClient, auth);\n case 'localKubectlProxy':\n return new LocalKubectlProxyClusterLocator();\n case 'config':\n return ConfigClusterLocator.fromConfig(\n clusterLocatorMethod,\n authStrategy,\n );\n case 'gke':\n return GkeClusterLocator.fromConfig(\n clusterLocatorMethod,\n refreshInterval,\n );\n default:\n throw new Error(\n `Unsupported kubernetes.clusterLocatorMethods: \"${type}\"`,\n );\n }\n });\n\n return new CombinedClustersSupplier(clusterSuppliers, logger);\n};\n"],"names":["CatalogClusterLocator","LocalKubectlProxyClusterLocator","ConfigClusterLocator","GkeClusterLocator"],"mappings":";;;;;;;AA+BA,MAAM,wBAA+D,CAAA;AAAA,EACnE,WAAA,CACW,kBACA,MACT,EAAA;AAFS,IAAA,IAAA,CAAA,gBAAA,GAAA,gBAAA;AACA,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA;AACR,EAEH,MAAM,YAAY,OAEY,EAAA;AAC5B,IAAM,MAAA,QAAA,GAAW,MAAM,OAAQ,CAAA,GAAA;AAAA,MAC7B,KAAK,gBAAiB,CAAA,GAAA,CAAI,cAAY,QAAS,CAAA,WAAA,CAAY,OAAO,CAAC;AAAA,KACrE,CACG,KAAK,CAAO,GAAA,KAAA;AACX,MAAA,OAAO,IAAI,IAAK,EAAA;AAAA,KACjB,CACA,CAAA,KAAA,CAAM,CAAK,CAAA,KAAA;AACV,MAAM,MAAA,CAAA;AAAA,KACP,CAAA;AACH,IAAO,OAAA,IAAA,CAAK,eAAe,QAAQ,CAAA;AAAA;AACrC,EAEQ,eAAe,QAA8C,EAAA;AACnE,IAAM,MAAA,YAAA,uBAAmB,GAAY,EAAA;AACrC,IAAM,MAAA,eAAA,uBAAsB,GAAY,EAAA;AACxC,IAAA,KAAA,MAAW,eAAe,QAAS,CAAA,GAAA,CAAI,CAAK,CAAA,KAAA,CAAA,CAAE,IAAI,CAAG,EAAA;AACnD,MAAI,IAAA,YAAA,CAAa,GAAI,CAAA,WAAW,CAAG,EAAA;AACjC,QAAA,eAAA,CAAgB,IAAI,WAAW,CAAA;AAAA,OAC1B,MAAA;AACL,QAAA,YAAA,CAAa,IAAI,WAAW,CAAA;AAAA;AAC9B;AAEF,IAAA,KAAA,MAAW,eAAe,eAAiB,EAAA;AACzC,MAAA,IAAA,CAAK,MAAO,CAAA,IAAA,CAAK,CAA2B,wBAAA,EAAA,WAAW,CAAG,CAAA,CAAA,CAAA;AAAA;AAE5D,IAAO,OAAA,QAAA;AAAA;AAEX;AAEa,MAAA,0BAAA,GAA6B,CACxC,UACA,EAAA,aAAA,EACA,cACA,MACA,EAAA,eAAA,GAAwC,QACxC,IAC+B,KAAA;AAC/B,EAAA,MAAM,mBAAmB,UACtB,CAAA,cAAA,CAAe,kCAAkC,CAAA,CACjD,IAAI,CAAwB,oBAAA,KAAA;AAC3B,IAAM,MAAA,IAAA,GAAO,oBAAqB,CAAA,SAAA,CAAU,MAAM,CAAA;AAClD,IAAA,QAAQ,IAAM;AAAA,MACZ,KAAK,SAAA;AACH,QAAO,OAAAA,2CAAA,CAAsB,UAAW,CAAA,aAAA,EAAe,IAAI,CAAA;AAAA,MAC7D,KAAK,mBAAA;AACH,QAAA,OAAO,IAAIC,wDAAgC,EAAA;AAAA,MAC7C,KAAK,QAAA;AACH,QAAA,OAAOC,yCAAqB,CAAA,UAAA;AAAA,UAC1B,oBAAA;AAAA,UACA;AAAA,SACF;AAAA,MACF,KAAK,KAAA;AACH,QAAA,OAAOC,mCAAkB,CAAA,UAAA;AAAA,UACvB,oBAAA;AAAA,UACA;AAAA,SACF;AAAA,MACF;AACE,QAAA,MAAM,IAAI,KAAA;AAAA,UACR,kDAAkD,IAAI,CAAA,CAAA;AAAA,SACxD;AAAA;AACJ,GACD,CAAA;AAEH,EAAO,OAAA,IAAI,wBAAyB,CAAA,gBAAA,EAAkB,MAAM,CAAA;AAC9D;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../../src/cluster-locator/index.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CatalogApi } from '@backstage/catalog-client';\nimport { Config } from '@backstage/config';\nimport { Duration } from 'luxon';\nimport { ConfigClusterLocator } from './ConfigClusterLocator';\nimport { GkeClusterLocator } from './GkeClusterLocator';\nimport { CatalogClusterLocator } from './CatalogClusterLocator';\nimport { LocalKubectlProxyClusterLocator } from './LocalKubectlProxyLocator';\nimport {\n AuthService,\n BackstageCredentials,\n LoggerService,\n} from '@backstage/backend-plugin-api';\nimport {\n AuthenticationStrategy,\n ClusterDetails,\n KubernetesClustersSupplier,\n} from '@backstage/plugin-kubernetes-node';\n\nclass CombinedClustersSupplier implements KubernetesClustersSupplier {\n constructor(\n readonly clusterSuppliers: KubernetesClustersSupplier[],\n readonly logger: LoggerService,\n ) {}\n\n async getClusters(options: {\n credentials: BackstageCredentials;\n }): Promise<ClusterDetails[]> {\n const clusters = await Promise.all(\n this.clusterSuppliers.map(supplier => supplier.getClusters(options)),\n )\n .then(res => {\n return res.flat();\n })\n .catch(e => {\n throw e;\n });\n return this.warnDuplicates(clusters);\n }\n\n private warnDuplicates(clusters: ClusterDetails[]): ClusterDetails[] {\n const clusterNames = new Set<string>();\n const duplicatedNames = new Set<string>();\n for (const clusterName of clusters.map(c => c.name)) {\n if (clusterNames.has(clusterName)) {\n duplicatedNames.add(clusterName);\n } else {\n clusterNames.add(clusterName);\n }\n }\n for (const clusterName of duplicatedNames) {\n this.logger.warn(`Duplicate cluster name '${clusterName}'`);\n }\n return clusters;\n }\n}\n\nexport const getCombinedClusterSupplier = (\n rootConfig: Config,\n catalogClient: CatalogApi,\n authStrategy: AuthenticationStrategy,\n logger: LoggerService,\n refreshInterval: Duration | undefined = undefined,\n auth: AuthService,\n): KubernetesClustersSupplier => {\n const clusterSuppliers = rootConfig\n .getConfigArray('kubernetes.clusterLocatorMethods')\n .map(clusterLocatorMethod => {\n const type = clusterLocatorMethod.getString('type');\n switch (type) {\n case 'catalog':\n return CatalogClusterLocator.fromConfig(catalogClient, auth);\n case 'localKubectlProxy':\n return new LocalKubectlProxyClusterLocator();\n case 'config':\n return ConfigClusterLocator.fromConfig(\n clusterLocatorMethod,\n authStrategy,\n );\n case 'gke':\n return GkeClusterLocator.fromConfig(\n clusterLocatorMethod,\n refreshInterval,\n );\n default:\n throw new Error(\n `Unsupported kubernetes.clusterLocatorMethods: \"${type}\"`,\n );\n }\n });\n\n return new CombinedClustersSupplier(clusterSuppliers, logger);\n};\n"],"names":["CatalogClusterLocator","LocalKubectlProxyClusterLocator","ConfigClusterLocator","GkeClusterLocator"],"mappings":";;;;;;;AAkCA,MAAM,wBAA+D,CAAA;AAAA,EACnE,WAAA,CACW,kBACA,MACT,EAAA;AAFS,IAAA,IAAA,CAAA,gBAAA,GAAA,gBAAA;AACA,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA;AACR,EAEH,MAAM,YAAY,OAEY,EAAA;AAC5B,IAAM,MAAA,QAAA,GAAW,MAAM,OAAQ,CAAA,GAAA;AAAA,MAC7B,KAAK,gBAAiB,CAAA,GAAA,CAAI,cAAY,QAAS,CAAA,WAAA,CAAY,OAAO,CAAC;AAAA,KACrE,CACG,KAAK,CAAO,GAAA,KAAA;AACX,MAAA,OAAO,IAAI,IAAK,EAAA;AAAA,KACjB,CACA,CAAA,KAAA,CAAM,CAAK,CAAA,KAAA;AACV,MAAM,MAAA,CAAA;AAAA,KACP,CAAA;AACH,IAAO,OAAA,IAAA,CAAK,eAAe,QAAQ,CAAA;AAAA;AACrC,EAEQ,eAAe,QAA8C,EAAA;AACnE,IAAM,MAAA,YAAA,uBAAmB,GAAY,EAAA;AACrC,IAAM,MAAA,eAAA,uBAAsB,GAAY,EAAA;AACxC,IAAA,KAAA,MAAW,eAAe,QAAS,CAAA,GAAA,CAAI,CAAK,CAAA,KAAA,CAAA,CAAE,IAAI,CAAG,EAAA;AACnD,MAAI,IAAA,YAAA,CAAa,GAAI,CAAA,WAAW,CAAG,EAAA;AACjC,QAAA,eAAA,CAAgB,IAAI,WAAW,CAAA;AAAA,OAC1B,MAAA;AACL,QAAA,YAAA,CAAa,IAAI,WAAW,CAAA;AAAA;AAC9B;AAEF,IAAA,KAAA,MAAW,eAAe,eAAiB,EAAA;AACzC,MAAA,IAAA,CAAK,MAAO,CAAA,IAAA,CAAK,CAA2B,wBAAA,EAAA,WAAW,CAAG,CAAA,CAAA,CAAA;AAAA;AAE5D,IAAO,OAAA,QAAA;AAAA;AAEX;AAEa,MAAA,0BAAA,GAA6B,CACxC,UACA,EAAA,aAAA,EACA,cACA,MACA,EAAA,eAAA,GAAwC,QACxC,IAC+B,KAAA;AAC/B,EAAA,MAAM,mBAAmB,UACtB,CAAA,cAAA,CAAe,kCAAkC,CAAA,CACjD,IAAI,CAAwB,oBAAA,KAAA;AAC3B,IAAM,MAAA,IAAA,GAAO,oBAAqB,CAAA,SAAA,CAAU,MAAM,CAAA;AAClD,IAAA,QAAQ,IAAM;AAAA,MACZ,KAAK,SAAA;AACH,QAAO,OAAAA,2CAAA,CAAsB,UAAW,CAAA,aAAA,EAAe,IAAI,CAAA;AAAA,MAC7D,KAAK,mBAAA;AACH,QAAA,OAAO,IAAIC,wDAAgC,EAAA;AAAA,MAC7C,KAAK,QAAA;AACH,QAAA,OAAOC,yCAAqB,CAAA,UAAA;AAAA,UAC1B,oBAAA;AAAA,UACA;AAAA,SACF;AAAA,MACF,KAAK,KAAA;AACH,QAAA,OAAOC,mCAAkB,CAAA,UAAA;AAAA,UACvB,oBAAA;AAAA,UACA;AAAA,SACF;AAAA,MACF;AACE,QAAA,MAAM,IAAI,KAAA;AAAA,UACR,kDAAkD,IAAI,CAAA,CAAA;AAAA,SACxD;AAAA;AACJ,GACD,CAAA;AAEH,EAAO,OAAA,IAAI,wBAAyB,CAAA,gBAAA,EAAkB,MAAM,CAAA;AAC9D;;;;"}
package/dist/index.cjs.js CHANGED
@@ -12,10 +12,8 @@ var GoogleServiceAccountStrategy = require('./auth/GoogleServiceAccountStrategy.
12
12
  var DispatchStrategy = require('./auth/DispatchStrategy.cjs.js');
13
13
  var ServiceAccountStrategy = require('./auth/ServiceAccountStrategy.cjs.js');
14
14
  var OidcStrategy = require('./auth/OidcStrategy.cjs.js');
15
- var KubernetesBuilder = require('./service/KubernetesBuilder.cjs.js');
16
15
  var KubernetesFanOutHandler = require('./service/KubernetesFanOutHandler.cjs.js');
17
16
  var KubernetesProxy = require('./service/KubernetesProxy.cjs.js');
18
- var router = require('./service/router.cjs.js');
19
17
 
20
18
 
21
19
 
@@ -29,10 +27,8 @@ exports.GoogleServiceAccountStrategy = GoogleServiceAccountStrategy.GoogleServic
29
27
  exports.DispatchStrategy = DispatchStrategy.DispatchStrategy;
30
28
  exports.ServiceAccountStrategy = ServiceAccountStrategy.ServiceAccountStrategy;
31
29
  exports.OidcStrategy = OidcStrategy.OidcStrategy;
32
- exports.KubernetesBuilder = KubernetesBuilder.KubernetesBuilder;
33
30
  exports.DEFAULT_OBJECTS = KubernetesFanOutHandler.DEFAULT_OBJECTS;
34
31
  exports.HEADER_KUBERNETES_AUTH = KubernetesProxy.HEADER_KUBERNETES_AUTH;
35
32
  exports.HEADER_KUBERNETES_CLUSTER = KubernetesProxy.HEADER_KUBERNETES_CLUSTER;
36
33
  exports.KubernetesProxy = KubernetesProxy.KubernetesProxy;
37
- exports.createRouter = router.createRouter;
38
34
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,16 +1,11 @@
1
1
  import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
2
- import { LoggerService, PermissionsService, DiscoveryService, HttpAuthService, AuthService, BackstageCredentials, RootConfigService } from '@backstage/backend-plugin-api';
2
+ import { LoggerService, PermissionsService, DiscoveryService, HttpAuthService } from '@backstage/backend-plugin-api';
3
3
  import * as k8sTypes from '@backstage/plugin-kubernetes-node';
4
- import { AuthenticationStrategy as AuthenticationStrategy$1, ClusterDetails as ClusterDetails$1, KubernetesCredential as KubernetesCredential$1, AuthMetadata as AuthMetadata$1, KubernetesClustersSupplier as KubernetesClustersSupplier$1, CustomResource as CustomResource$1, KubernetesFetcher as KubernetesFetcher$1, KubernetesObjectsProvider as KubernetesObjectsProvider$1, KubernetesServiceLocator as KubernetesServiceLocator$1, ObjectToFetch as ObjectToFetch$1 } from '@backstage/plugin-kubernetes-node';
4
+ import { AuthenticationStrategy, ClusterDetails, KubernetesCredential, AuthMetadata, ObjectToFetch, KubernetesClustersSupplier } from '@backstage/plugin-kubernetes-node';
5
5
  import { KubernetesRequestAuth, KubernetesRequestBody } from '@backstage/plugin-kubernetes-common';
6
6
  import { Config } from '@backstage/config';
7
7
  import { TokenCredential } from '@azure/identity';
8
- import { CatalogApi } from '@backstage/catalog-client';
9
- import { PermissionEvaluator } from '@backstage/plugin-permission-common';
10
- import express from 'express';
11
- import { Duration } from 'luxon';
12
8
  import { RequestHandler } from 'http-proxy-middleware';
13
- import { Logger } from 'winston';
14
9
 
15
10
  /**
16
11
  * This is the backend plugin that provides the Kubernetes integration.
@@ -22,20 +17,20 @@ declare const kubernetesPlugin: _backstage_backend_plugin_api.BackendFeature;
22
17
  *
23
18
  * @public
24
19
  */
25
- declare class AksStrategy implements AuthenticationStrategy$1 {
26
- getCredential(_: ClusterDetails$1, requestAuth: KubernetesRequestAuth): Promise<KubernetesCredential$1>;
20
+ declare class AksStrategy implements AuthenticationStrategy {
21
+ getCredential(_: ClusterDetails, requestAuth: KubernetesRequestAuth): Promise<KubernetesCredential>;
27
22
  validateCluster(): Error[];
28
- presentAuthMetadata(_authMetadata: AuthMetadata$1): AuthMetadata$1;
23
+ presentAuthMetadata(_authMetadata: AuthMetadata): AuthMetadata;
29
24
  }
30
25
 
31
26
  /**
32
27
  *
33
28
  * @public
34
29
  */
35
- declare class AnonymousStrategy implements AuthenticationStrategy$1 {
36
- getCredential(): Promise<KubernetesCredential$1>;
30
+ declare class AnonymousStrategy implements AuthenticationStrategy {
31
+ getCredential(): Promise<KubernetesCredential>;
37
32
  validateCluster(): Error[];
38
- presentAuthMetadata(_authMetadata: AuthMetadata$1): AuthMetadata$1;
33
+ presentAuthMetadata(_authMetadata: AuthMetadata): AuthMetadata;
39
34
  }
40
35
 
41
36
  /**
@@ -51,53 +46,53 @@ type SigningCreds = {
51
46
  *
52
47
  * @public
53
48
  */
54
- declare class AwsIamStrategy implements AuthenticationStrategy$1 {
49
+ declare class AwsIamStrategy implements AuthenticationStrategy {
55
50
  private readonly credsManager;
56
51
  constructor(opts: {
57
52
  config: Config;
58
53
  });
59
- getCredential(clusterDetails: ClusterDetails$1): Promise<KubernetesCredential$1>;
54
+ getCredential(clusterDetails: ClusterDetails): Promise<KubernetesCredential>;
60
55
  validateCluster(): Error[];
61
56
  private getBearerToken;
62
- presentAuthMetadata(_authMetadata: AuthMetadata$1): AuthMetadata$1;
57
+ presentAuthMetadata(_authMetadata: AuthMetadata): AuthMetadata;
63
58
  }
64
59
 
65
60
  /**
66
61
  *
67
62
  * @public
68
63
  */
69
- declare class AzureIdentityStrategy implements AuthenticationStrategy$1 {
64
+ declare class AzureIdentityStrategy implements AuthenticationStrategy {
70
65
  private readonly logger;
71
66
  private readonly tokenCredential;
72
67
  private accessToken;
73
68
  private newTokenPromise;
74
69
  constructor(logger: LoggerService, tokenCredential?: TokenCredential);
75
- getCredential(): Promise<KubernetesCredential$1>;
70
+ getCredential(): Promise<KubernetesCredential>;
76
71
  validateCluster(): Error[];
77
72
  private fetchNewToken;
78
73
  private tokenRequiresRefresh;
79
74
  private tokenExpired;
80
- presentAuthMetadata(_authMetadata: AuthMetadata$1): AuthMetadata$1;
75
+ presentAuthMetadata(_authMetadata: AuthMetadata): AuthMetadata;
81
76
  }
82
77
 
83
78
  /**
84
79
  *
85
80
  * @public
86
81
  */
87
- declare class GoogleStrategy implements AuthenticationStrategy$1 {
88
- getCredential(_: ClusterDetails$1, requestAuth: KubernetesRequestAuth): Promise<KubernetesCredential$1>;
82
+ declare class GoogleStrategy implements AuthenticationStrategy {
83
+ getCredential(_: ClusterDetails, requestAuth: KubernetesRequestAuth): Promise<KubernetesCredential>;
89
84
  validateCluster(): Error[];
90
- presentAuthMetadata(_authMetadata: AuthMetadata$1): AuthMetadata$1;
85
+ presentAuthMetadata(_authMetadata: AuthMetadata): AuthMetadata;
91
86
  }
92
87
 
93
88
  /**
94
89
  *
95
90
  * @public
96
91
  */
97
- declare class GoogleServiceAccountStrategy implements AuthenticationStrategy$1 {
98
- getCredential(): Promise<KubernetesCredential$1>;
92
+ declare class GoogleServiceAccountStrategy implements AuthenticationStrategy {
93
+ getCredential(): Promise<KubernetesCredential>;
99
94
  validateCluster(): Error[];
100
- presentAuthMetadata(_authMetadata: AuthMetadata$1): AuthMetadata$1;
95
+ presentAuthMetadata(_authMetadata: AuthMetadata): AuthMetadata;
101
96
  }
102
97
 
103
98
  /**
@@ -106,51 +101,42 @@ declare class GoogleServiceAccountStrategy implements AuthenticationStrategy$1 {
106
101
  */
107
102
  type DispatchStrategyOptions = {
108
103
  authStrategyMap: {
109
- [key: string]: AuthenticationStrategy$1;
104
+ [key: string]: AuthenticationStrategy;
110
105
  };
111
106
  };
112
107
  /**
113
108
  * used to direct a KubernetesAuthProvider to its corresponding AuthenticationStrategy
114
109
  * @public
115
110
  */
116
- declare class DispatchStrategy implements AuthenticationStrategy$1 {
111
+ declare class DispatchStrategy implements AuthenticationStrategy {
117
112
  private readonly strategyMap;
118
113
  constructor(options: DispatchStrategyOptions);
119
- getCredential(clusterDetails: ClusterDetails$1, auth: KubernetesRequestAuth): Promise<KubernetesCredential$1>;
120
- validateCluster(authMetadata: AuthMetadata$1): Error[];
121
- presentAuthMetadata(_authMetadata: AuthMetadata$1): AuthMetadata$1;
114
+ getCredential(clusterDetails: ClusterDetails, auth: KubernetesRequestAuth): Promise<KubernetesCredential>;
115
+ validateCluster(authMetadata: AuthMetadata): Error[];
116
+ presentAuthMetadata(_authMetadata: AuthMetadata): AuthMetadata;
122
117
  }
123
118
 
124
119
  /**
125
120
  *
126
121
  * @public
127
122
  */
128
- declare class ServiceAccountStrategy implements AuthenticationStrategy$1 {
123
+ declare class ServiceAccountStrategy implements AuthenticationStrategy {
129
124
  private injectedKubernetesClient?;
130
- getCredential(clusterDetails: ClusterDetails$1): Promise<KubernetesCredential$1>;
125
+ getCredential(clusterDetails: ClusterDetails): Promise<KubernetesCredential>;
131
126
  validateCluster(): Error[];
132
- presentAuthMetadata(_authMetadata: AuthMetadata$1): AuthMetadata$1;
127
+ presentAuthMetadata(_authMetadata: AuthMetadata): AuthMetadata;
133
128
  }
134
129
 
135
130
  /**
136
131
  *
137
132
  * @public
138
133
  */
139
- declare class OidcStrategy implements AuthenticationStrategy$1 {
140
- getCredential(clusterDetails: ClusterDetails$1, authConfig: KubernetesRequestAuth): Promise<KubernetesCredential$1>;
141
- validateCluster(authMetadata: AuthMetadata$1): Error[];
142
- presentAuthMetadata(_authMetadata: AuthMetadata$1): AuthMetadata$1;
134
+ declare class OidcStrategy implements AuthenticationStrategy {
135
+ getCredential(clusterDetails: ClusterDetails, authConfig: KubernetesRequestAuth): Promise<KubernetesCredential>;
136
+ validateCluster(authMetadata: AuthMetadata): Error[];
137
+ presentAuthMetadata(_authMetadata: AuthMetadata): AuthMetadata;
143
138
  }
144
139
 
145
- /**
146
- * @public @deprecated Import it from \@backstage/plugin-kubernetes-node instead
147
- */
148
- type AuthenticationStrategy = k8sTypes.AuthenticationStrategy;
149
- /**
150
- * @public @deprecated Import it from \@backstage/plugin-kubernetes-node instead
151
- */
152
- type KubernetesCredential = k8sTypes.KubernetesCredential;
153
-
154
140
  /**
155
141
  *
156
142
  * @public
@@ -173,61 +159,12 @@ interface KubernetesObjectsProviderOptions {
173
159
  * @public
174
160
  */
175
161
  type ObjectsByEntityRequest = KubernetesRequestBody;
162
+
176
163
  /**
177
- * @public @deprecated Import it from \@backstage/plugin-kubernetes-node instead
178
- */
179
- type KubernetesObjectsProvider = k8sTypes.KubernetesObjectsProvider;
180
- /**
181
- * @public @deprecated Import it from \@backstage/plugin-kubernetes-node instead
182
- */
183
- type CustomResourcesByEntity = k8sTypes.CustomResourcesByEntity;
184
- /**
185
- * @public
186
- * @deprecated Import it from \@backstage/plugin-kubernetes-node instead
187
- */
188
- type AuthMetadata = k8sTypes.AuthMetadata;
189
- /**
190
- * @public
191
- * @deprecated Import it from \@backstage/plugin-kubernetes-node instead
192
- */
193
- type ClusterDetails = k8sTypes.ClusterDetails;
194
- /**
164
+ *
195
165
  * @public
196
- * @deprecated Import it from \@backstage/plugin-kubernetes-node instead
197
- */
198
- type KubernetesClustersSupplier = k8sTypes.KubernetesClustersSupplier;
199
- /**
200
- * @public @deprecated Import it from \@backstage/plugin-kubernetes-node instead
201
- */
202
- type KubernetesObjectTypes = k8sTypes.KubernetesObjectTypes;
203
- /**
204
- * @public @deprecated Import it from \@backstage/plugin-kubernetes-node instead
205
- */
206
- type ObjectToFetch = k8sTypes.ObjectToFetch;
207
- /**
208
- * @public @deprecated Import it from \@backstage/plugin-kubernetes-node instead
209
- */
210
- type CustomResource = k8sTypes.CustomResource;
211
- /**
212
- * @public @deprecated Import it from \@backstage/plugin-kubernetes-node instead
213
- */
214
- type ObjectFetchParams = k8sTypes.ObjectFetchParams;
215
- /**
216
- * @public @deprecated Import it from \@backstage/plugin-kubernetes-node instead
217
- */
218
- type FetchResponseWrapper = k8sTypes.FetchResponseWrapper;
219
- /**
220
- * @public @deprecated Import it from \@backstage/plugin-kubernetes-node instead
221
- */
222
- type KubernetesFetcher = k8sTypes.KubernetesFetcher;
223
- /**
224
- * @public @deprecated Import it from \@backstage/plugin-kubernetes-node instead
225
- */
226
- type ServiceLocatorRequestContext = k8sTypes.ServiceLocatorRequestContext;
227
- /**
228
- * @public @deprecated Import it from \@backstage/plugin-kubernetes-node instead
229
166
  */
230
- type KubernetesServiceLocator = k8sTypes.KubernetesServiceLocator;
167
+ declare const DEFAULT_OBJECTS: ObjectToFetch[];
231
168
 
232
169
  /**
233
170
  * The header that is used to specify the cluster name.
@@ -259,7 +196,7 @@ type KubernetesProxyOptions = {
259
196
  clusterSupplier: KubernetesClustersSupplier;
260
197
  authStrategy: AuthenticationStrategy;
261
198
  discovery: DiscoveryService;
262
- httpAuth?: HttpAuthService;
199
+ httpAuth: HttpAuthService;
263
200
  };
264
201
  /**
265
202
  * A proxy that routes requests to the Kubernetes API.
@@ -281,124 +218,4 @@ declare class KubernetesProxy {
281
218
  private static combineHeaders;
282
219
  }
283
220
 
284
- /**
285
- * @deprecated Please migrate to the new backend system as this will be removed in the future.
286
- * @public
287
- */
288
- interface KubernetesEnvironment {
289
- logger: LoggerService;
290
- config: Config;
291
- catalogApi: CatalogApi;
292
- discovery: DiscoveryService;
293
- permissions: PermissionEvaluator;
294
- auth?: AuthService;
295
- httpAuth?: HttpAuthService;
296
- }
297
- /**
298
- * The return type of the `KubernetesBuilder.build` method
299
- * @deprecated Please migrate to the new backend system as this will be removed in the future.
300
- * @public
301
- */
302
- type KubernetesBuilderReturn = Promise<{
303
- router: express.Router;
304
- clusterSupplier: KubernetesClustersSupplier$1;
305
- customResources: CustomResource$1[];
306
- fetcher: KubernetesFetcher$1;
307
- proxy: KubernetesProxy;
308
- objectsProvider: KubernetesObjectsProvider$1;
309
- serviceLocator: KubernetesServiceLocator$1;
310
- authStrategyMap: {
311
- [key: string]: AuthenticationStrategy$1;
312
- };
313
- }>;
314
- /**
315
- * @deprecated Please migrate to the new backend system as this will be removed in the future.
316
- * @public
317
- * */
318
- declare class KubernetesBuilder {
319
- protected readonly env: KubernetesEnvironment;
320
- private clusterSupplier?;
321
- private defaultClusterRefreshInterval;
322
- private objectsProvider?;
323
- private fetcher?;
324
- private serviceLocator?;
325
- private proxy?;
326
- private authStrategyMap?;
327
- static createBuilder(env: KubernetesEnvironment): KubernetesBuilder;
328
- constructor(env: KubernetesEnvironment);
329
- build(): KubernetesBuilderReturn;
330
- setClusterSupplier(clusterSupplier?: KubernetesClustersSupplier$1): this;
331
- setDefaultClusterRefreshInterval(refreshInterval: Duration): this;
332
- setObjectsProvider(objectsProvider?: KubernetesObjectsProvider$1): this;
333
- setFetcher(fetcher?: KubernetesFetcher$1): this;
334
- setServiceLocator(serviceLocator?: KubernetesServiceLocator$1): this;
335
- setProxy(proxy?: KubernetesProxy): this;
336
- setAuthStrategyMap(authStrategyMap: {
337
- [key: string]: AuthenticationStrategy$1;
338
- }): void;
339
- addAuthStrategy(key: string, strategy: AuthenticationStrategy$1): this;
340
- protected buildCustomResources(): CustomResource$1[];
341
- protected buildClusterSupplier(refreshInterval: Duration): KubernetesClustersSupplier$1;
342
- protected buildObjectsProvider(options: KubernetesObjectsProviderOptions): KubernetesObjectsProvider$1;
343
- protected buildFetcher(): KubernetesFetcher$1;
344
- protected buildServiceLocator(method: ServiceLocatorMethod, clusterSupplier: KubernetesClustersSupplier$1): KubernetesServiceLocator$1;
345
- protected buildMultiTenantServiceLocator(clusterSupplier: KubernetesClustersSupplier$1): KubernetesServiceLocator$1;
346
- protected buildSingleTenantServiceLocator(clusterSupplier: KubernetesClustersSupplier$1): KubernetesServiceLocator$1;
347
- protected buildCatalogRelationServiceLocator(clusterSupplier: KubernetesClustersSupplier$1): KubernetesServiceLocator$1;
348
- protected buildHttpServiceLocator(_clusterSupplier: KubernetesClustersSupplier$1): KubernetesServiceLocator$1;
349
- protected buildProxy(logger: LoggerService, clusterSupplier: KubernetesClustersSupplier$1, discovery: DiscoveryService, httpAuth: HttpAuthService): KubernetesProxy;
350
- protected buildRouter(objectsProvider: KubernetesObjectsProvider$1, clusterSupplier: KubernetesClustersSupplier$1, catalogApi: CatalogApi, proxy: KubernetesProxy, permissionApi: PermissionEvaluator, authService: AuthService, httpAuth: HttpAuthService): express.Router;
351
- protected buildAuthStrategyMap(): {
352
- [key: string]: AuthenticationStrategy$1;
353
- };
354
- protected fetchClusterDetails(clusterSupplier: KubernetesClustersSupplier$1, options: {
355
- credentials: BackstageCredentials;
356
- }): Promise<k8sTypes.ClusterDetails[]>;
357
- protected getServiceLocatorMethod(): ServiceLocatorMethod;
358
- protected getFetcher(): KubernetesFetcher$1;
359
- protected getClusterSupplier(): KubernetesClustersSupplier$1;
360
- protected getServiceLocator(): KubernetesServiceLocator$1;
361
- protected getObjectsProvider(options: KubernetesObjectsProviderOptions): KubernetesObjectsProvider$1;
362
- protected getObjectTypesToFetch(): k8sTypes.ObjectToFetch[] | undefined;
363
- protected getProxy(logger: LoggerService, clusterSupplier: KubernetesClustersSupplier$1, discovery: DiscoveryService, httpAuth: HttpAuthService): KubernetesProxy;
364
- protected getAuthStrategyMap(): {
365
- [key: string]: AuthenticationStrategy$1;
366
- };
367
- }
368
-
369
- /**
370
- *
371
- * @public
372
- */
373
- declare const DEFAULT_OBJECTS: ObjectToFetch$1[];
374
-
375
- /**
376
- * @deprecated Please migrate to the new backend system as this will be removed in the future.
377
- * @public
378
- */
379
- interface RouterOptions {
380
- logger: Logger;
381
- config: RootConfigService;
382
- catalogApi: CatalogApi;
383
- clusterSupplier?: KubernetesClustersSupplier;
384
- discovery: DiscoveryService;
385
- permissions: PermissionEvaluator;
386
- }
387
- /**
388
- * creates and configure a new router for handling the kubernetes backend APIs
389
- * @param options - specifies the options required by this plugin
390
- * @returns a new router
391
- * @deprecated Please migrate to the new backend system as this will be removed in the future.
392
- * ```
393
- * import { KubernetesBuilder } from '@backstage/plugin-kubernetes-backend';
394
- * const { router } = await KubernetesBuilder.createBuilder({
395
- * logger,
396
- * config,
397
- * }).build();
398
- * ```
399
- *
400
- * @public
401
- */
402
- declare function createRouter(options: RouterOptions): Promise<express.Router>;
403
-
404
- export { AksStrategy, AnonymousStrategy, type AuthMetadata, type AuthenticationStrategy, AwsIamStrategy, AzureIdentityStrategy, type ClusterDetails, type CustomResource, type CustomResourcesByEntity, DEFAULT_OBJECTS, DispatchStrategy, type DispatchStrategyOptions, type FetchResponseWrapper, GoogleServiceAccountStrategy, GoogleStrategy, HEADER_KUBERNETES_AUTH, HEADER_KUBERNETES_CLUSTER, KubernetesBuilder, type KubernetesBuilderReturn, type KubernetesClustersSupplier, type KubernetesCredential, type KubernetesEnvironment, type KubernetesFetcher, type KubernetesObjectTypes, type KubernetesObjectsProvider, type KubernetesObjectsProviderOptions, KubernetesProxy, type KubernetesProxyCreateRequestHandlerOptions, type KubernetesProxyOptions, type KubernetesServiceLocator, type ObjectFetchParams, type ObjectToFetch, type ObjectsByEntityRequest, OidcStrategy, type RouterOptions, ServiceAccountStrategy, type ServiceLocatorMethod, type ServiceLocatorRequestContext, type SigningCreds, createRouter, kubernetesPlugin as default };
221
+ export { AksStrategy, AnonymousStrategy, AwsIamStrategy, AzureIdentityStrategy, DEFAULT_OBJECTS, DispatchStrategy, type DispatchStrategyOptions, GoogleServiceAccountStrategy, GoogleStrategy, HEADER_KUBERNETES_AUTH, HEADER_KUBERNETES_CLUSTER, type KubernetesObjectsProviderOptions, KubernetesProxy, type KubernetesProxyCreateRequestHandlerOptions, type KubernetesProxyOptions, type ObjectsByEntityRequest, OidcStrategy, ServiceAccountStrategy, type ServiceLocatorMethod, type SigningCreds, kubernetesPlugin as default };