Skip to content

feat(cli): expose --disk-size / --network / --entrypoint flags - #620

Merged
DorianZheng merged 2 commits into
boxlite-ai:mainfrom
G4614:feat/disk-size-cli
Jun 15, 2026
Merged

DorianZheng merged 2 commits into
boxlite-ai:mainfrom
G4614:feat/disk-size-cli

Conversation

@G4614

@G4614 G4614 commented May 28, 2026 •

Copy link
Copy Markdown
Contributor

Adds three boxlite run / create flags that the runtime and REST API already supported but the CLI never exposed.

  • --disk-size <GB>
  • --network <enabled|disabled> + --allow-net <HOST> (repeatable)
  • --entrypoint <EXEC>

Both run and create get all three.

Test plan

10 unit tests on the flag → BoxOptions plumbing (src/cli/src/cli.rs), each crossing the real apply_to boundary (value comes from the flag struct, not the assertion):

flag tests
--disk-size ..._plumbed (Some(10) verbatim), ..._default_unset (None)
--network / --allow-net ..._default_left_untouched, ..._disabled, ..._allow_net_implies_enabled, ..._disabled_with_allow_net_is_rejected, ..._invalid_mode_is_rejected
--entrypoint ..._override (Some(vec!["/bin/bash"])), ..._default_none (None)

Verification (this host):

  • cargo nextest run -p boxlite-cli -E 'test(network_flags) or test(entrypoint) or test(resource_flags) or test(disk_size)' — 10 passed.
  • make cli builds clean; make fmt:check:rust + cargo clippy -p boxlite-cli --bins --tests clean.

Before, these knobs were REST/SDK-only; after, boxlite run / create expose them with the same validation as the REST path.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added --entrypoint flag to override container entrypoint configuration.
    • Added --disk-size flag to specify container disk allocation (in GB).
    • Added --network flag to control network mode and --allow-net flag for allowlist-based network access.
  • Tests

    • Added and updated tests for new CLI flags and network configuration validation.

@G4614 G4614 changed the title feat(cli): expose --disk-size <GB> for boxlite run feat(cli): expose --disk-size / --network / --entrypoint flags May 28, 2026
@G4614
G4614 marked this pull request as ready for review May 28, 2026 13:31
@G4614
G4614 force-pushed the feat/disk-size-cli branch from 6ad67f5 to 32697d4 Compare June 1, 2026 04:22
G4614 and others added 2 commits June 2, 2026 05:19
Adds the `--disk-size <GB>` CLI flag for `boxlite run` (and any
subcommand that flattens `ResourceFlags`), wired straight into
`BoxOptions.disk_size_gb`. The field already existed end-to-end
in the runtime (`src/boxlite/src/runtime/options.rs:324` →
`src/boxlite/src/litebox/init/tasks/container_rootfs.rs::create_cow_disk`
sizes the COW overlay to `max(user_size, base_image_size)`) but was
only reachable via the REST API. CLI users had no way to grow the
writable rootfs past the base image, which is fine for one-shot
workloads but immediately ENOSPCs for anything that pulls multiple
images, runs `apt install`, builds wheels, or otherwise writes more
than a few hundred MB inside the box.

The motivating consumer is the agent-workflow dind integration
tests added in a follow-up commit — they need 5-10 GB of in-box
disk for sequential `docker pull`s, named-volume writes, and
container-lifecycle scratch. Without this flag those tests would
silently fail mid-pull and the breakage would look like a flaky
registry, not a missing size declaration.

Two new lib unit tests pin:
  - `--disk-size 10` reaches `BoxOptions.disk_size_gb`
    verbatim through `ResourceFlags::apply_to`
  - omitting the flag leaves `disk_size_gb = None`, preserving
    the documented "size to base image" default and guarding
    against a refactor that injects a fallback (`unwrap_or(N)`)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two more runtime knobs that were reachable over REST/SDK but had no CLI
