port smoke to go
This commit is contained in:
parent
b0a9d64f4a
commit
9ed44bfd75
20 changed files with 2118 additions and 1573 deletions
|
|
@ -35,8 +35,11 @@ provisions ssh, and drops you into the guest in one command. Use
|
|||
longer-lived VM you'll come back to.
|
||||
|
||||
Quick reference:
|
||||
banger vm run ephemeral sandbox; --rm to delete on exit
|
||||
banger vm run ./repo -- make test ship a repo, run a command, exit
|
||||
banger vm run interactive sandbox (stays alive on disconnect)
|
||||
banger vm run --rm -- script.sh ephemeral: VM auto-deletes on exit
|
||||
banger vm run ./repo -- make test ship a repo, run a command, exit with its status
|
||||
banger vm run --nat ./repo --nat: outbound internet (required for mise bootstrap)
|
||||
banger vm run -d ./repo --nat -d/--detach: prep + bootstrap, exit (no ssh attach)
|
||||
banger vm create --name dev persistent VM; pair with 'vm ssh'
|
||||
banger vm ssh <name> open a shell in a running VM
|
||||
banger vm exec <name> -- make test run a command in the workspace with mise toolchain
|
||||
|
|
@ -45,6 +48,7 @@ Quick reference:
|
|||
banger vm delete <name> stop + remove disks
|
||||
banger ps / banger vm list running / all VMs (use --all)
|
||||
banger vm logs <name> guest console + daemon log
|
||||
banger vm set --nat <name> toggle NAT on an existing VM (--no-nat to remove)
|
||||
banger vm workspace prepare/export ship a repo in, pull diffs back
|
||||
`),
|
||||
Example: strings.TrimSpace(`
|
||||
|
|
@ -93,6 +97,7 @@ func (d *deps) newVMRunCommand() *cobra.Command {
|
|||
dryRun bool
|
||||
detach bool
|
||||
skipBootstrap bool
|
||||
verbose bool
|
||||
)
|
||||
cmd := &cobra.Command{
|
||||
Use: "run [path] [-- command args...]",
|
||||
|
|
@ -103,14 +108,33 @@ Create a sandbox VM and either drop into an interactive shell or run a command.
|
|||
Modes:
|
||||
banger vm run bare sandbox, drops into ssh
|
||||
banger vm run ./repo workspace sandbox, drops into ssh at /root/repo
|
||||
banger vm run ./repo -- make test workspace, runs command, exits with its status
|
||||
banger vm run -d ./repo workspace + bootstrap, exit (no ssh attach)
|
||||
banger vm run ./repo -- make test workspace + run command, exit with its status
|
||||
banger vm run --rm -- script.sh ephemeral: VM auto-deletes when the session/command exits
|
||||
banger vm run -d ./repo workspace + bootstrap, exit (reconnect with 'vm ssh')
|
||||
|
||||
Workspace mode (path argument):
|
||||
Passing a path copies the repo's git-tracked files into /root/repo
|
||||
inside the guest. Untracked files are skipped by default — pass
|
||||
--include-untracked to ship them too, or --dry-run to preview the
|
||||
file list without creating a VM.
|
||||
|
||||
Outbound internet (--nat):
|
||||
Guests have no internet access by default. Pass --nat to enable
|
||||
host-side MASQUERADE so the VM can reach the public network. NAT is
|
||||
required whenever the workspace declares mise tooling (see below).
|
||||
Toggle on an existing VM with 'banger vm set --nat <name>'.
|
||||
|
||||
Tooling bootstrap (workspace mode):
|
||||
When the workspace contains a .mise.toml or .tool-versions, vm run
|
||||
installs the listed tools via mise on first boot. The bootstrap
|
||||
needs internet, so --nat must be set. Pass --no-bootstrap to skip
|
||||
it entirely (no NAT requirement).
|
||||
|
||||
Exit behaviour:
|
||||
In command mode (-- <cmd>), the guest command's exit code propagates
|
||||
through banger. Without --rm, the VM stays alive after the session
|
||||
or command exits — reconnect with 'banger vm ssh <name>'. With --rm,
|
||||
the VM is deleted on exit (stdout/stderr are preserved).
|
||||
`),
|
||||
Args: cobra.ArbitraryArgs,
|
||||
Example: strings.TrimSpace(`
|
||||
|
|
@ -190,7 +214,7 @@ Tooling bootstrap (workspace mode):
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return d.runVMRun(cmd.Context(), layout.SocketPath, cfg, cmd.InOrStdin(), cmd.OutOrStdout(), cmd.ErrOrStderr(), params, repoPtr, commandArgs, removeOnExit, detach, skipBootstrap)
|
||||
return d.runVMRun(cmd.Context(), layout.SocketPath, cfg, cmd.InOrStdin(), cmd.OutOrStdout(), cmd.ErrOrStderr(), params, repoPtr, commandArgs, removeOnExit, detach, skipBootstrap, verbose)
|
||||
},
|
||||
}
|
||||
cmd.Flags().StringVar(&name, "name", "", "vm name")
|
||||
|
|
@ -199,14 +223,15 @@ Tooling bootstrap (workspace mode):
|
|||
cmd.Flags().IntVar(&memory, "memory", defaults.MemoryMiB, "memory in MiB")
|
||||
cmd.Flags().StringVar(&systemOverlaySize, "system-overlay-size", model.FormatSizeBytes(defaults.SystemOverlaySizeByte), "system overlay size")
|
||||
cmd.Flags().StringVar(&workDiskSize, "disk-size", model.FormatSizeBytes(defaults.WorkDiskSizeBytes), "work disk size")
|
||||
cmd.Flags().BoolVar(&natEnabled, "nat", false, "enable NAT")
|
||||
cmd.Flags().BoolVar(&natEnabled, "nat", false, "enable outbound internet from the guest (host-side MASQUERADE; required when the workspace declares mise tooling)")
|
||||
cmd.Flags().StringVar(&branchName, "branch", "", "create and switch to a new guest branch")
|
||||
cmd.Flags().StringVar(&fromRef, "from", "HEAD", "git ref to branch from when --branch is set (default: HEAD)")
|
||||
cmd.Flags().BoolVar(&removeOnExit, "rm", false, "delete the VM after the ssh session / command exits")
|
||||
cmd.Flags().BoolVar(&removeOnExit, "rm", false, "ephemeral mode: delete the VM (and its disks) after the ssh session / command exits")
|
||||
cmd.Flags().BoolVar(&includeUntracked, "include-untracked", false, "also copy untracked non-ignored files into the guest workspace (default: tracked files only)")
|
||||
cmd.Flags().BoolVar(&dryRun, "dry-run", false, "list the files that would be copied into the guest workspace and exit without creating a VM")
|
||||
cmd.Flags().BoolVarP(&detach, "detach", "d", false, "create the VM, prep workspace + bootstrap, exit without attaching to ssh")
|
||||
cmd.Flags().BoolVarP(&detach, "detach", "d", false, "detached mode: create the VM, run workspace prep + bootstrap synchronously, exit without ssh attach (reconnect with 'vm ssh')")
|
||||
cmd.Flags().BoolVar(&skipBootstrap, "no-bootstrap", false, "skip the mise tooling bootstrap (no --nat requirement)")
|
||||
cmd.Flags().BoolVarP(&verbose, "verbose", "v", false, "show every progress line instead of a single rewriting status line")
|
||||
_ = cmd.RegisterFlagCompletionFunc("image", d.completeImageNames)
|
||||
return cmd
|
||||
}
|
||||
|
|
@ -370,6 +395,7 @@ func (d *deps) newVMCreateCommand() *cobra.Command {
|
|||
workDiskSize = model.FormatSizeBytes(defaults.WorkDiskSizeBytes)
|
||||
natEnabled bool
|
||||
noStart bool
|
||||
verbose bool
|
||||
)
|
||||
cmd := &cobra.Command{
|
||||
Use: "create",
|
||||
|
|
@ -397,7 +423,7 @@ Use 'vm create' for a longer-lived VM you'll come back to. Use
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
vm, err := d.runVMCreate(cmd.Context(), layout.SocketPath, cmd.ErrOrStderr(), params)
|
||||
vm, err := d.runVMCreate(cmd.Context(), layout.SocketPath, cmd.ErrOrStderr(), params, verbose)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -410,8 +436,9 @@ Use 'vm create' for a longer-lived VM you'll come back to. Use
|
|||
cmd.Flags().IntVar(&memory, "memory", defaults.MemoryMiB, "memory in MiB")
|
||||
cmd.Flags().StringVar(&systemOverlaySize, "system-overlay-size", model.FormatSizeBytes(defaults.SystemOverlaySizeByte), "system overlay size")
|
||||
cmd.Flags().StringVar(&workDiskSize, "disk-size", model.FormatSizeBytes(defaults.WorkDiskSizeBytes), "work disk size")
|
||||
cmd.Flags().BoolVar(&natEnabled, "nat", false, "enable NAT")
|
||||
cmd.Flags().BoolVar(&natEnabled, "nat", false, "enable outbound internet from the guest (host-side MASQUERADE)")
|
||||
cmd.Flags().BoolVar(&noStart, "no-start", false, "create without starting")
|
||||
cmd.Flags().BoolVarP(&verbose, "verbose", "v", false, "show every progress line instead of a single rewriting status line")
|
||||
_ = cmd.RegisterFlagCompletionFunc("image", d.completeImageNames)
|
||||
return cmd
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue