From 8253266a726db04584099c9aca77ffa156e82d43 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Thu, 9 Nov 2023 13:18:44 -0500 Subject: [PATCH] add download files artifacts to kurtosis client in em ui --- .../client/enclaveManager/KurtosisClient.ts | 19 ++++++++++++++++++- .../enclaves/widgets/DownloadFileButton.tsx | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/enclave-manager/web/src/client/enclaveManager/KurtosisClient.ts b/enclave-manager/web/src/client/enclaveManager/KurtosisClient.ts index 413f206cc6..6034de66bf 100644 --- a/enclave-manager/web/src/client/enclaveManager/KurtosisClient.ts +++ b/enclave-manager/web/src/client/enclaveManager/KurtosisClient.ts @@ -1,5 +1,6 @@ import { PromiseClient } from "@connectrpc/connect"; import { + DownloadFilesArtifactArgs, FilesArtifactNameAndUuid, RunStarlarkPackageArgs, ServiceInfo, @@ -15,6 +16,7 @@ import { } from "enclave-manager-sdk/build/engine_service_pb"; import { KurtosisEnclaveManagerServer } from "enclave-manager-sdk/build/kurtosis_enclave_manager_api_connect"; import { + DownloadFilesArtifactRequest, GetListFilesArtifactNamesAndUuidsRequest, GetServicesRequest, GetStarlarkRunRequest, @@ -145,7 +147,7 @@ export abstract class KurtosisClient { const apicInfo = enclave.apiContainerInfo; assertDefined( apicInfo, - `Cannot listFilesArtifactNamesAndUuids because the passed enclave '${enclave.name}' does not have apicInfo`, + `Cannot inspect files artifact contents because the passed enclave '${enclave.name}' does not have apicInfo`, ); const request = new InspectFilesArtifactContentsRequest({ apicIpAddress: apicInfo.bridgeIpAddress, @@ -156,6 +158,21 @@ export abstract class KurtosisClient { }, `KurtosisClient could not inspectFilesArtifactContents for ${enclave.name}`); } + async downloadFilesArtifact(enclave: RemoveFunctions, file: FilesArtifactNameAndUuid) { + const apicInfo = enclave.apiContainerInfo; + assertDefined( + apicInfo, + `Cannot download files artifact because the passed enclave '${enclave.name}' does not have apicInfo`, + ); + // Not currently using asyncResult as the return type here is an asyncIterable + const request = new DownloadFilesArtifactRequest({ + apicIpAddress: apicInfo.bridgeIpAddress, + apicPort: apicInfo.grpcPortInsideEnclave, + downloadFilesArtifactsArgs: new DownloadFilesArtifactArgs({ identifier: file.fileUuid}) + }); + return this.client.downloadFilesArtifact(request, this.getHeaderOptions()); + } + async createEnclave( enclaveName: string, apiContainerLogLevel: string, diff --git a/enclave-manager/web/src/components/enclaves/widgets/DownloadFileButton.tsx b/enclave-manager/web/src/components/enclaves/widgets/DownloadFileButton.tsx index 93ebabe135..41d1da044c 100644 --- a/enclave-manager/web/src/components/enclaves/widgets/DownloadFileButton.tsx +++ b/enclave-manager/web/src/components/enclaves/widgets/DownloadFileButton.tsx @@ -19,7 +19,7 @@ export const DownloadFileButton = ({ file, enclave }: DownloadFileButtonProps) = const handleDownloadClick = async () => { setIsLoading(true); // todo: get tgz download instead - const maybeFile = await kurtosisClient.inspectFilesArtifactContents(enclave, file); + const maybeFile = await kurtosisClient.downloadFilesArtifact(enclave, file); if (maybeFile.isErr) { toast({ title: `Could not inspect ${file.fileName}: ${maybeFile.error}`,