Repository navigation
completion: honor -p when listing VM names - #1218
Merged
Merged
Conversation
Cobra resolves ValidArgsFunction after parsing flags but without running PersistentPreRunE, which was the only place -p/--provider was copied into ONCTL_CLOUD. So `onctl -p ac destroy <TAB>` completed from ONCTL_CLOUD's provider instead, or exited "No Cloud Provider Set" when it was unset. Move the -p step into applyProviderFlag and call it from ensureProvider too, so every completion that lists VMs or sizes (destroy and aliases, ssh, port-forward, images, --type/--size) sees the flag. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
cdalar
enabled auto-merge (squash)
October 22, 2026 05:36
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1218 +/- ##
==========================================
+ Coverage 45.57% 45.70% +0.12%
==========================================
Files 75 75
Lines 8778 8783 +5
==========================================
+ Hits 4001 4014 +13
+ Misses 4777 4769 -8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Problem
onctl -p ac delete <TAB>did not complete VM names. Cobra's completion path (__complete) parses flags but skipsPersistentPreRunE, which was the only place-p/--providerwas copied intoONCTL_CLOUD. SoensureProviderresolved the provider from the environment instead:ONCTL_CLOUDunset: exits with "No Cloud Provider Set", no completions.ONCTL_CLOUDset to another provider: completes that provider's VM names.Exporting
ONCTL_CLOUD=acalways worked, which made it look ac-specific.Fix
Move the
-pvalidation andONCTL_CLOUDassignment intoapplyProviderFlag, called from bothPersistentPreRunEandensureProvider. This covers every completion that lists VMs or sizes: destroy and its aliases, ssh, port-forward, images, and the--type/--sizesize completions.Verification
TestEnsureProvider_HonorsProviderFlag:ONCTL_CLOUD=staticwithproviderFlag = "ac"must build the ac provider. Fails on the old code, passes now.containerCLI:onctl -p ac __complete delete ""returns the ac VM names withONCTL_CLOUDunset and with it set tostatic;-p bogusreturns the error directive.go test ./cmd/passes (one pre-existing, unrelated failure when run as root:TestPopulateOnctlEnv_ErrorWritingFileexpects a read-only dir write to fail).🤖 Generated with Claude Code