flag, wired the same plumbing-only way as --disk-size:

- `--network <enabled|disabled>` + `--allow-net <HOST>` (repeatable):
  builds NetworkConfig{mode, allow_net} → NetworkSpec::try_from, exactly
  mirroring the REST build_box_options mapping (single source of truth,
  including the disabled+allow_net rejection). `--network disabled` gives
  a no-eth0 box; `--allow-net` sets an egress allowlist (implies enabled).
- `--entrypoint <EXEC>`: overrides the image entrypoint as a single-token
  argv → BoxOptions.entrypoint, which container_rootfs applies as
  config.entrypoint. Mirrors `docker run --entrypoint`.

Both run and create get the flags (NetworkFlags flattened in each;
entrypoint via ProcessFlags for run and a standalone arg for create).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@G4614
G4614 force-pushed the feat/disk-size-cli branch from 32697d4 to 367fbec Compare June 2, 2026 05:23
@G4614
G4614 marked this pull request as draft June 8, 2026 06:17
@DorianZheng
DorianZheng marked this pull request as ready for review June 15, 2026 12:31
@DorianZheng
DorianZheng requested a review from a team June 15, 2026 12:31
@DorianZheng
DorianZheng enabled auto-merge June 15, 2026 12:32
@DorianZheng
DorianZheng disabled auto-merge June 15, 2026 12:32
@coderabbitai

coderabbitai Bot commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 69247c1a-b03e-4e8a-a332-6c905c469411

📥 Commits

Reviewing files that changed from the base of the PR and between a438d6b and 367fbec.

📒 Files selected for processing (3)
  • src/cli/src/cli.rs
  • src/cli/src/commands/create.rs
  • src/cli/src/commands/run.rs

📝 Walkthrough

Walkthrough

Three new CLI flag groups are added: --entrypoint on ProcessFlags, --disk-size on ResourceFlags, and a new NetworkFlags struct with --network/--allow-net. All three are wired into CreateArgs and RunArgs, with NetworkFlags.apply_to building BoxOptions.network via NetworkSpec::try_from. Unit tests cover all new paths.

Changes

CLI flag additions and command wiring

Layer / File(s) Summary
NetworkFlags struct and apply_to logic
src/cli/src/cli.rs
Adds NetworkSpec import and defines the NetworkFlags struct with network and allow_net fields; apply_to short-circuits when no flags are set, otherwise parses the mode (defaulting to enabled) and constructs BoxOptions.network via NetworkSpec::try_from, returning an error on invalid combinations or modes.
--entrypoint and --disk-size additions
src/cli/src/cli.rs
Adds entrypoint: Option<String> to ProcessFlags and updates apply_to to write it as a single-element vector into BoxOptions.entrypoint; adds disk_size_gb: Option<u64> to ResourceFlags and plumbs it into BoxOptions.disk_size_gb.
Wiring into create and run commands
src/cli/src/commands/create.rs, src/cli/src/commands/run.rs
CreateArgs gains a flattened NetworkFlags and an optional entrypoint field; to_box_options calls network.apply_to and sets the entrypoint override. RunArgs gains a flattened NetworkFlags; BoxRunner::create_box calls apply_to for network settings.
Unit tests
src/cli/src/cli.rs
Updates the existing ResourceFlags CPU cap test to include disk_size_gb: None; adds new tests for disk size set/unset, NetworkFlags no-op default, disabled mode, allow-net implying enabled, contradiction and invalid-mode rejection, and entrypoint set/unset behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 Hop, hop, the network flag springs to life,
A disk size grows, entrypoints end all strife.
apply_to checks — no flags? no fuss!
Each BoxOptions field boards the right bus.
Tests green, the warren is tidy and bright. 🌿

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@DorianZheng
DorianZheng merged commit 5f93780 into boxlite-ai:main Jun 15, 2026
23 of 24 checks passed
@G4614
G4614 deleted the feat/disk-size-cli branch July 23, 2026 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants