Skip to content

CNTRLPLANE-2600: docs: cli flags doc generater#7564

Draft
devguyio wants to merge 3 commits intoopenshift:mainfrom
devguyio:cntrlplane-2600-cli-flags-doc-generater
Draft

CNTRLPLANE-2600: docs: cli flags doc generater#7564
devguyio wants to merge 3 commits intoopenshift:mainfrom
devguyio:cntrlplane-2600-cli-flags-doc-generater

Conversation

@devguyio
Copy link
Contributor

@devguyio devguyio commented Jan 21, 2026

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:

  1. No visibility on exposed flags - There's no single place documenting which flags are exposed in the hcp CLI vs developer-only flags in hypershift
  2. Risk of developer flags leaking to hcp - Without clear visibility, developer-only flags could accidentally be exposed in the product CLI
  3. No CLI documentation exists - Currently there's no dedicated place in the docs for CLI flag reference
  4. Required flag ambiguity - Some flags (e.g. --name and --pull-secret ) were validated as required at runtime but not marked as such in cobra, making it impossible to auto-detect requirements

Solution

This PR introduces a CLI flag documentation generator that:

  1. Extracts flags programmatically from both hcp and hypershift CLI commands using the actual cobra command structures
  2. Detects required flags dynamically via cobra's MarkFlagRequired and MarkPersistentFlagRequired annotations instead of hardcoding
  3. Organizes flags by category using a mapping in categories.go (AWS Infrastructure, Cluster Identity, Security, Networking, etc.) for better readability
  4. Generates markdown documentation comparing flags side-by-side with per-CLI availability and required status
  5. Integrates with the build system via make cli-docs target (included in make update)

Changes

New hypershift docs generate command (cmd/docs/):

  • generate.go - Main generator logic, extracts flags from both CLIs by walking the cobra command tree
  • types.go - FlagInfo struct with RequiredInHcp and RequiredInHypershift fields for per-CLI tracking
  • categories.go - Flag categorization (AWS Infrastructure, Cluster Identity, Security, etc.)
  • templates/aws.md.tmpl - Template with three-state display for Required section
  • generate_test.go - 27 unit tests covering flag extraction, merging, and required detection

Required flag annotations (cmd/cluster/cluster.go, product-cli/cmd/cluster/cluster.go):

  • Added MarkPersistentFlagRequired("name") and MarkPersistentFlagRequired("pull-secret")
  • These flags were already effectively required through runtime validation in cmd/cluster/core/create.go but not marked using cobra's mechanism

Generated documentation (docs/content/reference/cli-flags/):

  • index.md - Overview page explaining hcp vs hypershift CLIs
  • aws.md - Generated flag reference for create cluster aws command

Three-state display in Required section:

Symbol Meaning
Required and available in this CLI
Optional Available but not required in this CLI
Unavailable Flag does not exist in this CLI

Which issue(s) this PR fixes:

Fixes CNTRLPLANE-2600

Documentation Preview

📖 Preview the generated docs

