pr feedback

Signed-off-by: Matthew Clarke <mclarke@spotify.com>
This commit is contained in:
Matthew Clarke
2022-09-19 15:57:13 -04:00
parent 5eb54be2ac
commit 72e610f0e4
5 changed files with 51 additions and 33 deletions
@@ -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<ObjectsByEntityResponse> {
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<ObjectsByEntityResponse> {
return await this.postRequired(`/resources/custom/query`, {
entityRef: stringifyEntityRef(entity),
auth,
customResources,
entityRef: stringifyEntityRef(request.entity),
auth: request.auth,
customResources: request.customResources,
});
}
+4 -8
View File
@@ -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<KubernetesApi>({
id: 'plugin.kubernetes.service',
@@ -39,12 +38,9 @@ export interface KubernetesApi {
}[]
>;
getWorkloadsByEntity(
auth: KubernetesRequestAuth,
entity: Entity,
request: WorkloadsByEntityRequest,
): Promise<ObjectsByEntityResponse>;
getCustomObjectsByEntity(
auth: KubernetesRequestAuth,
customResources: CustomResourceMatcher[],
entity: Entity,
request: CustomObjectsByEntityRequest,
): Promise<ObjectsByEntityResponse>;
}