gigadrive 2.16.0 → 2.17.1

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.
package/dist/index.cjs CHANGED
@@ -32,7 +32,7 @@ var import_effect31 = require("effect");
32
32
  // package.json
33
33
  var package_default = {
34
34
  name: "gigadrive",
35
- version: "2.16.0",
35
+ version: "2.17.1",
36
36
  repository: {
37
37
  type: "git",
38
38
  url: "https://github.com/Gigadrive/sdk.git",
@@ -3394,7 +3394,7 @@ var parseInjectFlags = (values) => import_effect24.Effect.gen(function* () {
3394
3394
  if (domain === "" || name === "" || equals === value.length - 1) {
3395
3395
  return yield* new InvalidMicroVmOptionsError({
3396
3396
  // The entry is not echoed: it may hold the credential.
3397
- message: '--inject must be DOMAIN:HEADER=VALUE, such as "api.openai.com:Authorization=Bearer $OPENAI_API_KEY".'
3397
+ message: '--inject and --inject-file take DOMAIN:HEADER=VALUE, such as "api.openai.com:Authorization=Bearer $OPENAI_API_KEY".'
3398
3398
  });
3399
3399
  }
3400
3400
  rules.set(domain, { ...rules.get(domain), [name]: value.slice(equals + 1) });
@@ -3404,6 +3404,17 @@ var parseInjectFlags = (values) => import_effect24.Effect.gen(function* () {
3404
3404
  }
3405
3405
  return [...rules].map(([domain, headers]) => ({ domain, headers }));
3406
3406
  });
3407
+ var readInjectRules = (inject, injectFile) => import_effect24.Effect.gen(function* () {
3408
+ if (import_effect24.Option.isNone(injectFile)) return yield* parseInjectFlags(inject);
3409
+ const fs = yield* import_platform8.FileSystem.FileSystem;
3410
+ const content = yield* fs.readFileString(injectFile.value).pipe(
3411
+ import_effect24.Effect.mapError(
3412
+ () => new InvalidMicroVmOptionsError({ message: `Could not read --inject-file ${injectFile.value}.` })
3413
+ )
3414
+ );
3415
+ const lines = content.split(/\r?\n/).map((line) => line.trim()).filter((line) => line !== "" && !line.startsWith("#"));
3416
+ return yield* parseInjectFlags([...inject, ...lines]);
3417
+ });
3407
3418
  var checkEgressFlags = (denyEgress, allowEgress) => import_effect24.Effect.gen(function* () {
3408
3419
  if (denyEgress && allowEgress.length > 0) {
3409
3420
  return yield* new InvalidMicroVmOptionsError({
@@ -3434,7 +3445,7 @@ var createInput = (flags) => import_effect24.Effect.gen(function* () {
3434
3445
  if (badPort !== void 0) {
3435
3446
  return yield* new InvalidMicroVmOptionsError({ message: `--port must be between 1 and 65535 (got ${badPort}).` });
3436
3447
  }
3437
- const inject = yield* parseInjectFlags(flags.inject);
3448
+ const inject = yield* readInjectRules(flags.inject, flags.injectFile);
3438
3449
  if (inject.length > 0 && flags.denyEgress) {
3439
3450
  return yield* new InvalidMicroVmOptionsError({ message: "--inject cannot be combined with --deny-egress." });
3440
3451
  }
@@ -3561,6 +3572,12 @@ var createCommand = import_cli12.Command.make(
3561
3572
  ),
3562
3573
  import_cli12.Options.repeated
3563
3574
  ),
3575
+ injectFile: import_cli12.Options.text("inject-file").pipe(
3576
+ import_cli12.Options.withDescription(
3577
+ "Read --inject rules from a file, one DOMAIN:HEADER=VALUE per line (/dev/stdin for a pipe), so the values stay out of the command line"
3578
+ ),
3579
+ import_cli12.Options.optional
3580
+ ),
3564
3581
  pauseOnTimeout: import_cli12.Options.boolean("pause-on-timeout").pipe(
3565
3582
  import_cli12.Options.withDescription("Pause the microVM when its timeout ends instead of stopping it")
3566
3583
  ),
@@ -3930,7 +3947,7 @@ var updateMicroVmNetwork = (microvmId, flags) => import_effect24.Effect.gen(func
3930
3947
  });
3931
3948
  }
3932
3949
  yield* checkEgressFlags(flags.denyEgress, flags.allowEgress);
3933
- const inject = yield* parseInjectFlags(flags.inject);
3950
+ const inject = yield* readInjectRules(flags.inject, flags.injectFile);
3934
3951
  if (inject.length > 0 && flags.denyEgress) {
3935
3952
  return yield* new InvalidMicroVmOptionsError({ message: "--inject cannot be combined with --deny-egress." });
3936
3953
  }
@@ -3977,6 +3994,12 @@ var networkCommand = import_cli12.Command.make(
3977
3994
  ),
3978
3995
  import_cli12.Options.repeated
3979
3996
  ),
3997
+ injectFile: import_cli12.Options.text("inject-file").pipe(
3998
+ import_cli12.Options.withDescription(
3999
+ "Read --inject rules from a file, one DOMAIN:HEADER=VALUE per line (/dev/stdin for a pipe), so the values stay out of the command line"
4000
+ ),
4001
+ import_cli12.Options.optional
4002
+ ),
3980
4003
  clearInject: import_cli12.Options.boolean("clear-inject").pipe(
3981
4004
  import_cli12.Options.withDescription("Remove every header rule added with --inject")
3982
4005
  )