gigadrive 2.9.0 → 2.10.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.9.0",
35
+ version: "2.10.1",
36
36
  repository: {
37
37
  type: "git",
38
38
  url: "https://github.com/Gigadrive/sdk.git",
@@ -3072,7 +3072,7 @@ var describeMicroVm = (vm, now = Date.now()) => {
3072
3072
  `Image: ${vm.image.name}`,
3073
3073
  `Size: ${vm.vcpus} vCPU, ${formatMemory(vm.memoryMb)} memory, ${formatMemory(vm.diskMb)} disk`,
3074
3074
  `Region: ${vm.region}`,
3075
- `Network: ${vm.network.egress === "deny" ? "outbound traffic blocked" : "internet access"}`,
3075
+ `Network: ${vm.network.egress === "deny" ? "outbound traffic blocked" : vm.network.allow && vm.network.allow.length > 0 ? `only ${vm.network.allow.join(", ")} (and DNS)` : "internet access"}`,
3076
3076
  `Previews: ${vm.network.previews === "private" ? "private (preview token required)" : "public"}`,
3077
3077
  `Application: ${vm.applicationId}`,
3078
3078
  `Created: ${vm.createdAt}`
@@ -3340,6 +3340,20 @@ var createInput = (flags) => import_effect24.Effect.gen(function* () {
3340
3340
  onNone: () => import_effect24.Effect.succeed(void 0),
3341
3341
  onSome: (text) => parseLifetime("--timeout", text)
3342
3342
  });
3343
+ if (flags.denyEgress && flags.allowEgress.length > 0) {
3344
+ return yield* new InvalidMicroVmOptionsError({
3345
+ message: "--allow-egress cannot be combined with --deny-egress."
3346
+ });
3347
+ }
3348
+ if (flags.allowEgress.length > 32) {
3349
+ return yield* new InvalidMicroVmOptionsError({ message: "--allow-egress takes at most 32 networks." });
3350
+ }
3351
+ const badNetwork = flags.allowEgress.find((network) => !/^\d{1,3}(\.\d{1,3}){3}\/\d{1,2}$/.test(network.trim()));
3352
+ if (badNetwork !== void 0) {
3353
+ return yield* new InvalidMicroVmOptionsError({
3354
+ message: `--allow-egress must be an IPv4 network such as 140.82.112.0/20 (got ${badNetwork}).`
3355
+ });
3356
+ }
3343
3357
  const badPort = flags.ports.find((port) => !Number.isInteger(port) || port < 1 || port > 65535);
3344
3358
  if (badPort !== void 0) {
3345
3359
  return yield* new InvalidMicroVmOptionsError({ message: `--port must be between 1 and 65535 (got ${badPort}).` });
@@ -3358,10 +3372,11 @@ var createInput = (flags) => import_effect24.Effect.gen(function* () {
3358
3372
  ...flags.ports.length > 0 ? { ports: [...flags.ports] } : {},
3359
3373
  ...env ? { env } : {},
3360
3374
  ...metadata ? { metadata } : {},
3361
- ...flags.denyEgress || flags.privatePreviews ? {
3375
+ ...flags.denyEgress || flags.privatePreviews || flags.allowEgress.length > 0 ? {
3362
3376
  network: {
3363
3377
  egress: flags.denyEgress ? "deny" : "allow",
3364
- ...flags.privatePreviews ? { previews: "private" } : {}
3378
+ ...flags.privatePreviews ? { previews: "private" } : {},
3379
+ ...flags.allowEgress.length > 0 ? { allow: [...flags.allowEgress] } : {}
3365
3380
  }
3366
3381
  } : {},
3367
3382
  ...import_effect24.Option.match(flags.region, { onNone: () => ({}), onSome: (region) => ({ region }) })
@@ -3427,6 +3442,12 @@ var createCommand = import_cli12.Command.make(
3427
3442
  privatePreviews: import_cli12.Options.boolean("private-previews").pipe(
3428
3443
  import_cli12.Options.withDescription("Answer preview URLs only to requests that carry the preview token printed at create")
3429
3444
  ),
3445
+ allowEgress: import_cli12.Options.text("allow-egress").pipe(
3446
+ import_cli12.Options.withDescription(
3447
+ "Only reach this public IPv4 network, such as 140.82.112.0/20, besides DNS (repeatable, up to 32)"
3448
+ ),
3449
+ import_cli12.Options.repeated
3450
+ ),
3430
3451
  region: import_cli12.Options.text("region").pipe(import_cli12.Options.withDescription("Region to place the microVM in"), import_cli12.Options.optional),
3431
3452
  json: jsonOption2
3432
3453
  },