@backstage/plugin-kubernetes-node 0.3.3-next.0 → 0.3.3

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,13 @@
1
1
  # @backstage/plugin-kubernetes-node
2
2
 
3
+ ## 0.3.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 79e342e: Added support for providing a factory to the extension points
8
+ - Updated dependencies
9
+ - @backstage/backend-plugin-api@1.4.2
10
+
3
11
  ## 0.3.3-next.0
4
12
 
5
13
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"PinnipedHelper.cjs.js","sources":["../../src/auth/PinnipedHelper.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { LoggerService } from '@backstage/backend-plugin-api';\nimport * as https from 'https';\nimport fetch, { RequestInit } from 'node-fetch';\nimport { ClusterDetails } from '../types/types';\n\n/**\n *\n * @public\n */\nexport type PinnipedClientCerts = {\n key: string;\n cert: string;\n expirationTimestamp: string;\n};\n\n/**\n *\n * @public\n */\nexport type PinnipedParameters = {\n clusterScopedIdToken: string;\n authenticator: {\n apiGroup: string;\n kind: string;\n name: string;\n };\n tokenCredentialRequest?: {\n apiGroup?: string;\n };\n};\n\n/**\n *\n * @public\n */\nexport class PinnipedHelper {\n constructor(private readonly logger: LoggerService) {}\n\n public async tokenCredentialRequest(\n clusterDetails: ClusterDetails,\n pinnipedParams: PinnipedParameters,\n ): Promise<PinnipedClientCerts> {\n this.logger.debug('Pinniped: Requesting client Certs to Concierge');\n return await this.exchangeClusterTokentoClientCerts(\n clusterDetails,\n pinnipedParams,\n );\n }\n\n private async exchangeClusterTokentoClientCerts(\n clusterDetails: ClusterDetails,\n pinnipedParams: PinnipedParameters,\n ): Promise<PinnipedClientCerts> {\n const url: URL = new URL(clusterDetails.url);\n const apiGroup =\n pinnipedParams.tokenCredentialRequest?.apiGroup ??\n 'login.concierge.pinniped.dev/v1alpha1';\n\n url.pathname = `/apis/${apiGroup}/tokencredentialrequests`;\n\n const requestInit = await this.buildRequestForPinniped(\n url,\n clusterDetails,\n pinnipedParams,\n );\n\n this.logger.info(\n 'Fetching client certs for mTLS authentication on Pinniped',\n );\n let response;\n try {\n response = await fetch(url, requestInit);\n } catch (error) {\n this.logger.error('Pinniped request error', error);\n throw error;\n }\n\n const data: any = await response.json();\n\n if (data.status.credential) {\n const result = {\n key: data.status.credential.clientKeyData,\n cert: data.status.credential.clientCertificateData,\n expirationTimestamp: data.status.credential.expirationTimestamp,\n };\n return Promise.resolve(result);\n }\n\n this.logger.error('Unable to fetch client certs,', data.status);\n return Promise.reject(data.status.message);\n }\n\n private async buildRequestForPinniped(\n url: URL,\n clusterDetails: ClusterDetails,\n pinnipedParams: PinnipedParameters,\n ): Promise<fetch.RequestInit> {\n const { bufferFromFileOrString } = await import('@kubernetes/client-node');\n\n const body = {\n apiVersion:\n pinnipedParams.tokenCredentialRequest?.apiGroup ??\n 'login.concierge.pinniped.dev/v1alpha1',\n kind: 'TokenCredentialRequest',\n spec: {\n authenticator: pinnipedParams.authenticator,\n token: pinnipedParams.clusterScopedIdToken,\n },\n };\n const requestInit: RequestInit = {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body),\n };\n\n if (url.protocol === 'https:') {\n requestInit.agent = new https.Agent({\n ca:\n bufferFromFileOrString(\n clusterDetails.caFile,\n clusterDetails.caData,\n ) ?? undefined,\n rejectUnauthorized: !clusterDetails.skipTLSVerify,\n });\n }\n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A,KAAA,CAAA;AAAA,QACP,kBAAA,EAAoB,CAAC,cAAe,CAAA;AAAA,OACrC,CAAA;AAAA;AAGH,IAAO,OAAA,WAAA;AAAA;AAEX;;;;"}
1
+ {"version":3,"file":"PinnipedHelper.cjs.js","sources":["../../src/auth/PinnipedHelper.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { LoggerService } from '@backstage/backend-plugin-api';\nimport * as https from 'https';\nimport fetch, { RequestInit } from 'node-fetch';\nimport { ClusterDetails } from '../types/types';\n\n/**\n *\n * @public\n */\nexport type PinnipedClientCerts = {\n key: string;\n cert: string;\n expirationTimestamp: string;\n};\n\n/**\n *\n * @public\n */\nexport type PinnipedParameters = {\n clusterScopedIdToken: string;\n authenticator: {\n apiGroup: string;\n kind: string;\n name: string;\n };\n tokenCredentialRequest?: {\n apiGroup?: string;\n };\n};\n\n/**\n *\n * @public\n */\nexport class PinnipedHelper {\n constructor(private readonly logger: LoggerService) {}\n\n public async tokenCredentialRequest(\n clusterDetails: ClusterDetails,\n pinnipedParams: PinnipedParameters,\n ): Promise<PinnipedClientCerts> {\n this.logger.debug('Pinniped: Requesting client Certs to Concierge');\n return await this.exchangeClusterTokentoClientCerts(\n clusterDetails,\n pinnipedParams,\n );\n }\n\n private async exchangeClusterTokentoClientCerts(\n clusterDetails: ClusterDetails,\n pinnipedParams: PinnipedParameters,\n ): Promise<PinnipedClientCerts> {\n const url: URL = new URL(clusterDetails.url);\n const apiGroup =\n pinnipedParams.tokenCredentialRequest?.apiGroup ??\n 'login.concierge.pinniped.dev/v1alpha1';\n\n url.pathname = `/apis/${apiGroup}/tokencredentialrequests`;\n\n const requestInit = await this.buildRequestForPinniped(\n url,\n clusterDetails,\n pinnipedParams,\n );\n\n this.logger.info(\n 'Fetching client certs for mTLS authentication on Pinniped',\n );\n let response;\n try {\n response = await fetch(url, requestInit);\n } catch (error) {\n this.logger.error('Pinniped request error', error);\n throw error;\n }\n\n const data: any = await response.json();\n\n if (data.status.credential) {\n const result = {\n key: data.status.credential.clientKeyData,\n cert: data.status.credential.clientCertificateData,\n expirationTimestamp: data.status.credential.expirationTimestamp,\n };\n return Promise.resolve(result);\n }\n\n this.logger.error('Unable to fetch client certs,', data.status);\n return Promise.reject(data.status.message);\n }\n\n private async buildRequestForPinniped(\n url: URL,\n clusterDetails: ClusterDetails,\n pinnipedParams: PinnipedParameters,\n ): Promise<fetch.RequestInit> {\n const { bufferFromFileOrString } = await import('@kubernetes/client-node');\n\n const body = {\n apiVersion:\n pinnipedParams.tokenCredentialRequest?.apiGroup ??\n 'login.concierge.pinniped.dev/v1alpha1',\n kind: 'TokenCredentialRequest',\n spec: {\n authenticator: pinnipedParams.authenticator,\n token: pinnipedParams.clusterScopedIdToken,\n },\n };\n const requestInit: RequestInit = {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body),\n };\n\n if (url.protocol === 'https:') {\n requestInit.agent = new https.Agent({\n ca:\n bufferFromFileOrString(\n clusterDetails.caFile,\n clusterDetails.caData,\n ) ?? undefined,\n rejectUnauthorized: !clusterDetails.skipTLSVerify,\n });\n }\n\n return requestInit;\n }\n}\n"],"names":["fetch","https"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDO,MAAM,cAAA,CAAe;AAAA,EAC1B,YAA6B,MAAA,EAAuB;AAAvB,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA,EAAwB;AAAA,EAErD,MAAa,sBAAA,CACX,cAAA,EACA,cAAA,EAC8B;AAC9B,IAAA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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 */\nimport { createExtensionPoint } from '@backstage/backend-plugin-api';\nimport {\n AuthenticationStrategy,\n KubernetesClustersSupplier,\n KubernetesFetcher,\n KubernetesObjectsProvider,\n KubernetesServiceLocator,\n} from '@backstage/plugin-kubernetes-node';\n\n/**\n * The interface for {@link kubernetesObjectsProviderExtensionPoint}.\n *\n * @public\n */\nexport interface KubernetesObjectsProviderExtensionPoint {\n addObjectsProvider(provider: KubernetesObjectsProvider): void;\n}\n\n/**\n * An extension point the exposes the ability to configure a objects provider.\n *\n * @public\n */\nexport const kubernetesObjectsProviderExtensionPoint =\n createExtensionPoint<KubernetesObjectsProviderExtensionPoint>({\n id: 'kubernetes.objects-provider',\n });\n\n/**\n * The interface for {@link kubernetesClusterSupplierExtensionPoint}.\n *\n * @public\n */\nexport interface KubernetesClusterSupplierExtensionPoint {\n addClusterSupplier(clusterSupplier: KubernetesClustersSupplier): void;\n}\n\n/**\n * An extension point the exposes the ability to configure a cluster supplier.\n *\n * @public\n */\nexport const kubernetesClusterSupplierExtensionPoint =\n createExtensionPoint<KubernetesClusterSupplierExtensionPoint>({\n id: 'kubernetes.cluster-supplier',\n });\n\n/**\n * The interface for {@link kubernetesAuthStrategyExtensionPoint}.\n *\n * @public\n */\nexport interface KubernetesAuthStrategyExtensionPoint {\n addAuthStrategy(key: string, strategy: AuthenticationStrategy): void;\n}\n\n/**\n * An extension point the exposes the ability to add an Auth Strategy.\n *\n * @public\n */\nexport const kubernetesAuthStrategyExtensionPoint =\n createExtensionPoint<KubernetesAuthStrategyExtensionPoint>({\n id: 'kubernetes.auth-strategy',\n });\n\n/**\n * The interface for {@link kubernetesFetcherExtensionPoint}.\n *\n * @public\n */\nexport interface KubernetesFetcherExtensionPoint {\n addFetcher(fetcher: KubernetesFetcher): void;\n}\n\n/**\n * An extension point the exposes the ability to configure a kubernetes fetcher.\n *\n * @public\n */\nexport const kubernetesFetcherExtensionPoint =\n createExtensionPoint<KubernetesFetcherExtensionPoint>({\n id: 'kubernetes.fetcher',\n });\n\n/**\n * The interface for {@link kubernetesServiceLocatorExtensionPoint}.\n *\n * @public\n */\nexport interface KubernetesServiceLocatorExtensionPoint {\n addServiceLocator(serviceLocator: KubernetesServiceLocator): void;\n}\n\n/**\n * An extension point the exposes the ability to configure a kubernetes service locator.\n *\n * @public\n */\nexport const kubernetesServiceLocatorExtensionPoint =\n createExtensionPoint<KubernetesServiceLocatorExtensionPoint>({\n id: 'kubernetes.service-locator',\n });\n"],"names":["createExtensionPoint"],"mappings":";;;;AAsCO,MAAM,0CACXA,qCAA8D,CAAA;AAAA,EAC5D,EAAI,EAAA;AACN,CAAC;AAgBI,MAAM,0CACXA,qCAA8D,CAAA;AAAA,EAC5D,EAAI,EAAA;AACN,CAAC;AAgBI,MAAM,uCACXA,qCAA2D,CAAA;AAAA,EACzD,EAAI,EAAA;AACN,CAAC;AAgBI,MAAM,kCACXA,qCAAsD,CAAA;AAAA,EACpD,EAAI,EAAA;AACN,CAAC;AAgBI,MAAM,yCACXA,qCAA6D,CAAA;AAAA,EAC3D,EAAI,EAAA;AACN,CAAC;;;;;;;;"}
1
+ {"version":3,"file":"extensions.cjs.js","sources":["../src/extensions.ts"],"sourcesContent":["/*\n * Copyright 2023 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 */\nimport { createExtensionPoint } from '@backstage/backend-plugin-api';\nimport {\n AuthenticationStrategy,\n CustomResource,\n ObjectToFetch,\n KubernetesClustersSupplier,\n KubernetesFetcher,\n KubernetesObjectsProvider,\n KubernetesServiceLocator,\n} from '@backstage/plugin-kubernetes-node';\n\n/**\n * A factory function for creating a KubernetesObjectsProvider.\n *\n * @public\n */\nexport type KubernetesObjectsProviderFactory = (opts: {\n getDefault: () => Promise<KubernetesObjectsProvider>;\n clusterSupplier: KubernetesClustersSupplier;\n serviceLocator: KubernetesServiceLocator;\n customResources: CustomResource[];\n objectTypesToFetch?: ObjectToFetch[];\n authStrategy: AuthenticationStrategy;\n}) => Promise<KubernetesObjectsProvider>;\n\n/**\n * The interface for {@link kubernetesObjectsProviderExtensionPoint}.\n *\n * @public\n */\nexport interface KubernetesObjectsProviderExtensionPoint {\n addObjectsProvider(\n provider: KubernetesObjectsProvider | KubernetesObjectsProviderFactory,\n ): void;\n}\n\n/**\n * An extension point the exposes the ability to configure a objects provider.\n *\n * @public\n */\nexport const kubernetesObjectsProviderExtensionPoint =\n createExtensionPoint<KubernetesObjectsProviderExtensionPoint>({\n id: 'kubernetes.objects-provider',\n });\n\n/**\n * A factory function for creating a KubernetesClustersSupplier.\n *\n * @public\n */\nexport type KubernetesClusterSupplierFactory = (opts: {\n getDefault: () => Promise<KubernetesClustersSupplier>;\n}) => Promise<KubernetesClustersSupplier>;\n\n/**\n * The interface for {@link kubernetesClusterSupplierExtensionPoint}.\n *\n * @public\n */\nexport interface KubernetesClusterSupplierExtensionPoint {\n addClusterSupplier(\n clusterSupplier:\n | KubernetesClustersSupplier\n | KubernetesClusterSupplierFactory,\n ): void;\n}\n\n/**\n * An extension point the exposes the ability to configure a cluster supplier.\n *\n * @public\n */\nexport const kubernetesClusterSupplierExtensionPoint =\n createExtensionPoint<KubernetesClusterSupplierExtensionPoint>({\n id: 'kubernetes.cluster-supplier',\n });\n\n/**\n * The interface for {@link kubernetesAuthStrategyExtensionPoint}.\n *\n * @public\n */\nexport interface KubernetesAuthStrategyExtensionPoint {\n addAuthStrategy(key: string, strategy: AuthenticationStrategy): void;\n}\n\n/**\n * An extension point the exposes the ability to add an Auth Strategy.\n *\n * @public\n */\nexport const kubernetesAuthStrategyExtensionPoint =\n createExtensionPoint<KubernetesAuthStrategyExtensionPoint>({\n id: 'kubernetes.auth-strategy',\n });\n\n/**\n * A factory function for creating a KubernetesFetcher.\n *\n * @public\n */\nexport type KubernetesFetcherFactory = (opts: {\n getDefault: () => Promise<KubernetesFetcher>;\n}) => Promise<KubernetesFetcher>;\n\n/**\n * The interface for {@link kubernetesFetcherExtensionPoint}.\n *\n * @public\n */\nexport interface KubernetesFetcherExtensionPoint {\n addFetcher(fetcher: KubernetesFetcher | KubernetesFetcherFactory): void;\n}\n\n/**\n * An extension point the exposes the ability to configure a kubernetes fetcher.\n *\n * @public\n */\nexport const kubernetesFetcherExtensionPoint =\n createExtensionPoint<KubernetesFetcherExtensionPoint>({\n id: 'kubernetes.fetcher',\n });\n\n/**\n * A factory function for creating a KubernetesServiceLocator.\n *\n * @public\n */\nexport type KubernetesServiceLocatorFactory = (opts: {\n getDefault: () => Promise<KubernetesServiceLocator>;\n clusterSupplier: KubernetesClustersSupplier;\n}) => Promise<KubernetesServiceLocator>;\n\n/**\n * The interface for {@link kubernetesServiceLocatorExtensionPoint}.\n *\n * @public\n */\nexport interface KubernetesServiceLocatorExtensionPoint {\n addServiceLocator(\n serviceLocator: KubernetesServiceLocator | KubernetesServiceLocatorFactory,\n ): void;\n}\n\n/**\n * An extension point the exposes the ability to configure a kubernetes service locator.\n *\n * @public\n */\nexport const kubernetesServiceLocatorExtensionPoint =\n createExtensionPoint<KubernetesServiceLocatorExtensionPoint>({\n id: 'kubernetes.service-locator',\n });\n"],"names":["createExtensionPoint"],"mappings":";;;;AAwDO,MAAM,0CACXA,qCAAA,CAA8D;AAAA,EAC5D,EAAA,EAAI;AACN,CAAC;AA6BI,MAAM,0CACXA,qCAAA,CAA8D;AAAA,EAC5D,EAAA,EAAI;AACN,CAAC;AAgBI,MAAM,uCACXA,qCAAA,CAA2D;AAAA,EACzD,EAAA,EAAI;AACN,CAAC;AAyBI,MAAM,kCACXA,qCAAA,CAAsD;AAAA,EACpD,EAAA,EAAI;AACN,CAAC;AA4BI,MAAM,yCACXA,qCAAA,CAA6D;AAAA,EAC3D,EAAA,EAAI;AACN,CAAC;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,17 +1,30 @@
1
1
  import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
2
2
  import { BackstageCredentials, LoggerService } from '@backstage/backend-plugin-api';
3
- import { KubernetesObjectsProvider as KubernetesObjectsProvider$1, KubernetesClustersSupplier as KubernetesClustersSupplier$1, AuthenticationStrategy as AuthenticationStrategy$1, KubernetesFetcher as KubernetesFetcher$1, KubernetesServiceLocator as KubernetesServiceLocator$1 } from '@backstage/plugin-kubernetes-node';
3
+ import { KubernetesObjectsProvider as KubernetesObjectsProvider$1, KubernetesClustersSupplier as KubernetesClustersSupplier$1, KubernetesServiceLocator as KubernetesServiceLocator$1, CustomResource as CustomResource$1, ObjectToFetch as ObjectToFetch$1, AuthenticationStrategy as AuthenticationStrategy$1, KubernetesFetcher as KubernetesFetcher$1 } from '@backstage/plugin-kubernetes-node';
4
4
  import { Entity } from '@backstage/catalog-model';
5
- import { ObjectsByEntityResponse, KubernetesRequestAuth, CustomResourceMatcher, KubernetesFetchError, FetchResponse } from '@backstage/plugin-kubernetes-common';
5
+ import { KubernetesRequestAuth, ObjectsByEntityResponse, CustomResourceMatcher, KubernetesFetchError, FetchResponse } from '@backstage/plugin-kubernetes-common';
6
6
  import { JsonObject } from '@backstage/types';
7
7
 
8
+ /**
9
+ * A factory function for creating a KubernetesObjectsProvider.
10
+ *
11
+ * @public
12
+ */
13
+ type KubernetesObjectsProviderFactory = (opts: {
14
+ getDefault: () => Promise<KubernetesObjectsProvider$1>;
15
+ clusterSupplier: KubernetesClustersSupplier$1;
16
+ serviceLocator: KubernetesServiceLocator$1;
17
+ customResources: CustomResource$1[];
18
+ objectTypesToFetch?: ObjectToFetch$1[];
19
+ authStrategy: AuthenticationStrategy$1;
20
+ }) => Promise<KubernetesObjectsProvider$1>;
8
21
  /**
9
22
  * The interface for {@link kubernetesObjectsProviderExtensionPoint}.
10
23
  *
11
24
  * @public
12
25
  */
13
26
  interface KubernetesObjectsProviderExtensionPoint {
14
- addObjectsProvider(provider: KubernetesObjectsProvider$1): void;
27
+ addObjectsProvider(provider: KubernetesObjectsProvider$1 | KubernetesObjectsProviderFactory): void;
15
28
  }
16
29
  /**
17
30
  * An extension point the exposes the ability to configure a objects provider.
@@ -19,13 +32,21 @@ interface KubernetesObjectsProviderExtensionPoint {
19
32
  * @public
20
33
  */
21
34
  declare const kubernetesObjectsProviderExtensionPoint: _backstage_backend_plugin_api.ExtensionPoint<KubernetesObjectsProviderExtensionPoint>;
35
+ /**
36
+ * A factory function for creating a KubernetesClustersSupplier.
37
+ *
38
+ * @public
39
+ */
40
+ type KubernetesClusterSupplierFactory = (opts: {
41
+ getDefault: () => Promise<KubernetesClustersSupplier$1>;
42
+ }) => Promise<KubernetesClustersSupplier$1>;
22
43
  /**
23
44
  * The interface for {@link kubernetesClusterSupplierExtensionPoint}.
24
45
  *
25
46
  * @public
26
47
  */
27
48
  interface KubernetesClusterSupplierExtensionPoint {
28
- addClusterSupplier(clusterSupplier: KubernetesClustersSupplier$1): void;
49
+ addClusterSupplier(clusterSupplier: KubernetesClustersSupplier$1 | KubernetesClusterSupplierFactory): void;
29
50
  }
30
51
  /**
31
52
  * An extension point the exposes the ability to configure a cluster supplier.
@@ -47,13 +68,21 @@ interface KubernetesAuthStrategyExtensionPoint {
47
68
  * @public
48
69
  */
49
70
  declare const kubernetesAuthStrategyExtensionPoint: _backstage_backend_plugin_api.ExtensionPoint<KubernetesAuthStrategyExtensionPoint>;
71
+ /**
72
+ * A factory function for creating a KubernetesFetcher.
73
+ *
74
+ * @public
75
+ */
76
+ type KubernetesFetcherFactory = (opts: {
77
+ getDefault: () => Promise<KubernetesFetcher$1>;
78
+ }) => Promise<KubernetesFetcher$1>;
50
79
  /**
51
80
  * The interface for {@link kubernetesFetcherExtensionPoint}.
52
81
  *
53
82
  * @public
54
83
  */
55
84
  interface KubernetesFetcherExtensionPoint {
56
- addFetcher(fetcher: KubernetesFetcher$1): void;
85
+ addFetcher(fetcher: KubernetesFetcher$1 | KubernetesFetcherFactory): void;
57
86
  }
58
87
  /**
59
88
  * An extension point the exposes the ability to configure a kubernetes fetcher.
@@ -61,13 +90,22 @@ interface KubernetesFetcherExtensionPoint {
61
90
  * @public
62
91
  */
63
92
  declare const kubernetesFetcherExtensionPoint: _backstage_backend_plugin_api.ExtensionPoint<KubernetesFetcherExtensionPoint>;
93
+ /**
94
+ * A factory function for creating a KubernetesServiceLocator.
95
+ *
96
+ * @public
97
+ */
98
+ type KubernetesServiceLocatorFactory = (opts: {
99
+ getDefault: () => Promise<KubernetesServiceLocator$1>;
100
+ clusterSupplier: KubernetesClustersSupplier$1;
101
+ }) => Promise<KubernetesServiceLocator$1>;
64
102
  /**
65
103
  * The interface for {@link kubernetesServiceLocatorExtensionPoint}.
66
104
  *
67
105
  * @public
68
106
  */
69
107
  interface KubernetesServiceLocatorExtensionPoint {
70
- addServiceLocator(serviceLocator: KubernetesServiceLocator$1): void;
108
+ addServiceLocator(serviceLocator: KubernetesServiceLocator$1 | KubernetesServiceLocatorFactory): void;
71
109
  }
72
110
  /**
73
111
  * An extension point the exposes the ability to configure a kubernetes service locator.
@@ -313,4 +351,4 @@ declare class PinnipedHelper {
313
351
  private buildRequestForPinniped;
314
352
  }
315
353
 
316
- export { type AuthMetadata, type AuthenticationStrategy, type ClusterDetails, type CustomResource, type CustomResourcesByEntity, type FetchResponseWrapper, type KubernetesAuthStrategyExtensionPoint, type KubernetesClusterSupplierExtensionPoint, type KubernetesClustersSupplier, type KubernetesCredential, type KubernetesFetcher, type KubernetesFetcherExtensionPoint, type KubernetesObjectTypes, type KubernetesObjectsByEntity, type KubernetesObjectsProvider, type KubernetesObjectsProviderExtensionPoint, type KubernetesServiceLocator, type KubernetesServiceLocatorExtensionPoint, type ObjectFetchParams, type ObjectToFetch, type PinnipedClientCerts, PinnipedHelper, type PinnipedParameters, type ServiceLocatorRequestContext, kubernetesAuthStrategyExtensionPoint, kubernetesClusterSupplierExtensionPoint, kubernetesFetcherExtensionPoint, kubernetesObjectsProviderExtensionPoint, kubernetesServiceLocatorExtensionPoint };
354
+ export { type AuthMetadata, type AuthenticationStrategy, type ClusterDetails, type CustomResource, type CustomResourcesByEntity, type FetchResponseWrapper, type KubernetesAuthStrategyExtensionPoint, type KubernetesClusterSupplierExtensionPoint, type KubernetesClusterSupplierFactory, type KubernetesClustersSupplier, type KubernetesCredential, type KubernetesFetcher, type KubernetesFetcherExtensionPoint, type KubernetesFetcherFactory, type KubernetesObjectTypes, type KubernetesObjectsByEntity, type KubernetesObjectsProvider, type KubernetesObjectsProviderExtensionPoint, type KubernetesObjectsProviderFactory, type KubernetesServiceLocator, type KubernetesServiceLocatorExtensionPoint, type KubernetesServiceLocatorFactory, type ObjectFetchParams, type ObjectToFetch, type PinnipedClientCerts, PinnipedHelper, type PinnipedParameters, type ServiceLocatorRequestContext, kubernetesAuthStrategyExtensionPoint, kubernetesClusterSupplierExtensionPoint, kubernetesFetcherExtensionPoint, kubernetesObjectsProviderExtensionPoint, kubernetesServiceLocatorExtensionPoint };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-kubernetes-node",
3
- "version": "0.3.3-next.0",
3
+ "version": "0.3.3",
4
4
  "description": "Node.js library for the kubernetes plugin",
5
5
  "backstage": {
6
6
  "role": "node-library",
@@ -38,20 +38,20 @@
38
38
  "test": "backstage-cli package test"
39
39
  },
40
40
  "dependencies": {
41
- "@backstage/backend-plugin-api": "1.4.2-next.0",
42
- "@backstage/catalog-model": "1.7.5",
43
- "@backstage/plugin-kubernetes-common": "0.9.6",
44
- "@backstage/types": "1.2.1",
41
+ "@backstage/backend-plugin-api": "^1.4.2",
42
+ "@backstage/catalog-model": "^1.7.5",
43
+ "@backstage/plugin-kubernetes-common": "^0.9.6",
44
+ "@backstage/types": "^1.2.1",
45
45
  "@kubernetes/client-node": "1.1.2",
46
46
  "node-fetch": "^2.7.0",
47
47
  "winston": "^3.2.1"
48
48
  },
49
49
  "devDependencies": {
50
- "@backstage/backend-app-api": "1.2.6-next.0",
51
- "@backstage/backend-defaults": "0.11.2-next.0",
52
- "@backstage/backend-test-utils": "1.7.1-next.0",
53
- "@backstage/cli": "0.33.2-next.0",
54
- "@backstage/plugin-kubernetes-backend": "0.19.9-next.0",
50
+ "@backstage/backend-app-api": "^1.2.6",
51
+ "@backstage/backend-defaults": "^0.12.0",
52
+ "@backstage/backend-test-utils": "^1.8.0",
53
+ "@backstage/cli": "^0.34.0",
54
+ "@backstage/plugin-kubernetes-backend": "^0.20.0",
55
55
  "msw": "^1.3.1",
56
56
  "supertest": "^7.0.0"
57
57
  },