From 72e610f0e49122e3ee5fcce2ad8d5da5669d9d39 Mon Sep 17 00:00:00 2001 From: Matthew Clarke Date: Mon, 19 Sep 2022 15:57:13 -0400 Subject: [PATCH] pr feedback Signed-off-by: Matthew Clarke --- plugins/kubernetes-common/api-report.md | 18 +++++++++++++++ plugins/kubernetes-common/src/types.ts | 13 +++++++++++ plugins/kubernetes/api-report.md | 18 +++++---------- .../src/api/KubernetesBackendClient.ts | 23 ++++++++----------- plugins/kubernetes/src/api/types.ts | 12 ++++------ 5 files changed, 51 insertions(+), 33 deletions(-) diff --git a/plugins/kubernetes-common/api-report.md b/plugins/kubernetes-common/api-report.md index 9485bd0294..85015662c6 100644 --- a/plugins/kubernetes-common/api-report.md +++ b/plugins/kubernetes-common/api-report.md @@ -89,6 +89,16 @@ export interface CronJobsFetchResponse { type: 'cronjobs'; } +// @public (undocumented) +export interface CustomObjectsByEntityRequest { + // (undocumented) + auth: KubernetesRequestAuth; + // (undocumented) + customResources: CustomResourceMatcher[]; + // (undocumented) + entity: Entity; +} + // @public (undocumented) export interface CustomResourceFetchResponse { // (undocumented) @@ -243,4 +253,12 @@ export interface StatefulSetsFetchResponse { // (undocumented) type: 'statefulsets'; } + +// @public (undocumented) +export interface WorkloadsByEntityRequest { + // (undocumented) + auth: KubernetesRequestAuth; + // (undocumented) + entity: Entity; +} ``` diff --git a/plugins/kubernetes-common/src/types.ts b/plugins/kubernetes-common/src/types.ts index 07378ae688..149caadb15 100644 --- a/plugins/kubernetes-common/src/types.ts +++ b/plugins/kubernetes-common/src/types.ts @@ -46,6 +46,19 @@ export interface CustomResourceMatcher { plural: string; } +/** @public */ +export interface WorkloadsByEntityRequest { + auth: KubernetesRequestAuth; + entity: Entity; +} + +/** @public */ +export interface CustomObjectsByEntityRequest { + auth: KubernetesRequestAuth; + customResources: CustomResourceMatcher[]; + entity: Entity; +} + /** @public */ export interface KubernetesRequestBody { auth?: KubernetesRequestAuth; diff --git a/plugins/kubernetes/api-report.md b/plugins/kubernetes/api-report.md index 98ca4e4725..b7ec80aee3 100644 --- a/plugins/kubernetes/api-report.md +++ b/plugins/kubernetes/api-report.md @@ -10,12 +10,11 @@ import { BackstagePlugin } from '@backstage/core-plugin-api'; import { ClientPodStatus } from '@backstage/plugin-kubernetes-common'; import { ClusterAttributes } from '@backstage/plugin-kubernetes-common'; import { ClusterObjects } from '@backstage/plugin-kubernetes-common'; -import { CustomResourceMatcher } from '@backstage/plugin-kubernetes-common'; +import { CustomObjectsByEntityRequest } from '@backstage/plugin-kubernetes-common'; import { DiscoveryApi } from '@backstage/core-plugin-api'; import { Entity } from '@backstage/catalog-model'; import { IdentityApi } from '@backstage/core-plugin-api'; import type { JsonObject } from '@backstage/types'; -import { KubernetesRequestAuth } from '@backstage/plugin-kubernetes-common'; import { KubernetesRequestBody } from '@backstage/plugin-kubernetes-common'; import { OAuthApi } from '@backstage/core-plugin-api'; import { ObjectsByEntityResponse } from '@backstage/plugin-kubernetes-common'; @@ -33,6 +32,7 @@ import { V1Pod } from '@kubernetes/client-node'; import { V1ReplicaSet } from '@kubernetes/client-node'; import { V1Service } from '@kubernetes/client-node'; import { V1StatefulSet } from '@kubernetes/client-node'; +import { WorkloadsByEntityRequest } from '@backstage/plugin-kubernetes-common'; // Warning: (ae-forgotten-export) The symbol "ClusterProps" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "Cluster" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -248,9 +248,7 @@ export interface KubernetesApi { >; // (undocumented) getCustomObjectsByEntity( - auth: KubernetesRequestAuth, - customResources: CustomResourceMatcher[], - entity: Entity, + request: CustomObjectsByEntityRequest, ): Promise; // (undocumented) getObjectsByEntity( @@ -258,8 +256,7 @@ export interface KubernetesApi { ): Promise; // (undocumented) getWorkloadsByEntity( - auth: KubernetesRequestAuth, - entity: Entity, + request: WorkloadsByEntityRequest, ): Promise; } @@ -318,9 +315,7 @@ export class KubernetesBackendClient implements KubernetesApi { >; // (undocumented) getCustomObjectsByEntity( - auth: KubernetesRequestAuth, - customResources: CustomResourceMatcher[], - entity: Entity, + request: CustomObjectsByEntityRequest, ): Promise; // (undocumented) getObjectsByEntity( @@ -328,8 +323,7 @@ export class KubernetesBackendClient implements KubernetesApi { ): Promise; // (undocumented) getWorkloadsByEntity( - auth: KubernetesRequestAuth, - entity: Entity, + request: WorkloadsByEntityRequest, ): Promise; } diff --git a/plugins/kubernetes/src/api/KubernetesBackendClient.ts b/plugins/kubernetes/src/api/KubernetesBackendClient.ts index 04f4624b24..bffc966333 100644 --- a/plugins/kubernetes/src/api/KubernetesBackendClient.ts +++ b/plugins/kubernetes/src/api/KubernetesBackendClient.ts @@ -16,13 +16,13 @@ import { KubernetesApi } from './types'; import { - KubernetesRequestAuth, KubernetesRequestBody, ObjectsByEntityResponse, - CustomResourceMatcher, + WorkloadsByEntityRequest, + CustomObjectsByEntityRequest, } from '@backstage/plugin-kubernetes-common'; import { DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api'; -import { Entity, stringifyEntityRef } from '@backstage/catalog-model'; +import { stringifyEntityRef } from '@backstage/catalog-model'; export class KubernetesBackendClient implements KubernetesApi { private readonly discoveryApi: DiscoveryApi; @@ -79,24 +79,21 @@ export class KubernetesBackendClient implements KubernetesApi { } async getWorkloadsByEntity( - auth: KubernetesRequestAuth, - entity: Entity, + request: WorkloadsByEntityRequest, ): Promise { return await this.postRequired('/resources/workloads/query', { - auth, - entityRef: stringifyEntityRef(entity), + auth: request.auth, + entityRef: stringifyEntityRef(request.entity), }); } async getCustomObjectsByEntity( - auth: KubernetesRequestAuth, - customResources: CustomResourceMatcher[], - entity: Entity, + request: CustomObjectsByEntityRequest, ): Promise { return await this.postRequired(`/resources/custom/query`, { - entityRef: stringifyEntityRef(entity), - auth, - customResources, + entityRef: stringifyEntityRef(request.entity), + auth: request.auth, + customResources: request.customResources, }); } diff --git a/plugins/kubernetes/src/api/types.ts b/plugins/kubernetes/src/api/types.ts index b7e3f9fd49..0005a8d069 100644 --- a/plugins/kubernetes/src/api/types.ts +++ b/plugins/kubernetes/src/api/types.ts @@ -15,13 +15,12 @@ */ import { - KubernetesRequestAuth, KubernetesRequestBody, ObjectsByEntityResponse, - CustomResourceMatcher, + WorkloadsByEntityRequest, + CustomObjectsByEntityRequest, } from '@backstage/plugin-kubernetes-common'; import { createApiRef } from '@backstage/core-plugin-api'; -import { Entity } from '@backstage/catalog-model'; export const kubernetesApiRef = createApiRef({ id: 'plugin.kubernetes.service', @@ -39,12 +38,9 @@ export interface KubernetesApi { }[] >; getWorkloadsByEntity( - auth: KubernetesRequestAuth, - entity: Entity, + request: WorkloadsByEntityRequest, ): Promise; getCustomObjectsByEntity( - auth: KubernetesRequestAuth, - customResources: CustomResourceMatcher[], - entity: Entity, + request: CustomObjectsByEntityRequest, ): Promise; }