Repository navigation
feat(create): expose Hetzner config as CLI flags; drop required .onctl YAML - #918
Merged
Merged
Conversation
…d .onctl YAML onctl previously required a .onctl config dir (from `onctl init`) and fatally refused to run without it. For Hetzner, every setting that lived in hetzner.yaml / onctl.yaml is now a CLI flag with a default, so onctl works with no config files on disk. - setDefaults() (cmd/common.go): viper.SetDefault for all Hetzner + global keys (location=fsn1, vm.type=cpx21, vm.image=ubuntu-22.04, vm.username=root, ssh.publicKey/privateKey, vm.cloud-init.timeout=3m, actions.githubOwner). - Generic create flags --type/--location/--username/--cloud-init-timeout (+ existing --image), each viper.BindPFlag'd to the key the code already reads, so values flow through unchanged. Defaults match the old YAML. - Persistent --provider flag (overrides ONCTL_CLOUD); --github-owner on action. - Provider construction + config load moved from Execute() into rootCmd.PersistentPreRunE so it runs after flag parsing (flags can override config). Missing .onctl is now best-effort (logged), not fatal. - Remove embedded init/hetzner.yaml and init/onctl.yaml (defaults are in code). Other providers keep their YAML for now (separate follow-up). Credentials are unaffected (still env: HCLOUD_TOKEN, etc.). Adds flags_defaults_test.go covering flag existence, viper binding, and defaults. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013fQKc2HmtfdtBeKfXBXab6
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bbe4653e80
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
cdalar
force-pushed
the
feat/hetzner-flags-no-yaml
branch
from
June 19, 2026 11:24
684204d to
848728e
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #918 +/- ##
==========================================
+ Coverage 21.40% 22.41% +1.00%
==========================================
Files 41 42 +1
Lines 4031 4163 +132
==========================================
+ Hits 863 933 +70
- Misses 3059 3114 +55
- Partials 109 116 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
- Keep config errors fatal outside Hetzner by extracting initState() from PersistentPreRunE, matching the pre-flags behavior for aws/gcp/ azure/firecracker while still defaulting Hetzner when .onctl is missing. - Add ensureProvider() and skip __complete/__completeNoDesc in PersistentPreRunE so shell completion doesn't dereference a nil provider or fatally error when config is missing. - Fix TestCreateFlagsBindToViper flaking under randomized test order by loading an isolated empty config before asserting on viper defaults. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0181WDmhDAKfTzXfFUZFKGvM
cdalar
force-pushed
the
feat/hetzner-flags-no-yaml
branch
from
June 19, 2026 11:30
848728e to
2e8a77c
Compare
cdalar
added a commit
that referenced
this pull request
Jun 19, 2026
…racker → fc (#919) * feat(create): expose Firecracker config as CLI flags; drop firecracker.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 * refactor: rename the firecracker provider to fc 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 * docs(fc): add local testing guide for the fc provider rename 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 * fix(cmd): allow fc provider to run without .onctl config initState only let the hetzner provider skip a missing/unreadable config file. The fc provider now ships built-in defaults too (this PR), so it needs the same configless path or fresh `ONCTL_CLOUD=fc` runs abort before defaults/flags are applied. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gf7TpG2y985TySw8Pg7Cn3 --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Jun 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes
onctlusable for Hetzner with zero config files. Previouslyonctlrequired a.onctldirectory (fromonctl init) and fatally refused to run without it. Every setting that lived inhetzner.yaml/onctl.yamlis now a CLI flag with a default.Scope is Hetzner only this pass — AWS/GCP/Azure/Firecracker keep their YAML (separate follow-up).
What changed
setDefaults()(cmd/common.go):viper.SetDefaultfor all Hetzner + global keys —hetzner.location=fsn1,hetzner.vm.type=cpx21,hetzner.vm.image=ubuntu-22.04,hetzner.vm.username=root,ssh.publicKey/privateKey,vm.cloud-init.timeout=3m,actions.githubOwner=cdalar. Values identical to the old templates.--type,--location,--username,--cloud-init-timeout(plus existing--image), eachviper.BindPFlag'd to the key the rest of the code already reads — so values flow through unchanged with no churn to the ~40 read sites.--providerflag (overridesONCTL_CLOUD);--github-owneronaction.Execute()intorootCmd.PersistentPreRunE, so it runs after cobra parses flags (flags can override config). A missing.onctlis now best-effort (logged at DEBUG), not fatal.init/hetzner.yamlandinit/onctl.yaml(defaults now in code).onctl initstill scaffolds the other providers.Credentials are unaffected — still env (
HCLOUD_TOKEN,AWS_*, …).Why
Drives the onctl-runners controller (and onctl UX generally) without a per-VM/provider config file — e.g.
onctl create -n x --type cpx31 --location nbg1 --provider hetzner.Tests
go test ./...green. Newcmd/flags_defaults_test.gocovers flag existence, viper binding (override flows through), and defaults.HOME(no~/.onctl),onctl lsreaches the Hetzner API (invalid-token) instead of demandingonctl init.onctl create --helpshows the new flags.Suggested reviewer smoke test (real VM)
Out of scope
AWS/GCP/Azure/Firecracker flag conversion; the onctl-runners controller switch to
--type/--provider(follow-up once this ships).🤖 Generated with Claude Code
https://claude.ai/code/session_013fQKc2HmtfdtBeKfXBXab6