-
Notifications
You must be signed in to change notification settings - Fork 97
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
Feat/crd argo rollouts #375
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #375 +/- ##
==========================================
+ Coverage 43.38% 44.25% +0.87%
==========================================
Files 63 65 +2
Lines 4020 4291 +271
==========================================
+ Hits 1744 1899 +155
- Misses 2030 2128 +98
- Partials 246 264 +18 ☔ View full report in Codecov by Sentry. |
@oliveiraxavier Please rebase so we can properly review the code |
@yonahd The main branch has been merged with the feat branch. |
Did you sync your fork? |
Yes, synced |
1e937ad
to
e85e81e
Compare
@oliveiraxavier I'm working on the review. Any chance you can split this into 2 separate PRs |
In my previous PR (#363), the logic was separated but the resource search files (deployments for example) were extremely tied to the connection logic, I separated them with that in mind. Refactoring this would almost be a reopening of the previous pr and would require some more refactoring of everything I developed, I can't see how I can split this PR into two without breaking the functioning of everything. |
Maybe I'm missing something but it seems most of the connection logic is just moving the logic from kor.go |
I won't be able to work on it at the moment |
No worries. I'll review it as is. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic looks right for the finding unused argorollouts
There are some structure issues and minor fixes.
I suggest you also look through https://github.com/yonahd/kor/blob/main/CONTRIBUTING.md which will help structuring the PR.
Also we need to think of how we give the permissions in the helm chart
@@ -253,6 +269,45 @@ Unused resources in namespace: "test" | |||
+---+----------------+----------------------------------------------+--------------------------------------------------------+ | |||
``` | |||
|
|||
```sh | |||
kor all --include-third-party-crds argo-rollouts,argo-rollouts-analysis-templates,argo-rollouts-cluster-analysis-templates --show-reason --show-reason |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this additional example
@@ -85,4 +87,5 @@ func addFilterOptionsFlag(cmd *cobra.Command, opts *filters.Options) { | |||
cmd.PersistentFlags().StringVar(&opts.IncludeLabels, "include-labels", opts.IncludeLabels, "Selector to filter in, Example: --include-labels key1=value1.(currently supports one label)") | |||
cmd.PersistentFlags().StringSliceVarP(&opts.ExcludeNamespaces, "exclude-namespaces", "e", opts.ExcludeNamespaces, "Namespaces to be excluded, split by commas. Example: --exclude-namespaces ns1,ns2,ns3. If --include-namespaces is set, --exclude-namespaces will be ignored.") | |||
cmd.PersistentFlags().StringSliceVarP(&opts.IncludeNamespaces, "include-namespaces", "n", opts.IncludeNamespaces, "Namespaces to run on, split by commas. Example: --include-namespaces ns1,ns2,ns3. If set, non-namespaced resources will be ignored.") | |||
rootCmd.PersistentFlags().StringSliceVar(&opts.IncludeThirdPartyCrds, "include-third-party-crds", opts.IncludeThirdPartyCrds, "Custom resources defintions to search, split by commas. Example: --include-crds argo-rollouts. If set, the chosen crd will be returned (in addition to the other resources, of course)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can allow the user to select specific ones without a flag using the multi functionality.
I think the flag should exist in case the user chooses kor all
and wants to choose either only native resources or also crds (a boolean flag)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change the folder structure to pkg/kor/crds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should cause circular import error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a separate file create_test_crd_resources.go for crd test resources
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this into utils
@@ -235,3 +235,12 @@ func FormatOutputAll(namespace string, allDiffs []ResourceDiff, opts common.Opts | |||
table.Render() | |||
return fmt.Sprintf("Unused resources in namespace: %q\n%s\n", namespace, buf.String()) | |||
} | |||
|
|||
func SkipIfContainsValue(data []ResourceInfo, key string, value interface{}) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Should not be in formatter.go
"github.com/yonahd/kor/pkg/filters" | ||
) | ||
|
||
func GetUnusedArgoRollouts(clientsetinterface clusterconfig.ClientInterface, namespace string, filterOpts *filters.Options) ResourceDiff { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to create cmd/kor/argorollouts.go so users can select this one specifically
Also missing pkg/kor/multi.go - allow finding your new resource in a comma-separated query along other resources.
"github.com/yonahd/kor/pkg/clusterconfig" | ||
"github.com/yonahd/kor/pkg/filters" | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: move the get unused functions to the bottom to match convention
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this needed for?
I'm closing this pr. |
Thank's for your review |
Are you planning on completing this? |
Maybe in two or three months I can set aside some time to get back to it. If someone follows the idea, no problem. |
This PR allow get some unused Argo rollouts
PR Checklist
Notes for your reviewers
This PR adds support for get unused Argo Rollout, Cluster Analysis templates and Analysis templates.
For this pr, some code refactoring was necessary.