Skip to content

fix: command in karmadactl create should be karmadactl instead of kubectl#7545

Merged
karmada-bot merged 1 commit into
karmada-io:masterfrom
FAUST-BENCHOU:fix/kubectl-example
Jun 17, 2026
Merged

fix: command in karmadactl create should be karmadactl instead of kubectl#7545
karmada-bot merged 1 commit into
karmada-io:masterfrom
FAUST-BENCHOU:fix/kubectl-example

Conversation

@FAUST-BENCHOU

Copy link
Copy Markdown
Member

What type of PR is this?

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #7542

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


Copilot AI review requested due to automatic review settings May 23, 2026 09:47
@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR adds richer create subcommand help output by introducing per-subcommand Example strings and wiring a recursive helper to apply them across the cobra command tree.

Changes:

  • Added example text blocks for many create subcommands (namespace, quota, configmap, RBAC, ingress, secrets, services, etc.).
  • Introduced a createSubcommandExamples lookup map keyed by subcommand name.
  • Added setCreateSubcommandExamples to recursively set subCmd.Example during NewCmdCreate.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/karmadactl/create/create.go Outdated
Comment thread pkg/karmadactl/create/create.go Outdated
Comment thread pkg/karmadactl/create/create.go Outdated
Comment thread pkg/karmadactl/create/create.go Outdated

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a comprehensive set of example strings for various karmadactl create subcommands and implements a recursive function, setCreateSubcommandExamples, to apply these examples to the command hierarchy. Feedback was provided regarding a formatting bug in the podDisruptionBudgetExample where a percentage sign needs to be escaped to prevent fmt.Sprintf errors. Additionally, it was recommended to add a documentation comment to the new setCreateSubcommandExamples function to align with maintainability best practices.

Comment thread pkg/karmadactl/create/create.go Outdated
Comment thread pkg/karmadactl/create/create.go Outdated
@FAUST-BENCHOU FAUST-BENCHOU force-pushed the fix/kubectl-example branch from 53acb8d to 57604bd Compare May 23, 2026 09:55
@codecov-commenter

codecov-commenter commented May 23, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.06%. Comparing base (7bdab44) to head (1e78543).

Files with missing lines Patch % Lines
pkg/karmadactl/create/create.go 0.00% 6 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7545      +/-   ##
==========================================
- Coverage   42.07%   42.06%   -0.01%     
==========================================
  Files         879      879              
  Lines       54821    54827       +6     
==========================================
- Hits        23064    23063       -1     
- Misses      30013    30020       +7     
  Partials     1744     1744              
Flag Coverage Δ
unittests 42.06% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@XiShanYongYe-Chang

Copy link
Copy Markdown
Member

cc @zhzhuang-zju

@RainbowMango RainbowMango added this to the v1.19 milestone Jun 17, 2026
@RainbowMango

Copy link
Copy Markdown
Member

Just out of curiosity, the generated command-line-flags should be updated after this PR, but why not?

@FAUST-BENCHOU

Copy link
Copy Markdown
Member Author

Just out of curiosity, the generated command-line-flags should be updated after this PR, but why not?

because at that time, karmadactl doc 's PR had not yet been merged lol.Let me rebase to the newest

@RainbowMango

Copy link
Copy Markdown
Member

OK. thanks.

@FAUST-BENCHOU FAUST-BENCHOU force-pushed the fix/kubectl-example branch 2 times, most recently from b0f4fc0 to 9674d1c Compare June 17, 2026 02:43
@FAUST-BENCHOU

Copy link
Copy Markdown
Member Author

/cc @RainbowMango I simplified it to a recursive method.

Comment thread pkg/karmadactl/create/create.go Outdated
func replaceCreateSubcommandExamples(cmd *cobra.Command, parentCommand string) {
for _, subCmd := range cmd.Commands() {
if subCmd.Example != "" {
subCmd.Example = strings.ReplaceAll(subCmd.Example, "kubectl", parentCommand)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Another replace approach is to strictly match kubectl create, so it won't accidentally replace anything should't be replaced, like:

Suggested change
subCmd.Example = strings.ReplaceAll(subCmd.Example, "kubectl", parentCommand)
subCmd.Example = strings.ReplaceAll(subCmd.Example, "kubectl create", parentCommand+" create")

But, no big deal, it's up to you.

/approve
/lgtm

/hold
for @FAUST-BENCHOU confirm

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

make sense

@karmada-bot karmada-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 17, 2026
@karmada-bot karmada-bot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jun 17, 2026
…ectl

Signed-off-by: zhoujinyu <2319109590@qq.com>
@karmada-bot karmada-bot removed the lgtm Indicates that a PR is ready to be merged. label Jun 17, 2026

@RainbowMango RainbowMango left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm
/approve

/hold cancel
Thanks.

@karmada-bot karmada-bot added lgtm Indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Jun 17, 2026
@karmada-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RainbowMango

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

@karmada-bot karmada-bot merged commit 0227123 into karmada-io:master Jun 17, 2026
18 checks passed
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. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Example command in website of karmadactl create is kubectl instead of karmadactl

6 participants