Skip to content

feat(cli): add -p short flag for --provider - #920

Merged
cdalar merged 4 commits into
mainfrom
feat/provider-short-flag-p
Jun 19, 2026
Merged

cdalar merged 4 commits into
mainfrom
feat/provider-short-flag-p

Conversation

@cdalar

@cdalar cdalar commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Summary

Adds -p as a global short flag for --provider. Because --provider lives on the persistent (root) flag set, Cobra panics if any subcommand redefines the -p shorthand — so the three colliding short flags were relocated.

Changes

  • --provider: now usable as -p globally
  • ssh --port: -p → -P (matches scp/sftp -P convention)
  • create --ssh-port: -p → -P
  • action --params: -p → -j
  • Updated flag assertions in ssh_test.go, create_test.go, action_test.go

Testing

  • go build clean (no shorthand-redefinition panic)
  • go test ./cmd/... passes
  • Verified --help for ssh/create/action/deploy resolves flags correctly

🤖 Generated with Claude Code

cdalar and others added 4 commits June 19, 2026 14:21
…r.yaml

Mirrors the Hetzner pass (#918) for Firecracker so the provider works with no
.onctl YAML:

- setDefaults(): firecracker.* defaults (kernelImage, rootfsImage, vcpuCount,
  memSizeMib, binPath, network.bridge/cidr, vm.username) matching the old
  firecracker.yaml. providerfirecracker.GetConfig still defaults these for
  direct package use; kernelImage/rootfsImage (which GetConfig left empty) now
  resolve to the conventional ~/.onctl paths with no config.
- create flags --kernel-image, --rootfs-image, --fc-binary, --vcpu, --memory
  bound to the firecracker.* keys read by GetConfig; the generic --username
  also drives firecracker.vm.username.
- Removed embedded internal/files/init/firecracker.yaml (`onctl init` no longer
  scaffolds it).
- flags_defaults_test.go covers the new flags' existence, viper binding, and
  defaults.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ha7EmqjjYwGC3f1wk41TE2
Renames the provider *identity* from `firecracker` to `fc` while keeping every
reference to the Firecracker technology/binary intact:

- Provider string: `--provider fc`, `ONCTL_CLOUD=fc`, cloudProviderList entry.
- Config keys: firecracker.* -> fc.* (e.g. fc.kernelImage, fc.vcpuCount,
  fc.network.bridge, fc.vm.username).
- Package internal/providerfirecracker -> internal/providerfc.
- Exported Go types: ProviderFirecracker->ProviderFC, FirecrackerConfig->FCConfig,
  FirecrackerVMConfig->FCVMConfig, FirecrackerProcess->FCProcess,
  FirecrackerAPI->FCAPI (plus unexported helpers: firecrackerRequest->fcRequest,
  firecrackerStatus*->fcStatus*, defaultFirecrackerKernelArgs->defaultFCKernelArgs,
  firecrackerMAC/TapName/VM, parseFirecrackerType, load/saveFirecrackerMetadata,
  allocateFirecrackerIP, and the test helpers).
- Files pkg/cloud/firecracker.go -> fc.go, firecracker_test.go -> fc_test.go.
- README provider name + ONCTL_CLOUD updated.

Deliberately KEPT (these name the Firecracker technology, not the provider):
- the literal `firecracker` binary name (fc.binPath default),
- the ~/.onctl/firecracker image/state directory paths (so existing image
  layouts keep working),
- comments/strings describing the Firecracker API, VMM and microVMs,
- the firecracker/firecracker-host-setup.sh template path in the README.

go build / go vet / go test ./... all green; gofmt clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ha7EmqjjYwGC3f1wk41TE2
Walkthrough for testing this branch on a GCP fc-host VM: building/copying the
binary, running create/pause/resume/destroy against the new `fc` provider and
flags, and confirming the old `firecracker` provider name is rejected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ha7EmqjjYwGC3f1wk41TE2
Make --provider a globally usable short flag (-p) on the persistent
root flag set. Since Cobra panics when a subcommand redefines a
persistent shorthand, relocate the colliding short flags:

- ssh --port:      -p -> -P (matches scp/sftp -P convention)
- create --ssh-port: -p -> -P
- action --params:   -p -> -j

Update flag assertions in the affected tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EGdJJHgKUfLaNTJd5JbeXg
@cdalar
cdalar changed the base branch from firecracker-flags-no-yaml to main June 19, 2026 13:01
@cdalar
cdalar merged commit c1124b2 into main Jun 19, 2026
6 checks passed
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.

1 participant

⌂ 换网址