Closed Forget-C closed 9 months ago
The original purpose was to abstract the filter framework
to facilitate the addition of filter parameters. Other changes are necessary to achieve this goal. #187
now, If we want to add a filter, we only need the following steps:
// 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
}
const TestFilterName = "test"
func NewDefaultRegistry() Registry {
return Registry{
LabelFilterName: LabelFilter,
AgeFilterName: AgeFilter,
KorLabelFilterName: KorLabelFilter,
TestFilterName: TestFilter,
}
}
Attention: 220 lines
in your changes are missing coverage. Please review.
Comparison is base (
1e391dd
) 45.87% compared to head (69bc5c5
) 44.43%. Report is 1 commits behind head on main.
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
refactor&feat&fix&style:
kor.Opts
and filter parametersfilters.Options
.includeExcludeLists
no longer participates incmd args
binding, and is taken over byfilters.Options
.includeNamespace
andexcludeNamespace
are taken over byfilters.Options
and will only be executed once.kor/used=true
tag.The unit tests have passed, but due to the large scope of the changes, more tests are needed.