feature: add support for apps to pass in a KubernetesClustersSupplier

This commit is contained in:
Jonah Back
2021-02-22 20:14:08 -08:00
parent 8b79540176
commit e3adec2bd1
2 changed files with 18 additions and 4 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-kubernetes-backend': patch
---
Allow apps to pass in a KubernetesClustersSupplier
@@ -27,6 +27,7 @@ import {
ServiceLocatorMethod,
ClusterLocatorMethod,
ClusterDetails,
KubernetesClustersSupplier,
} from '..';
import { getCombinedClusterDetails } from '../cluster-locator';
import { KubernetesFanOutHandler } from './KubernetesFanOutHandler';
@@ -34,6 +35,7 @@ import { KubernetesFanOutHandler } from './KubernetesFanOutHandler';
export interface RouterOptions {
logger: Logger;
config: Config;
clusterSupplier?: KubernetesClustersSupplier;
}
const getServiceLocator = (
@@ -98,10 +100,17 @@ export async function createRouter(
'kubernetes.clusterLocatorMethods',
) as ClusterLocatorMethod[];
const clusterDetails = await getCombinedClusterDetails(
clusterLocatorMethods,
options.config,
);
let clusterDetails: ClusterDetails[];
if (options.clusterSupplier) {
clusterDetails = await options.clusterSupplier.getClusters();
// Append supplied clusters to cluster retrieved via getCombinedClusterDetails
} else {
clusterDetails = await getCombinedClusterDetails(
clusterLocatorMethods,
options.config,
);
}
const serviceLocator = getServiceLocator(options.config, clusterDetails);