Skip to content

Conversation

mayooot
Copy link
Contributor

@mayooot mayooot commented Apr 16, 2025

Description

Add Range Delete Command.
Usage:

# Delete all contexts with prefix "dev-"
kubecm range-delete dev-
or 
kubecm range-delete -m prefix dev-

# Delete all contexts with suffix "-prod"
kubecm range-delete -m suffix -prod

# Delete all contexts containing "staging"
kubecm range-delete -m contains staging

Related Issue

#1079

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (changes only affecting documentation)

Checklist

  • I have tested my changes locally and ensured they are functioning properly. Please run the make build and make test commands.
  • I have added/updated unit or e2e tests to cover my changes.
  • I have updated the relevant documentation. If you change commands or arguments, run make doc-gen to generate new documentation.

Copy link

the-label-bot bot commented Apr 16, 2025

The Label Bot has predicted the following:

Category Value Confidence Applied Label

Copy link

codecov bot commented Apr 16, 2025

Codecov Report

Attention: Patch coverage is 22.44898% with 76 lines in your changes missing coverage. Please review.

Project coverage is 20.08%. Comparing base (f843d2a) to head (c123037).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
cmd/delete_range.go 22.68% 75 Missing ⚠️
cmd/delete.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1088      +/-   ##
==========================================
+ Coverage   20.00%   20.08%   +0.08%     
==========================================
  Files          21       22       +1     
  Lines        2655     2753      +98     
==========================================
+ Hits          531      553      +22     
- Misses       2071     2147      +76     
  Partials       53       53              
Flag Coverage Δ
unittests 20.08% <22.44%> (+0.08%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

@sunny0826 sunny0826 requested review from sunny0826 and Copilot April 16, 2025 08:47
@sunny0826 sunny0826 self-assigned this Apr 16, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces the Range Delete Command to delete kubeconfig contexts based on a specified matching pattern.

  • Implements the range delete logic and adds the corresponding Cobra command
  • Updates both user documentation and unit tests for the new feature
  • Registers the new command in the CLI entry point

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
docs/en-us/cli/kubecm_range-delete_docs.md Added documentation page for the range delete command
docs/en-us/cli/kubecm_range-delete.md Provided command usage, examples, and options for the feature
cmd/range_delete_test.go Added unit tests to cover the matching logic
cmd/range_delete.go Implemented the new range delete command logic
cmd/cmd.go Registered the new RangeDeleteCommand in the CLI

Comment on lines +19 to +21
# Open add command document page
kubecm add docs

Copy link
Preview

Copilot AI Apr 16, 2025

Choose a reason for hiding this comment

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

The command example appears to be incorrect; consider changing 'kubecm add docs' to 'kubecm range-delete docs' to accurately reflect the new command.

Suggested change
# Open add command document page
kubecm add docs
# Delete contexts matching the pattern "test-*"
kubecm range-delete docs --pattern "test-*"

Copilot uses AI. Check for mistakes.

Copy link
Owner

@sunny0826 sunny0826 left a comment

Choose a reason for hiding this comment

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

Also, please add the e2e test case for range delete cmd to https://github.com/sunny0826/kubecm/blob/master/.github/workflows/e2e-test.yaml

@sunny0826
Copy link
Owner

Also, please add the e2e test case for range delete cmd to https://github.com/sunny0826/kubecm/blob/master/.github/workflows/e2e-test.yaml

@mayooot code looks good enough, please add e2e tests.

@mayooot mayooot force-pushed the feat/range-delete branch from 65b5a64 to c123037 Compare April 23, 2025 12:07
@mayooot
Copy link
Contributor Author

mayooot commented Apr 23, 2025

Also, please add the e2e test case for range delete cmd to https://github.com/sunny0826/kubecm/blob/master/.github/workflows/e2e-test.yaml

@mayooot code looks good enough, please add e2e tests.

Sure,I'm done.

Copy link
Owner

@sunny0826 sunny0826 left a comment

Choose a reason for hiding this comment

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

LGTM
Thank you for your valuable contribution to this project! Your work is greatly appreciated. 🎆

@sunny0826 sunny0826 merged commit 6f711a3 into sunny0826:master Apr 24, 2025
6 checks passed
@sunny0826
Copy link
Owner

@all-contributors please add @mayooot for code/doc/test

Copy link
Contributor

@sunny0826

I couldn't determine any contributions to add, did you specify any contributions?
Please make sure to use valid contribution names.

@sunny0826
Copy link
Owner

@all-contributors
please add @mayooot for code
please add @mayooot for doc
please add @mayooot for test

Copy link
Contributor

@sunny0826

I've put up a pull request to add @mayooot! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants