Skip to content

Commit

Permalink
add download files artifacts to kurtosis client in em ui
Browse files Browse the repository at this point in the history
  • Loading branch information
tedim52 committed Nov 9, 2023
1 parent 1af09ed commit 8253266
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 18 additions & 1 deletion enclave-manager/web/src/client/enclaveManager/KurtosisClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { PromiseClient } from "@connectrpc/connect";
import {
DownloadFilesArtifactArgs,
FilesArtifactNameAndUuid,
RunStarlarkPackageArgs,
ServiceInfo,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -156,6 +158,21 @@ export abstract class KurtosisClient {
}, `KurtosisClient could not inspectFilesArtifactContents for ${enclave.name}`);
}

async downloadFilesArtifact(enclave: RemoveFunctions<EnclaveInfo>, 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down

0 comments on commit 8253266

Please sign in to comment.