kurtosis-sdk 0.84.4 → 0.84.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,4 +35,7 @@ export declare class EnclaveContext {
35
35
  getStarlarkRun(): Promise<Result<GetStarlarkRunResponse, Error>>;
36
36
  private static convertApiPortsToServiceContextPorts;
37
37
  private assembleRunStarlarkPackageArg;
38
+ private getKurtosisYaml;
39
+ private uploadLocalStarlarkPackageDependencies;
40
+ private isLocalDependencyReplace;
38
41
  }
@@ -25,6 +25,8 @@ const kurtosis_yaml_1 = require("./kurtosis_yaml");
25
25
  const starlark_run_blocking_1 = require("./starlark_run_blocking");
26
26
  const service_identifiers_1 = require("../services/service_identifiers");
27
27
  exports.KURTOSIS_YAML_FILENAME = "kurtosis.yml";
28
+ const OS_PATH_SEPARATOR_STRING = "/";
29
+ const DOT_RELATIVE_PATH_INDICATOR_STRING = ".";
28
30
  // Docs available at https://docs.kurtosis.com/sdk/#enclavecontext
29
31
  class EnclaveContext {
30
32
  constructor(backend, pathJoiner, genericTgzArchiver) {
@@ -98,10 +100,31 @@ class EnclaveContext {
98
100
  // Docs available at https://docs.kurtosis.com/sdk/#runstarlarkpackagestring-packagerootpath-string-serializedparams-boolean-dryrun---streamstarlarkrunresponseline-responselines-error-error
99
101
  runStarlarkPackage(packageRootPath, runConfig) {
100
102
  return __awaiter(this, void 0, void 0, function* () {
101
- const args = yield this.assembleRunStarlarkPackageArg(packageRootPath, runConfig.relativePathToMainFile, runConfig.mainFunctionName, runConfig.serializedParams, runConfig.dryRun, runConfig.cloudInstanceId, runConfig.cloudUserId);
103
+ const kurtosisYmlResult = yield this.getKurtosisYaml(packageRootPath);
104
+ if (kurtosisYmlResult.isErr()) {
105
+ return (0, neverthrow_1.err)(new Error(`Unexpected error while getting the Kurtosis yaml file from path '${packageRootPath}'`));
106
+ }
107
+ const kurtosisYaml = kurtosisYmlResult.value;
108
+ const packageId = kurtosisYaml.name;
109
+ const packageReplaceOptions = kurtosisYaml.packageReplaceOptions;
110
+ const args = yield this.assembleRunStarlarkPackageArg(kurtosisYaml, runConfig.relativePathToMainFile, runConfig.mainFunctionName, runConfig.serializedParams, runConfig.dryRun, runConfig.cloudInstanceId, runConfig.cloudUserId);
102
111
  if (args.isErr()) {
103
112
  return (0, neverthrow_1.err)(new Error(`Unexpected error while assembling arguments to pass to the Starlark executor \n${args.error}`));
104
113
  }
114
+ const archiverResponse = yield this.genericTgzArchiver.createTgzByteArray(packageRootPath);
115
+ if (archiverResponse.isErr()) {
116
+ return (0, neverthrow_1.err)(new Error(`Unexpected error while creating the package's tgs file from '${packageRootPath}'\n${archiverResponse.error}`));
117
+ }
118
+ const uploadStarlarkPackageResponse = yield this.backend.uploadStarlarkPackage(packageId, archiverResponse.value);
119
+ if (uploadStarlarkPackageResponse.isErr()) {
120
+ return (0, neverthrow_1.err)(new Error(`Unexpected error while uploading Starlark package '${packageId}'\n${uploadStarlarkPackageResponse.error}`));
121
+ }
122
+ if (packageReplaceOptions !== undefined && packageReplaceOptions.size > 0) {
123
+ const uploadLocalStarlarkPackageDependenciesResponse = yield this.uploadLocalStarlarkPackageDependencies(packageRootPath, packageReplaceOptions);
124
+ if (uploadLocalStarlarkPackageDependenciesResponse.isErr()) {
125
+ return (0, neverthrow_1.err)(new Error(`Unexpected error while uploading local Starlark package dependencies '${packageReplaceOptions}' from '${packageRootPath}' \n${uploadLocalStarlarkPackageDependenciesResponse.error}`));
126
+ }
127
+ }
105
128
  const packageRunResult = yield this.backend.runStarlarkPackage(args.value);
106
129
  if (packageRunResult.isErr()) {
107
130
  return (0, neverthrow_1.err)(new Error(`Unexpected error happened executing Starlark package \n${packageRunResult.error}`));
@@ -306,20 +329,9 @@ class EnclaveContext {
306
329
  }
307
330
  return (0, neverthrow_1.ok)(result);
308
331
  }
309
- assembleRunStarlarkPackageArg(packageRootPath, relativePathToMainFile, mainFunctionName, serializedParams, dryRun, cloudInstanceId, cloudUserId) {
332
+ assembleRunStarlarkPackageArg(kurtosisYaml, relativePathToMainFile, mainFunctionName, serializedParams, dryRun, cloudInstanceId, cloudUserId) {
310
333
  return __awaiter(this, void 0, void 0, function* () {
311
- const kurtosisYamlFilepath = path.join(packageRootPath, exports.KURTOSIS_YAML_FILENAME);
312
- const resultParseKurtosisYaml = yield (0, kurtosis_yaml_1.parseKurtosisYaml)(kurtosisYamlFilepath);
313
- if (resultParseKurtosisYaml.isErr()) {
314
- return (0, neverthrow_1.err)(resultParseKurtosisYaml.error);
315
- }
316
- const kurtosisYaml = resultParseKurtosisYaml.value;
317
- const archiverResponse = yield this.genericTgzArchiver.createTgzByteArray(packageRootPath);
318
- if (archiverResponse.isErr()) {
319
- return (0, neverthrow_1.err)(archiverResponse.error);
320
- }
321
334
  const args = new api_container_service_pb_1.RunStarlarkPackageArgs;
322
- args.setLocal(archiverResponse.value);
323
335
  args.setPackageId(kurtosisYaml.name);
324
336
  args.setSerializedParams(serializedParams);
325
337
  args.setDryRun(dryRun);
@@ -330,5 +342,41 @@ class EnclaveContext {
330
342
  return (0, neverthrow_1.ok)(args);
331
343
  });
332
344
  }
345
+ getKurtosisYaml(packageRootPath) {
346
+ return __awaiter(this, void 0, void 0, function* () {
347
+ const kurtosisYamlFilepath = path.join(packageRootPath, exports.KURTOSIS_YAML_FILENAME);
348
+ const resultParseKurtosisYaml = yield (0, kurtosis_yaml_1.parseKurtosisYaml)(kurtosisYamlFilepath);
349
+ if (resultParseKurtosisYaml.isErr()) {
350
+ return (0, neverthrow_1.err)(resultParseKurtosisYaml.error);
351
+ }
352
+ const kurtosisYaml = resultParseKurtosisYaml.value;
353
+ return (0, neverthrow_1.ok)(kurtosisYaml);
354
+ });
355
+ }
356
+ uploadLocalStarlarkPackageDependencies(packageRootPath, packageReplaceOptions) {
357
+ return __awaiter(this, void 0, void 0, function* () {
358
+ for (const [dependencyPackageId, replaceOption] of packageReplaceOptions.entries()) {
359
+ if (this.isLocalDependencyReplace(replaceOption)) {
360
+ const localPackagePath = path.join(packageRootPath, replaceOption);
361
+ const archiverResponse = yield this.genericTgzArchiver.createTgzByteArray(localPackagePath);
362
+ if (archiverResponse.isErr()) {
363
+ return (0, neverthrow_1.err)(archiverResponse.error);
364
+ }
365
+ const uploadStarlarkPackageResponse = yield this.backend.uploadStarlarkPackage(dependencyPackageId, archiverResponse.value);
366
+ if (uploadStarlarkPackageResponse.isErr()) {
367
+ return (0, neverthrow_1.err)(uploadStarlarkPackageResponse.error);
368
+ }
369
+ return (0, neverthrow_1.ok)(null);
370
+ }
371
+ }
372
+ return (0, neverthrow_1.ok)(null);
373
+ });
374
+ }
375
+ isLocalDependencyReplace(replace) {
376
+ if (replace.startsWith(OS_PATH_SEPARATOR_STRING) || replace.startsWith(DOT_RELATIVE_PATH_INDICATOR_STRING)) {
377
+ return true;
378
+ }
379
+ return false;
380
+ }
333
381
  }
334
382
  exports.EnclaveContext = EnclaveContext;
@@ -13,6 +13,7 @@ export interface GenericApiContainerClient {
13
13
  getServices(getServicesArgs: GetServicesArgs): Promise<Result<GetServicesResponse, Error>>;
14
14
  execCommand(execCommandArgs: ExecCommandArgs): Promise<Result<ExecCommandResponse, Error>>;
15
15
  uploadFiles(name: string, payload: Uint8Array): Promise<Result<UploadFilesArtifactResponse, Error>>;
16
+ uploadStarlarkPackage(packageId: string, payload: Uint8Array): Promise<Result<null, Error>>;
16
17
  storeWebFilesArtifact(storeWebFilesArtifactArgs: StoreWebFilesArtifactArgs): Promise<Result<StoreWebFilesArtifactResponse, Error>>;
17
18
  downloadFilesArtifact(downloadFilesArtifactArgs: DownloadFilesArtifactArgs): Promise<Result<Uint8Array, Error>>;
18
19
  getExistingAndHistoricalServiceIdentifiers(): Promise<Result<GetExistingAndHistoricalServiceIdentifiersResponse, Error>>;
@@ -19,6 +19,7 @@ export declare class GrpcNodeApiContainerClient implements GenericApiContainerCl
19
19
  getServices(getServicesArgs: GetServicesArgs): Promise<Result<GetServicesResponse, Error>>;
20
20
  execCommand(execCommandArgs: ExecCommandArgs): Promise<Result<ExecCommandResponse, Error>>;
21
21
  uploadFiles(name: string, payload: Uint8Array): Promise<Result<UploadFilesArtifactResponse, Error>>;
22
+ uploadStarlarkPackage(packageId: string, payload: Uint8Array): Promise<Result<null, Error>>;
22
23
  storeWebFilesArtifact(storeWebFilesArtifactArgs: StoreWebFilesArtifactArgs): Promise<Result<StoreWebFilesArtifactResponse, Error>>;
23
24
  downloadFilesArtifact(downloadFilesArtifactArgs: DownloadFilesArtifactArgs): Promise<Result<Uint8Array, Error>>;
24
25
  getExistingAndHistoricalServiceIdentifiers(): Promise<Result<GetExistingAndHistoricalServiceIdentifiersResponse, Error>>;
@@ -183,6 +183,48 @@ class GrpcNodeApiContainerClient {
183
183
  return (0, neverthrow_1.ok)(uploadFilesArtifactResponse);
184
184
  });
185
185
  }
186
+ uploadStarlarkPackage(packageId, payload) {
187
+ return __awaiter(this, void 0, void 0, function* () {
188
+ const uploadStarlarkPackagePromise = new Promise((resolve, _unusedReject) => {
189
+ const clientStream = this.client.uploadStarlarkPackage((error, response) => {
190
+ if (error === null) {
191
+ if (!response) {
192
+ resolve((0, neverthrow_1.err)(new Error("No error was encountered but the response was still falsy; this should never happen")));
193
+ }
194
+ else {
195
+ resolve((0, neverthrow_1.ok)(null));
196
+ }
197
+ }
198
+ else {
199
+ resolve((0, neverthrow_1.err)(error));
200
+ }
201
+ });
202
+ const constantChunkMetadata = new api_container_service_pb_1.DataChunkMetadata()
203
+ .setName(packageId);
204
+ let previousChunkHash = "";
205
+ for (let idx = 0; idx < payload.length; idx += DATA_STREAM_CHUNK_SIZE) {
206
+ const currentChunk = payload.subarray(idx, Math.min(idx + DATA_STREAM_CHUNK_SIZE, payload.length));
207
+ const dataChunk = new api_container_service_pb_1.StreamedDataChunk()
208
+ .setData(currentChunk)
209
+ .setPreviousChunkHash(previousChunkHash)
210
+ .setMetadata(constantChunkMetadata);
211
+ clientStream.write(dataChunk, (streamErr) => {
212
+ if (streamErr != undefined) {
213
+ resolve((0, neverthrow_1.err)(new Error(`An error occurred sending data through the stream:\n${streamErr.message}`)));
214
+ }
215
+ });
216
+ previousChunkHash = this.computeHexHash(currentChunk);
217
+ }
218
+ clientStream.end(); // close the stream, no more data will be sent
219
+ });
220
+ const uploadStarlarkPackageResponseResult = yield uploadStarlarkPackagePromise;
221
+ if (uploadStarlarkPackageResponseResult.isErr()) {
222
+ return (0, neverthrow_1.err)(uploadStarlarkPackageResponseResult.error);
223
+ }
224
+ const uploadStarlarkPackageResponse = uploadStarlarkPackageResponseResult.value;
225
+ return (0, neverthrow_1.ok)(uploadStarlarkPackageResponse);
226
+ });
227
+ }
186
228
  storeWebFilesArtifact(storeWebFilesArtifactArgs) {
187
229
  return __awaiter(this, void 0, void 0, function* () {
188
230
  const storeWebFilesArtifactPromise = new Promise((resolve, _unusedReject) => {
@@ -1,6 +1,8 @@
1
1
  import { Result } from "neverthrow";
2
2
  export declare class KurtosisYaml {
3
3
  readonly name: string;
4
- constructor(name: string);
4
+ readonly description: string;
5
+ readonly packageReplaceOptions: Map<string, string>;
6
+ constructor(name: string, description: string, packageReplaceOptions: Map<string, string>);
5
7
  }
6
8
  export declare function parseKurtosisYaml(kurtosisYamlFilepath: string): Promise<Result<KurtosisYaml, Error>>;
@@ -16,8 +16,10 @@ const yaml = require("js-yaml");
16
16
  const enclave_context_1 = require("./enclave_context");
17
17
  const PACKAGES_URL = "https://docs.kurtosis.com/concepts-reference/packages";
18
18
  class KurtosisYaml {
19
- constructor(name) {
19
+ constructor(name, description, packageReplaceOptions) {
20
20
  this.name = name;
21
+ this.description = description;
22
+ this.packageReplaceOptions = packageReplaceOptions;
21
23
  }
22
24
  }
23
25
  exports.KurtosisYaml = KurtosisYaml;
@@ -4,5 +4,5 @@ exports.KURTOSIS_VERSION = void 0;
4
4
  // !!!!!!!!!!! DO NOT UPDATE! WILL BE MANUALLY UPDATED DURING THE RELEASE PROCESS !!!!!!!!!!!!!!!!!!!!!!
5
5
  // This is necessary so that Kurt Core consumers (e.g. modules) will know if they're compatible with the currently-running
6
6
  // API container
7
- exports.KURTOSIS_VERSION = "0.84.4";
7
+ exports.KURTOSIS_VERSION = "0.84.6";
8
8
  // !!!!!!!!!!! DO NOT UPDATE! WILL BE MANUALLY UPDATED DURING THE RELEASE PROCESS !!!!!!!!!!!!!!!!!!!!!!
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kurtosis-sdk",
3
3
  "//": "NOTE: DO NOT UPDATE THIS VERSION MANUALLY - IT WILL BE UPDATED DURING THE RELEASE PROCESS!",
4
- "version": "0.84.4",
4
+ "version": "0.84.6",
5
5
  "main": "./build/index",
6
6
  "description": "This repo contains a Typescript client for communicating with the Kurtosis Engine server, which is responsible for creating, managing and destroying Kurtosis Enclaves.",
7
7
  "types": "./build/index",