Repository navigation
rpk-k8s: report command flags in --help-autocomplete - #2021
Open
JakeSCahill wants to merge 1 commit into
Open
JakeSCahill wants to merge 1 commit into
JakeSCahill wants to merge 1 commit into
Conversation
rpk builds the reference docs for plugin commands from the
--help-autocomplete output, which carried no flag metadata. Each entry
now has a flags array in the shape rpk prints for its own flags in
--print-tree: local, non-hidden flags with typed defaults.
args now lists the command's flag names ("--name") for completion, as
rpk expects. It used to carry ValidArgs, which no rpk-k8s command sets,
so it was always null. Cobra's help and completion commands are skipped
if they are ever present in the walk.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
JakeSCahill
marked this pull request as ready for review
October 27, 2026 09:43
JakeSCahill
requested review from
RafalKorepta,
andrewstucki,
chrisseto,
gene-redpanda and
hidalgopl
as code owners
October 27, 2026 09:43
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.
Each
--help-autocompleteentry fromrpk-k8snow carries aflagsarray: the command's own flags (cmd.LocalFlags(), hidden flags andhelpskipped), in the shaperpk --print-treeuses for rpk's flags. With https://github.com/redpanda-data/streaming-enterprise/pull/1134, rpk includes these in--print-tree, so the docs no longer parserpk k8s ... --helptext. Tracking: https://redpandadata.atlassian.net/browse/DOC-2689.Also fixes
args. It wascmd.ValidArgs, which no rpk-k8s command sets, so rpk got no flag completion forrpk k8s. It now lists the command's flag names (local, then inherited), as rpai does.The walk also skips cobra's
helpandcompletioncommands by name. Today they can't appear, because cobra adds them insideExecute.Tested:
TestCollectHelpsFlagscovers typed defaults (bool, int, duration, stringSlice, string), shorthand, required and deprecated, hidden flags and commands, a persistent flag listed only on its root,[]for a command with no flags, and theargsfix.GOLANG_PROTOBUF_REGISTRATION_CONFLICT=ignore go test ./cmd/rpk-k8s/passes. With main'smain.gothe test fails.multicluster status(5 flags) andmulticluster bundle(14 flags) match their--help.task lint.gofmtis clean.