From 8dd179ac2f57b9b4743af58b38c35b477c1df071 Mon Sep 17 00:00:00 2001 From: Jamie Klassen Date: Tue, 5 Sep 2023 16:14:10 -0400 Subject: [PATCH] refactor: remove redundant ClusterDetails subtypes Signed-off-by: Jamie Klassen --- plugins/kubernetes-backend/api-report.md | 20 +++++++------------ .../src/cluster-locator/GkeClusterLocator.ts | 8 ++------ .../AzureIdentityKubernetesAuthTranslator.ts | 8 ++++---- .../GoogleKubernetesAuthTranslator.ts | 8 ++++---- .../GoogleServiceAccountAuthProvider.ts | 8 ++++---- plugins/kubernetes-backend/src/types/types.ts | 14 +------------ 6 files changed, 22 insertions(+), 44 deletions(-) diff --git a/plugins/kubernetes-backend/api-report.md b/plugins/kubernetes-backend/api-report.md index ebaae3dfa8..a9037f2c31 100644 --- a/plugins/kubernetes-backend/api-report.md +++ b/plugins/kubernetes-backend/api-report.md @@ -41,9 +41,6 @@ export class AwsIamKubernetesAuthTranslator ): Promise; } -// @public (undocumented) -export interface AzureClusterDetails extends ClusterDetails {} - // @public (undocumented) export class AzureIdentityKubernetesAuthTranslator implements KubernetesAuthTranslator @@ -51,8 +48,8 @@ export class AzureIdentityKubernetesAuthTranslator constructor(logger: Logger, tokenCredential?: TokenCredential); // (undocumented) decorateClusterDetailsWithAuth( - clusterDetails: AzureClusterDetails, - ): Promise; + clusterDetails: ClusterDetails, + ): Promise; } // @public (undocumented) @@ -123,18 +120,15 @@ export interface FetchResponseWrapper { responses: FetchResponse[]; } -// @public (undocumented) -export interface GKEClusterDetails extends ClusterDetails {} - // @public (undocumented) export class GoogleKubernetesAuthTranslator implements KubernetesAuthTranslator { // (undocumented) decorateClusterDetailsWithAuth( - clusterDetails: GKEClusterDetails, + clusterDetails: ClusterDetails, authConfig: KubernetesRequestAuth, - ): Promise; + ): Promise; } // @public (undocumented) @@ -143,8 +137,8 @@ export class GoogleServiceAccountAuthTranslator { // (undocumented) decorateClusterDetailsWithAuth( - clusterDetails: GKEClusterDetails, - ): Promise; + clusterDetails: ClusterDetails, + ): Promise; } // @public @@ -398,7 +392,7 @@ export class NoopKubernetesAuthTranslator implements KubernetesAuthTranslator { // @public (undocumented) export interface ObjectFetchParams { // (undocumented) - clusterDetails: GKEClusterDetails | ClusterDetails; + clusterDetails: ClusterDetails; // (undocumented) customResources: CustomResource[]; // (undocumented) diff --git a/plugins/kubernetes-backend/src/cluster-locator/GkeClusterLocator.ts b/plugins/kubernetes-backend/src/cluster-locator/GkeClusterLocator.ts index 7a81b98032..40a003607f 100644 --- a/plugins/kubernetes-backend/src/cluster-locator/GkeClusterLocator.ts +++ b/plugins/kubernetes-backend/src/cluster-locator/GkeClusterLocator.ts @@ -19,11 +19,7 @@ import { ForwardedError } from '@backstage/errors'; import * as container from '@google-cloud/container'; import { Duration } from 'luxon'; import { runPeriodically } from '../service/runPeriodically'; -import { - ClusterDetails, - GKEClusterDetails, - KubernetesClustersSupplier, -} from '../types/types'; +import { ClusterDetails, KubernetesClustersSupplier } from '../types/types'; interface MatchResourceLabelEntry { key: string; @@ -43,7 +39,7 @@ export class GkeClusterLocator implements KubernetesClustersSupplier { constructor( private readonly options: GkeClusterLocatorOptions, private readonly client: container.v1.ClusterManagerClient, - private clusterDetails: GKEClusterDetails[] | undefined = undefined, + private clusterDetails: ClusterDetails[] | undefined = undefined, private hasClusterDetails: boolean = false, ) {} diff --git a/plugins/kubernetes-backend/src/kubernetes-auth-translator/AzureIdentityKubernetesAuthTranslator.ts b/plugins/kubernetes-backend/src/kubernetes-auth-translator/AzureIdentityKubernetesAuthTranslator.ts index 784e3c7311..3e0622a9d2 100644 --- a/plugins/kubernetes-backend/src/kubernetes-auth-translator/AzureIdentityKubernetesAuthTranslator.ts +++ b/plugins/kubernetes-backend/src/kubernetes-auth-translator/AzureIdentityKubernetesAuthTranslator.ts @@ -16,7 +16,7 @@ import { Logger } from 'winston'; import { KubernetesAuthTranslator } from './types'; -import { AzureClusterDetails } from '../types/types'; +import { ClusterDetails } from '../types/types'; import { AccessToken, DefaultAzureCredential, @@ -41,9 +41,9 @@ export class AzureIdentityKubernetesAuthTranslator ) {} async decorateClusterDetailsWithAuth( - clusterDetails: AzureClusterDetails, - ): Promise { - const clusterDetailsWithAuthToken: AzureClusterDetails = Object.assign( + clusterDetails: ClusterDetails, + ): Promise { + const clusterDetailsWithAuthToken: ClusterDetails = Object.assign( {}, clusterDetails, ); diff --git a/plugins/kubernetes-backend/src/kubernetes-auth-translator/GoogleKubernetesAuthTranslator.ts b/plugins/kubernetes-backend/src/kubernetes-auth-translator/GoogleKubernetesAuthTranslator.ts index 96b2daebad..d0bef9c21b 100644 --- a/plugins/kubernetes-backend/src/kubernetes-auth-translator/GoogleKubernetesAuthTranslator.ts +++ b/plugins/kubernetes-backend/src/kubernetes-auth-translator/GoogleKubernetesAuthTranslator.ts @@ -15,7 +15,7 @@ */ import { KubernetesAuthTranslator } from './types'; -import { GKEClusterDetails } from '../types/types'; +import { ClusterDetails } from '../types/types'; import { KubernetesRequestAuth } from '@backstage/plugin-kubernetes-common'; /** @@ -26,10 +26,10 @@ export class GoogleKubernetesAuthTranslator implements KubernetesAuthTranslator { async decorateClusterDetailsWithAuth( - clusterDetails: GKEClusterDetails, + clusterDetails: ClusterDetails, authConfig: KubernetesRequestAuth, - ): Promise { - const clusterDetailsWithAuthToken: GKEClusterDetails = Object.assign( + ): Promise { + const clusterDetailsWithAuthToken: ClusterDetails = Object.assign( {}, clusterDetails, ); diff --git a/plugins/kubernetes-backend/src/kubernetes-auth-translator/GoogleServiceAccountAuthProvider.ts b/plugins/kubernetes-backend/src/kubernetes-auth-translator/GoogleServiceAccountAuthProvider.ts index 81b50c478b..8aa60e0012 100644 --- a/plugins/kubernetes-backend/src/kubernetes-auth-translator/GoogleServiceAccountAuthProvider.ts +++ b/plugins/kubernetes-backend/src/kubernetes-auth-translator/GoogleServiceAccountAuthProvider.ts @@ -14,7 +14,7 @@ * limitations under the License. */ import { KubernetesAuthTranslator } from './types'; -import { GKEClusterDetails } from '../types/types'; +import { ClusterDetails } from '../types/types'; import * as container from '@google-cloud/container'; /** @@ -25,9 +25,9 @@ export class GoogleServiceAccountAuthTranslator implements KubernetesAuthTranslator { async decorateClusterDetailsWithAuth( - clusterDetails: GKEClusterDetails, - ): Promise { - const clusterDetailsWithAuthToken: GKEClusterDetails = Object.assign( + clusterDetails: ClusterDetails, + ): Promise { + const clusterDetailsWithAuthToken: ClusterDetails = Object.assign( {}, clusterDetails, ); diff --git a/plugins/kubernetes-backend/src/types/types.ts b/plugins/kubernetes-backend/src/types/types.ts index 6d53ac350b..0096c166d8 100644 --- a/plugins/kubernetes-backend/src/types/types.ts +++ b/plugins/kubernetes-backend/src/types/types.ts @@ -33,7 +33,7 @@ import { Config } from '@backstage/config'; */ export interface ObjectFetchParams { serviceId: string; - clusterDetails: GKEClusterDetails | ClusterDetails; + clusterDetails: ClusterDetails; objectTypesToFetch: Set; labelSelector: string; customResources: CustomResource[]; @@ -208,18 +208,6 @@ export interface ClusterDetails { authMetadata?: Record; } -/** - * - * @public - */ -export interface GKEClusterDetails extends ClusterDetails {} - -/** - * - * @public - */ -export interface AzureClusterDetails extends ClusterDetails {} - /** * * @public