From 40de11b8f5f77d139b9c87b7213d4be49fc5ca9e Mon Sep 17 00:00:00 2001 From: Jonah Back Date: Tue, 5 Jul 2022 10:17:20 -0700 Subject: [PATCH] address review comments Signed-off-by: Jonah Back --- .../cluster-locator/CatalogClusterLocator.ts | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/plugins/kubernetes-backend/src/cluster-locator/CatalogClusterLocator.ts b/plugins/kubernetes-backend/src/cluster-locator/CatalogClusterLocator.ts index 124a53a72a..03fa347e5f 100644 --- a/plugins/kubernetes-backend/src/cluster-locator/CatalogClusterLocator.ts +++ b/plugins/kubernetes-backend/src/cluster-locator/CatalogClusterLocator.ts @@ -34,19 +34,21 @@ export class CatalogClusterLocator implements KubernetesClustersSupplier { } async getClusters(): Promise { + const apiServerKey = `metadata.annotations.${ANNOTATION_KUBERNETES_API_SERVER}`; + const apiServerCaKey = `metadata.annotations.${ANNOTATION_KUBERNETES_API_SERVER_CA}`; + const authProviderKey = `metadata.annotations.${ANNOTATION_KUBERNETES_AUTH_PROVIDER}`; + + const filter: Record = { + kind: 'Resource', + 'spec.type': 'kubernetes-cluster', + }; + + filter[apiServerKey] = CATALOG_FILTER_EXISTS; + filter[apiServerCaKey] = CATALOG_FILTER_EXISTS; + filter[authProviderKey] = CATALOG_FILTER_EXISTS; + const clusters = await this.catalogClient.getEntities({ - filter: [ - { - kind: 'Resource', - 'spec.type': 'kubernetes-cluster', - 'metadata.annotations.kubernetes.io/api-server': - CATALOG_FILTER_EXISTS, - 'metadata.annotations.kubernetes.io/api-server-certificate-authority': - CATALOG_FILTER_EXISTS, - 'metadata.annotations.kubernetes.io/auth-provider': - CATALOG_FILTER_EXISTS, - }, - ], + filter: [filter], }); return clusters.items.map(entity => { const clusterDetails: ClusterDetails = {