change pod prefix filter to blacklist

This commit is contained in:
rasmus 2022-11-09 21:15:17 +02:00
parent 1218016ca1
commit 9363ec9d70
1 changed files with 5 additions and 5 deletions

View File

@ -32,8 +32,8 @@ var App = &cli.App{
//TODO: &cli.BoolFlag{Name: "normalize-log-level", Usage: "Normalize log.level values to Syslog defined keywords"},
//TODO: &cli.BoolFlag{Name: "parse-json"},
//
&cli.StringSliceFlag{Category: "selectors", Name: "pod-namespace", EnvVars: []string{"KUBE_POD_NAMESPACE"}},
&cli.StringSliceFlag{Category: "selectors", Name: "pod-prefix", EnvVars: []string{"KUBE_NODE_NAME"}},
&cli.StringSliceFlag{Category: "selectors", Name: "pod-namespace", EnvVars: []string{"KUBE_POD_NAMESPACE"}, Usage: "whitelist filter for filenames"},
&cli.StringSliceFlag{Category: "selectors", Name: "pod-prefix", EnvVars: []string{"KUBE_NODE_NAME"}, Usage: "blacklist filter for filenames"},
//
&cli.StringFlag{Category: "secrets", Name: "mongo-uri", EnvVars: []string{"MONGO_URI"}, Usage: "mongodb://foo:bar@host:27017/database", Required: true},
},
@ -49,7 +49,7 @@ var App = &cli.App{
},
Action: func(ctx *cli.Context) error {
filterNamespace, filterPodPrefixes := sliceToMap(ctx.StringSlice("pod-namespace")), ctx.StringSlice("pod-prefix")
whitelistNamespaces, blacklistPodPrefixes := sliceToMap(ctx.StringSlice("pod-namespace")), ctx.StringSlice("pod-prefix")
var wg sync.WaitGroup
log.Printf("%s %s starting", ctx.App.Name, ctx.App.Version)
@ -96,11 +96,11 @@ var App = &cli.App{
continue
}
if _, ok := filterNamespace[kubeInfo.Namespace]; !ok {
if _, ok := whitelistNamespaces[kubeInfo.Namespace]; !ok {
continue
}
if ok := hasSlicePrefix(kubeInfo.Pod, filterPodPrefixes); !ok {
if ok := hasSlicePrefix(kubeInfo.Pod, blacklistPodPrefixes); ok {
continue
}