CNTRLPLANE-2600: docs: cli flags doc generater#7564
CNTRLPLANE-2600: docs: cli flags doc generater#7564devguyio wants to merge 3 commits intoopenshift:mainfrom
Conversation
Add a new `hypershift docs generate` command that generates markdown documentation comparing CLI flags between hcp and hypershift CLIs. The generator extracts flags from both CLIs and shows per-CLI availability and required status in the output. Generated with Claude Code Co-Authored-By: Claude Opus 4.5 (claude-opus-4-5-20251101) <noreply@anthropic.com> Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>
These flags were already effectively required through runtime validation but were not marked using cobra's MarkPersistentFlagRequired. This change makes the requirement explicit, enabling better CLI help output and allowing the doc generator to detect required flags via annotations. Generated with Claude Code Co-Authored-By: Claude Opus 4.5 (claude-opus-4-5-20251101) <noreply@anthropic.com> Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>
Generated by running `make cli-docs`. Adds CLI flag documentation for the `create cluster aws` command, comparing hcp and hypershift CLIs and showing flag availability and required status for each. Generated with Claude Code Co-Authored-By: Claude Opus 4.5 (claude-opus-4-5-20251101) <noreply@anthropic.com> Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>
|
@devguyio: This pull request references CNTRLPLANE-2600 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
Important Review skippedAuto reviews are limited based on label configuration. 🚫 Review skipped — only excluded labels are configured. (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
|
Skipping CI for Draft Pull Request. |
|
@devguyio: This pull request references CNTRLPLANE-2600 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
@devguyio: This pull request references CNTRLPLANE-2600 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
1 similar comment
|
@devguyio: This pull request references CNTRLPLANE-2600 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: devguyio The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/test ? |
|
@devguyio: The following commands are available to trigger required jobs: The following commands are available to trigger optional jobs: Use DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/test docs-preview |
|
@devguyio: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
@devguyio: This pull request references CNTRLPLANE-2600 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
/auto-cc |
jparrill
left a comment
There was a problem hiding this comment.
Thanks for the PR. Overall looks good. Some minor nits dropped
| for name, flag := range hypershiftFlags { | ||
| if existing, ok := merged[name]; ok { | ||
| existing.InHypershift = true | ||
| // RequiredInHypershift comes from hypershift CLI's annotation | ||
| existing.RequiredInHypershift = flag.RequiredInHcp // addFlagToMap sets both fields the same | ||
| } else { | ||
| f := *flag | ||
| f.InHypershift = true | ||
| // This flag is only in hypershift, so RequiredInHcp should be false | ||
| f.RequiredInHypershift = f.RequiredInHcp // Move to correct field | ||
| f.RequiredInHcp = false | ||
| merged[name] = &f | ||
| } | ||
| } |
There was a problem hiding this comment.
When processing hypershift flags, you uses flag.RequiredInHcp instead of flag.RequiredInHypershift:
existing.RequiredInHypershift = flag.RequiredInHcp// line 234f.RequiredInHypershift = f.RequiredInHcp// line 239
It Works because addFlagToMap sets both fields to the same value, but it's confusing and error-prone if addFlagToMap changes.
Do you mind use flag.RequiredInHypershift explicitly?
| ### {{ .Name }} | ||
| {{ if .Description }} | ||
| {{ .Description }} | ||
| {{ end }} | ||
| | Flag | Type | Default | hcp | hypershift | Description | | ||
| |------|------|---------|:---:|:----------:|-------------| | ||
| {{- range .Flags }} | ||
| {{- if eq $cat.Name "Required" }} | ||
| | `--{{ .Name }}` | {{ .Type }} | {{ if .Default }}`{{ .Default }}`{{ end }} | {{ if .RequiredInHcp }}✓{{ else if .InHcp }}Optional{{ else }}Unavailable{{ end }} | {{ if .RequiredInHypershift }}✓{{ else if .InHypershift }}Optional{{ else }}Unavailable{{ end }} | {{ .Description }} | | ||
| {{- else }} | ||
| | `--{{ .Name }}` | {{ .Type }} | {{ if .Default }}`{{ .Default }}`{{ end }} | {{ if .InHcp }}✓{{ end }} | {{ if .InHypershift }}✓{{ end }} | {{ .Description }} | | ||
| {{- end }} | ||
| {{- end }} |
There was a problem hiding this comment.
Not sure why you use {{ cat.Name }} vs {{ .Name }}? are those different? if not could we just use one?
|
PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
What this PR does / why we need it:
Background
The hcp (product/customer) and hypershift (developer/internal) CLIs share underlying code but expose different sets of flags. This creates several challenges:
--nameand--pull-secret) were validated as required at runtime but not marked as such in cobra, making it impossible to auto-detect requirementsSolution
This PR introduces a CLI flag documentation generator that:
MarkFlagRequiredandMarkPersistentFlagRequiredannotations instead of hardcodingcategories.go(AWS Infrastructure, Cluster Identity, Security, Networking, etc.) for better readabilitymake cli-docstarget (included inmake update)Changes
New
hypershift docs generatecommand (cmd/docs/):generate.go- Main generator logic, extracts flags from both CLIs by walking the cobra command treetypes.go-FlagInfostruct withRequiredInHcpandRequiredInHypershiftfields for per-CLI trackingcategories.go- Flag categorization (AWS Infrastructure, Cluster Identity, Security, etc.)templates/aws.md.tmpl- Template with three-state display for Required sectiongenerate_test.go- 27 unit tests covering flag extraction, merging, and required detectionRequired flag annotations (
cmd/cluster/cluster.go,product-cli/cmd/cluster/cluster.go):MarkPersistentFlagRequired("name")andMarkPersistentFlagRequired("pull-secret")cmd/cluster/core/create.gobut not marked using cobra's mechanismGenerated documentation (
docs/content/reference/cli-flags/):index.md- Overview page explaining hcp vs hypershift CLIsaws.md- Generated flag reference forcreate cluster awscommandThree-state display in Required section:
✓OptionalUnavailableWhich issue(s) this PR fixes:
Fixes CNTRLPLANE-2600
Documentation Preview
📖 Preview the generated docs
Special notes for your reviewer:
Scope: Currently only covers AWS
create clustercommand. The generator is designed to be extensible to other platforms and commands.Required flag detection: The generator walks up the cobra command tree to access flags directly where annotations are stored, ensuring annotations set by
MarkFlagRequiredandMarkPersistentFlagRequiredare visible (cobra'sInheritedFlags()returns copies without annotations).No breaking changes: The
MarkPersistentFlagRequiredcalls don't change runtime behavior - these flags were already validated as required. This just makes it explicit to cobra for better--helpoutput and annotation-based detection.Regenerating docs: Run
make cli-docsormake updateto regenerate after flag changes.🤖 Generated with Claude Code
Checklist: