Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(delete): Refactor input handling & output display on resource deletion #323

Merged
merged 4 commits into from
Jun 24, 2024

Conversation

doronkg
Copy link
Contributor

@doronkg doronkg commented Jun 23, 2024

What this PR does / why we need it?

This PR aims to resolve 2 outputing issues resulting in the --delete flag.

  1. Avoid the unexpected newline error on confirmation
  2. Append -DELETED suffix on deleted resources in output
$ .\main.exe clusterrole --delete
Do you want to delete ClusterRole aaa in namespace ? (Y/N): y
Deleting ClusterRole aaa in namespace
kor version: vdev

  _  _____  ____
 | |/ / _ \|  _ \
 | ' / | | | |_) |
 | . \ |_| |  _ <
 |_|\_\___/|_| \_\

Unused resources in namespace: ""
+---+---------------+---------------+
| # | RESOURCE TYPE | RESOURCE NAME |
+---+---------------+---------------+
| 1 | ClusterRole   | aaa-DELETED   |
+---+---------------+---------------+

PR Checklist

  • This PR adds K8s exceptions (false positives)
  • This PR adds new code
  • This PR includes tests for new/existing code
  • This PR adds docs

GitHub Issue

Closes #321
Closes #322

Notes for your reviewers

#321 is resolved by consuming the newline character ("\n") and removing it from the input buffer.
#322 is resolved by moving the deletion logic before the grouping logic, so the updated diff variable will be used.

@doronkg doronkg changed the title Fix delete output fix(delete): Refactor input handling & output display on resource deletion Jun 23, 2024
@codecov-commenter
Copy link

codecov-commenter commented Jun 23, 2024

Codecov Report

Attention: Patch coverage is 1.63934% with 60 lines in your changes missing coverage. Please review.

Project coverage is 41.77%. Comparing base (ced2ef2) to head (9b0aaf1).
Report is 2 commits behind head on main.

Files Patch % Lines
pkg/kor/clusterroles.go 0.00% 2 Missing and 1 partial ⚠️
pkg/kor/configmaps.go 0.00% 2 Missing and 1 partial ⚠️
pkg/kor/daemonsets.go 0.00% 2 Missing and 1 partial ⚠️
pkg/kor/deployments.go 0.00% 2 Missing and 1 partial ⚠️
pkg/kor/hpas.go 0.00% 2 Missing and 1 partial ⚠️
pkg/kor/ingresses.go 0.00% 2 Missing and 1 partial ⚠️
pkg/kor/jobs.go 0.00% 2 Missing and 1 partial ⚠️
pkg/kor/networkpolicies.go 0.00% 2 Missing and 1 partial ⚠️
pkg/kor/pdbs.go 0.00% 2 Missing and 1 partial ⚠️
pkg/kor/pods.go 0.00% 2 Missing and 1 partial ⚠️
... and 11 more

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #323      +/-   ##
==========================================
+ Coverage   41.34%   41.77%   +0.42%     
==========================================
  Files          61       61              
  Lines        3212     3179      -33     
==========================================
  Hits         1328     1328              
+ Misses       1671     1637      -34     
- Partials      213      214       +1     

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

Copy link
Owner

@yonahd yonahd left a comment

Choose a reason for hiding this comment

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

Looks good overall. Small suggestion

pkg/kor/clusterroles.go Outdated Show resolved Hide resolved
Copy link
Owner

@yonahd yonahd left a comment

Choose a reason for hiding this comment

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

Lgtm

@yonahd yonahd merged commit bc2cca8 into yonahd:main Jun 24, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants