refactor: simplify namespace exclusion logic
Replace the manual loop for checking excluded namespaces with the built-in slices.Contains function. This change enhances the readability and efficiency of the code, while also allowing for wildcard matching in exclusion.
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
"log"
|
"log"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -91,12 +92,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func nsExcluded(name string, excludedNS []string) bool {
|
func nsExcluded(name string, excludedNS []string) bool {
|
||||||
for _, ns := range excludedNS {
|
return slices.Contains(excludedNS, name) || slices.Contains(excludedNS, "*")
|
||||||
if name == ns {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseArgs() args {
|
func parseArgs() args {
|
||||||
|
|||||||
Reference in New Issue
Block a user