Special notes for your reviewer:

  1. Scope: Currently only covers AWS create cluster command. The generator is designed to be extensible to other platforms and commands.

  2. Required flag detection: The generator walks up the cobra command tree to access flags directly where annotations are stored, ensuring annotations set by MarkFlagRequired and MarkPersistentFlagRequired are visible (cobra's InheritedFlags() returns copies without annotations).

  3. No breaking changes: The MarkPersistentFlagRequired calls don't change runtime behavior - these flags were already validated as required. This just makes it explicit to cobra for better --help output and annotation-based detection.

  4. Regenerating docs: Run make cli-docs or make update to regenerate after flag changes.


🤖 Generated with Claude Code

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

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>
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jan 21, 2026
@openshift-ci-robot
Copy link

openshift-ci-robot commented Jan 21, 2026

@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.

Details

In response to this:

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:

  1. No visibility on exposed flags - There's no single place documenting which flags are exposed in the hcp CLI vs developer-only flags in hypershift
  2. Risk of developer flags leaking to hcp - Without clear visibility, developer-only flags could accidentally be exposed in the product CLI
  3. No CLI documentation exists - Currently there's no dedicated place in the docs for CLI flag reference
  4. Required flag ambiguity - Some flags (e.g. --name and --pull-secret ) were validated as required at runtime but not marked as such in cobra, making it impossible to auto-detect requirements

Solution

This PR introduces a CLI flag documentation generator that:

  1. Extracts flags programmatically from both hcp and hypershift CLI commands using the actual cobra command structures
  2. Detects required flags dynamically via cobra's MarkFlagRequired and MarkPersistentFlagRequired annotations instead of hardcoding
  3. Organizes flags by category using a mapping in categories.go (AWS Infrastructure, Cluster Identity, Security, Networking, etc.) for better readability
  4. Generates markdown documentation comparing flags side-by-side with per-CLI availability and required status
  5. Integrates with the build system via make cli-docs target (included in make update)

Changes

New hypershift docs generate command (cmd/docs/):

  • generate.go - Main generator logic, extracts flags from both CLIs by walking the cobra command tree
  • types.go - FlagInfo struct with RequiredInHcp and RequiredInHypershift fields for per-CLI tracking
  • categories.go - Flag categorization (AWS Infrastructure, Cluster Identity, Security, etc.)
  • templates/aws.md.tmpl - Template with three-state display for Required section
  • generate_test.go - 27 unit tests covering flag extraction, merging, and required detection

Required flag annotations (cmd/cluster/cluster.go, product-cli/cmd/cluster/cluster.go):

  • Added MarkPersistentFlagRequired("name") and MarkPersistentFlagRequired("pull-secret")
  • These flags were already effectively required through runtime validation in cmd/cluster/core/create.go but not marked using cobra's mechanism

Generated documentation (docs/content/reference/cli-flags/):

  • index.md - Overview page explaining hcp vs hypershift CLIs
  • aws.md - Generated flag reference for create cluster aws command

Three-state display in Required section:

Symbol Meaning
Required and available in this CLI
Optional Available but not required in this CLI
Unavailable Flag does not exist in this CLI

Which issue(s) this PR fixes:

Fixes CNTRLPLANE-2600

Documentation Preview

📖 Preview the generated CLI flag reference →

Special notes for your reviewer:

  1. Scope: Currently only covers AWS create cluster command. The generator is designed to be extensible to other platforms and commands.

  2. Required flag detection: The generator walks up the cobra command tree to access flags directly where annotations are stored, ensuring annotations set by MarkFlagRequired and MarkPersistentFlagRequired are visible (cobra's InheritedFlags() returns copies without annotations).

  3. No breaking changes: The MarkPersistentFlagRequired calls don't change runtime behavior - these flags were already validated as required. This just makes it explicit to cobra for better --help output and annotation-based detection.

  4. Regenerating docs: Run make cli-docs or make update to regenerate after flag changes.


🤖 Generated with Claude Code

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 21, 2026

Important

Review skipped

Auto reviews are limited based on label configuration.

🚫 Review skipped — only excluded labels are configured. (1)
  • do-not-merge/work-in-progress

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 21, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 21, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci-robot
Copy link

openshift-ci-robot commented Jan 21, 2026

@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.

Details

In response to this:

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:

  1. No visibility on exposed flags - There's no single place documenting which flags are exposed in the hcp CLI vs developer-only flags in hypershift
  2. Risk of developer flags leaking to hcp - Without clear visibility, developer-only flags could accidentally be exposed in the product CLI
  3. No CLI documentation exists - Currently there's no dedicated place in the docs for CLI flag reference
  4. Required flag ambiguity - Some flags (e.g. --name and --pull-secret ) were validated as required at runtime but not marked as such in cobra, making it impossible to auto-detect requirements

Solution

This PR introduces a CLI flag documentation generator that:

  1. Extracts flags programmatically from both hcp and hypershift CLI commands using the actual cobra command structures
  2. Detects required flags dynamically via cobra's MarkFlagRequired and MarkPersistentFlagRequired annotations instead of hardcoding
  3. Organizes flags by category using a mapping in categories.go (AWS Infrastructure, Cluster Identity, Security, Networking, etc.) for better readability
  4. Generates markdown documentation comparing flags side-by-side with per-CLI availability and required status
  5. Integrates with the build system via make cli-docs target (included in make update)

Changes

New hypershift docs generate command (cmd/docs/):

  • generate.go - Main generator logic, extracts flags from both CLIs by walking the cobra command tree
  • types.go - FlagInfo struct with RequiredInHcp and RequiredInHypershift fields for per-CLI tracking
  • categories.go - Flag categorization (AWS Infrastructure, Cluster Identity, Security, etc.)
  • templates/aws.md.tmpl - Template with three-state display for Required section
  • generate_test.go - 27 unit tests covering flag extraction, merging, and required detection

Required flag annotations (cmd/cluster/cluster.go, product-cli/cmd/cluster/cluster.go):

  • Added MarkPersistentFlagRequired("name") and MarkPersistentFlagRequired("pull-secret")
  • These flags were already effectively required through runtime validation in cmd/cluster/core/create.go but not marked using cobra's mechanism

Generated documentation (docs/content/reference/cli-flags/):

  • index.md - Overview page explaining hcp vs hypershift CLIs
  • aws.md - Generated flag reference for create cluster aws command

Three-state display in Required section:

Symbol Meaning
Required and available in this CLI
Optional Available but not required in this CLI
Unavailable Flag does not exist in this CLI

Which issue(s) this PR fixes:

Fixes CNTRLPLANE-2600

Documentation Preview

📖 Preview the generated CLI flag reference →

Special notes for your reviewer:

  1. Scope: Currently only covers AWS create cluster command. The generator is designed to be extensible to other platforms and commands.

  2. Required flag detection: The generator walks up the cobra command tree to access flags directly where annotations are stored, ensuring annotations set by MarkFlagRequired and MarkPersistentFlagRequired are visible (cobra's InheritedFlags() returns copies without annotations).

  3. No breaking changes: The MarkPersistentFlagRequired calls don't change runtime behavior - these flags were already validated as required. This just makes it explicit to cobra for better --help output and annotation-based detection.

  4. Regenerating docs: Run make cli-docs or make update to regenerate after flag changes.


🤖 Generated with Claude Code

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

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.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Jan 21, 2026

@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.

Details

In response to this:

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:

  1. No visibility on exposed flags - There's no single place documenting which flags are exposed in the hcp CLI vs developer-only flags in hypershift
  2. Risk of developer flags leaking to hcp - Without clear visibility, developer-only flags could accidentally be exposed in the product CLI
  3. No CLI documentation exists - Currently there's no dedicated place in the docs for CLI flag reference
  4. Required flag ambiguity - Some flags (e.g. --name and --pull-secret ) were validated as required at runtime but not marked as such in cobra, making it impossible to auto-detect requirements

Solution

This PR introduces a CLI flag documentation generator that:

  1. Extracts flags programmatically from both hcp and hypershift CLI commands using the actual cobra command structures
  2. Detects required flags dynamically via cobra's MarkFlagRequired and MarkPersistentFlagRequired annotations instead of hardcoding
  3. Organizes flags by category using a mapping in categories.go (AWS Infrastructure, Cluster Identity, Security, Networking, etc.) for better readability
  4. Generates markdown documentation comparing flags side-by-side with per-CLI availability and required status
  5. Integrates with the build system via make cli-docs target (included in make update)

Changes

New hypershift docs generate command (cmd/docs/):

  • generate.go - Main generator logic, extracts flags from both CLIs by walking the cobra command tree
  • types.go - FlagInfo struct with RequiredInHcp and RequiredInHypershift fields for per-CLI tracking
  • categories.go - Flag categorization (AWS Infrastructure, Cluster Identity, Security, etc.)
  • templates/aws.md.tmpl - Template with three-state display for Required section
  • generate_test.go - 27 unit tests covering flag extraction, merging, and required detection

Required flag annotations (cmd/cluster/cluster.go, product-cli/cmd/cluster/cluster.go):

  • Added MarkPersistentFlagRequired("name") and MarkPersistentFlagRequired("pull-secret")
  • These flags were already effectively required through runtime validation in cmd/cluster/core/create.go but not marked using cobra's mechanism

Generated documentation (docs/content/reference/cli-flags/):

  • index.md - Overview page explaining hcp vs hypershift CLIs
  • aws.md - Generated flag reference for create cluster aws command

Three-state display in Required section:

Symbol Meaning
Required and available in this CLI
Optional Available but not required in this CLI
Unavailable Flag does not exist in this CLI

Which issue(s) this PR fixes:

Fixes CNTRLPLANE-2600

Documentation Preview

Special notes for your reviewer:

  1. Scope: Currently only covers AWS create cluster command. The generator is designed to be extensible to other platforms and commands.

  2. Required flag detection: The generator walks up the cobra command tree to access flags directly where annotations are stored, ensuring annotations set by MarkFlagRequired and MarkPersistentFlagRequired are visible (cobra's InheritedFlags() returns copies without annotations).

  3. No breaking changes: The MarkPersistentFlagRequired calls don't change runtime behavior - these flags were already validated as required. This just makes it explicit to cobra for better --help output and annotation-based detection.

  4. Regenerating docs: Run make cli-docs or make update to regenerate after flag changes.


🤖 Generated with Claude Code

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

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
@openshift-ci-robot
Copy link

openshift-ci-robot commented Jan 21, 2026

@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.

Details

In response to this:

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:

  1. No visibility on exposed flags - There's no single place documenting which flags are exposed in the hcp CLI vs developer-only flags in hypershift
  2. Risk of developer flags leaking to hcp - Without clear visibility, developer-only flags could accidentally be exposed in the product CLI
  3. No CLI documentation exists - Currently there's no dedicated place in the docs for CLI flag reference
  4. Required flag ambiguity - Some flags (e.g. --name and --pull-secret ) were validated as required at runtime but not marked as such in cobra, making it impossible to auto-detect requirements

Solution

This PR introduces a CLI flag documentation generator that:

  1. Extracts flags programmatically from both hcp and hypershift CLI commands using the actual cobra command structures
  2. Detects required flags dynamically via cobra's MarkFlagRequired and MarkPersistentFlagRequired annotations instead of hardcoding
  3. Organizes flags by category using a mapping in categories.go (AWS Infrastructure, Cluster Identity, Security, Networking, etc.) for better readability
  4. Generates markdown documentation comparing flags side-by-side with per-CLI availability and required status
  5. Integrates with the build system via make cli-docs target (included in make update)

Changes

New hypershift docs generate command (cmd/docs/):

  • generate.go - Main generator logic, extracts flags from both CLIs by walking the cobra command tree
  • types.go - FlagInfo struct with RequiredInHcp and RequiredInHypershift fields for per-CLI tracking
  • categories.go - Flag categorization (AWS Infrastructure, Cluster Identity, Security, etc.)
  • templates/aws.md.tmpl - Template with three-state display for Required section
  • generate_test.go - 27 unit tests covering flag extraction, merging, and required detection

Required flag annotations (cmd/cluster/cluster.go, product-cli/cmd/cluster/cluster.go):

  • Added MarkPersistentFlagRequired("name") and MarkPersistentFlagRequired("pull-secret")
  • These flags were already effectively required through runtime validation in cmd/cluster/core/create.go but not marked using cobra's mechanism

Generated documentation (docs/content/reference/cli-flags/):

  • index.md - Overview page explaining hcp vs hypershift CLIs
  • aws.md - Generated flag reference for create cluster aws command

Three-state display in Required section:

Symbol Meaning
Required and available in this CLI
Optional Available but not required in this CLI
Unavailable Flag does not exist in this CLI

Which issue(s) this PR fixes:

Fixes CNTRLPLANE-2600

Documentation Preview

Special notes for your reviewer:

  1. Scope: Currently only covers AWS create cluster command. The generator is designed to be extensible to other platforms and commands.

  2. Required flag detection: The generator walks up the cobra command tree to access flags directly where annotations are stored, ensuring annotations set by MarkFlagRequired and MarkPersistentFlagRequired are visible (cobra's InheritedFlags() returns copies without annotations).

  3. No breaking changes: The MarkPersistentFlagRequired calls don't change runtime behavior - these flags were already validated as required. This just makes it explicit to cobra for better --help output and annotation-based detection.

  4. Regenerating docs: Run make cli-docs or make update to regenerate after flag changes.


🤖 Generated with Claude Code

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

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.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 21, 2026

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. area/cli Indicates the PR includes changes for CLI area/documentation Indicates the PR includes changes for documentation area/platform/aws PR/issue for AWS (AWSPlatform) platform and removed do-not-merge/needs-area labels Jan 21, 2026
@devguyio
Copy link
Contributor Author

/test ?

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 21, 2026

@devguyio: The following commands are available to trigger required jobs:

/test e2e-aks
/test e2e-aks-4-21
/test e2e-aks-override
/test e2e-aws
/test e2e-aws-4-21
/test e2e-aws-override
/test e2e-aws-upgrade-hypershift-operator
/test e2e-kubevirt-aws-ovn-reduced
/test images
/test okd-scos-images
/test security
/test unit
/test verify
/test verify-deps

The following commands are available to trigger optional jobs:

/test docs-preview
/test e2e-aws-autonode
/test e2e-aws-metrics
/test e2e-aws-minimal
/test e2e-aws-techpreview
/test e2e-azure-aks-ovn-conformance
/test e2e-conformance
/test e2e-kubevirt-aws-ovn
/test e2e-kubevirt-azure-ovn
/test e2e-kubevirt-metal-conformance
/test e2e-openstack-aws
/test e2e-openstack-aws-conformance
/test e2e-openstack-aws-csi-cinder
/test e2e-openstack-aws-csi-manila
/test e2e-openstack-aws-nfv
/test okd-scos-e2e-aws-ovn
/test reqserving-e2e-aws

Use /test all to run the following jobs that were automatically triggered:

pull-ci-openshift-hypershift-main-docs-preview
pull-ci-openshift-hypershift-main-e2e-aks
pull-ci-openshift-hypershift-main-e2e-aks-4-21
pull-ci-openshift-hypershift-main-e2e-aws
pull-ci-openshift-hypershift-main-e2e-aws-upgrade-hypershift-operator
pull-ci-openshift-hypershift-main-e2e-kubevirt-aws-ovn-reduced
pull-ci-openshift-hypershift-main-images
pull-ci-openshift-hypershift-main-okd-scos-images
pull-ci-openshift-hypershift-main-security
pull-ci-openshift-hypershift-main-unit
pull-ci-openshift-hypershift-main-verify
Details

In response to this:

/test ?

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.

@devguyio
Copy link
Contributor Author

/test docs-preview

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 21, 2026

@devguyio: all tests passed!

Full PR test history. Your PR dashboard.

Details

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. I understand the commands that are listed here.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Jan 21, 2026

@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.

Details

In response to this:

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:

  1. No visibility on exposed flags - There's no single place documenting which flags are exposed in the hcp CLI vs developer-only flags in hypershift
  2. Risk of developer flags leaking to hcp - Without clear visibility, developer-only flags could accidentally be exposed in the product CLI
  3. No CLI documentation exists - Currently there's no dedicated place in the docs for CLI flag reference
  4. Required flag ambiguity - Some flags (e.g. --name and --pull-secret ) were validated as required at runtime but not marked as such in cobra, making it impossible to auto-detect requirements

Solution

This PR introduces a CLI flag documentation generator that:

  1. Extracts flags programmatically from both hcp and hypershift CLI commands using the actual cobra command structures
  2. Detects required flags dynamically via cobra's MarkFlagRequired and MarkPersistentFlagRequired annotations instead of hardcoding
  3. Organizes flags by category using a mapping in categories.go (AWS Infrastructure, Cluster Identity, Security, Networking, etc.) for better readability
  4. Generates markdown documentation comparing flags side-by-side with per-CLI availability and required status
  5. Integrates with the build system via make cli-docs target (included in make update)

Changes

New hypershift docs generate command (cmd/docs/):

  • generate.go - Main generator logic, extracts flags from both CLIs by walking the cobra command tree
  • types.go - FlagInfo struct with RequiredInHcp and RequiredInHypershift fields for per-CLI tracking
  • categories.go - Flag categorization (AWS Infrastructure, Cluster Identity, Security, etc.)
  • templates/aws.md.tmpl - Template with three-state display for Required section
  • generate_test.go - 27 unit tests covering flag extraction, merging, and required detection

Required flag annotations (cmd/cluster/cluster.go, product-cli/cmd/cluster/cluster.go):

  • Added MarkPersistentFlagRequired("name") and MarkPersistentFlagRequired("pull-secret")
  • These flags were already effectively required through runtime validation in cmd/cluster/core/create.go but not marked using cobra's mechanism

Generated documentation (docs/content/reference/cli-flags/):

  • index.md - Overview page explaining hcp vs hypershift CLIs
  • aws.md - Generated flag reference for create cluster aws command

Three-state display in Required section:

Symbol Meaning
Required and available in this CLI
Optional Available but not required in this CLI
Unavailable Flag does not exist in this CLI

Which issue(s) this PR fixes:

Fixes CNTRLPLANE-2600

Documentation Preview

📖 Preview the generated docs

Special notes for your reviewer:

  1. Scope: Currently only covers AWS create cluster command. The generator is designed to be extensible to other platforms and commands.

  2. Required flag detection: The generator walks up the cobra command tree to access flags directly where annotations are stored, ensuring annotations set by MarkFlagRequired and MarkPersistentFlagRequired are visible (cobra's InheritedFlags() returns copies without annotations).

  3. No breaking changes: The MarkPersistentFlagRequired calls don't change runtime behavior - these flags were already validated as required. This just makes it explicit to cobra for better --help output and annotation-based detection.

  4. Regenerating docs: Run make cli-docs or make update to regenerate after flag changes.


🤖 Generated with Claude Code

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

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
Copy link
Contributor Author

/auto-cc

@openshift-ci openshift-ci bot requested review from jparrill and muraee January 21, 2026 19:11
Copy link
Contributor

@jparrill jparrill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. Overall looks good. Some minor nits dropped

Comment on lines +227 to +240
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
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When processing hypershift flags, you uses flag.RequiredInHcp instead of flag.RequiredInHypershift:

  • existing.RequiredInHypershift = flag.RequiredInHcp // line 234
  • f.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?

Comment on lines +15 to +27
### {{ .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 }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why you use {{ cat.Name }} vs {{ .Name }}? are those different? if not could we just use one?

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 2, 2026
@openshift-merge-robot
Copy link
Contributor

PR needs rebase.

Details

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/cli Indicates the PR includes changes for CLI area/documentation Indicates the PR includes changes for documentation area/platform/aws PR/issue for AWS (AWSPlatform) platform do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants