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
Refactor some codes, add filter objects, and add support for lable filtering... #194
Conversation
1. Unify parameter types and divide them into two categories: normal parameters `kor.Opts` and filter parameters `filters.Options`. 2. `includeExcludeLists` no longer participates in `cmd args` binding, and is taken over by `filters.Options`. 3. The initialization operations of `includeNamespace` and `excludeNamespace` are taken over by `filters.Options` and will only be executed once. 4. Add filters.Framework object to uniformly process filtering logic. 5. All currently supported resources are supported by the `kor/used=true` tag. 6. Fix the problem that filterOptions.Validate does not take effect 7. Support includeable parameters Signed-off-by: Extreme <1403539044@qq.com>
Signed-off-by: Extreme <1403539044@qq.com>
The original purpose was to abstract the create filter func// FilterFunc is a filter that is a function
// If the resource is legal, return true
// example:
// deployment.Spec.Replicas > 0; return true
// meta.GetLabels()["kor/used"] == "true"; return true
type FilterFunc func(object runtime.Object, opts *Options) bool
func TestFilter(object runtime.Object, opts *Options) bool {
if meta, ok := object.(metav1.Object); ok {
if meta.GetLabels()["kor/used"] == "true" {
return true
}
}
return false
} Set a nameconst TestFilterName = "test" Add to registryfunc NewDefaultRegistry() Registry {
return Registry{
LabelFilterName: LabelFilter,
AgeFilterName: AgeFilter,
KorLabelFilterName: KorLabelFilter,
TestFilterName: TestFilter,
}
} |
Signed-off-by: Extreme <1403539044@qq.com>
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #194 +/- ##
==========================================
- Coverage 45.87% 44.43% -1.45%
==========================================
Files 25 29 +4
Lines 2413 2444 +31
==========================================
- Hits 1107 1086 -21
- Misses 1122 1205 +83
+ Partials 184 153 -31 ☔ View full report in Codecov by Sentry. |
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.
Overall LGTM, left a few comments in the code.
Thanks.
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.
Approved!
Thank you!
refactor&feat&fix&style:
1. Unify parameter types and divide them into two categories: normal parameters
kor.Opts
and filter parametersfilters.Options
.2.
includeExcludeLists
no longer participates incmd args
binding, and is taken over byfilters.Options
.3. The initialization operations of
includeNamespace
andexcludeNamespace
are taken over byfilters.Options
and will only be executed once.4. Add filters.Framework object to uniformly process filtering logic.
5. All currently supported resources are supported by the
kor/used=true
tag.6. Fix the problem that filterOptions.Validate does not take effect
7. Support includeable parameters
The unit tests have passed, but due to the large scope of the changes, more tests are needed.