Skip to content

Commit 13c0e6a

Browse files
committed
upkeep: modernisert loop til å bruke contains
1 parent 0ebd955 commit 13c0e6a

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

pkg/naiserator/config/config.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
log "github.com/sirupsen/logrus"
99
flag "github.com/spf13/pflag"
1010

11+
"slices"
12+
1113
"github.com/go-viper/mapstructure/v2"
1214
"github.com/spf13/viper"
1315
)
@@ -374,23 +376,14 @@ func init() {
374376

375377
// Print out all configuration options except secret stuff.
376378
func Print(redacted []string) {
377-
ok := func(key string) bool {
378-
for _, forbiddenKey := range redacted {
379-
if forbiddenKey == key {
380-
return false
381-
}
382-
}
383-
return true
384-
}
385-
386379
var keys sort.StringSlice = viper.AllKeys()
387380

388381
keys.Sort()
389382
for _, key := range keys {
390-
if ok(key) {
391-
log.Printf("%s: %v", key, viper.Get(key))
392-
} else {
383+
if slices.Contains(redacted, key) {
393384
log.Printf("%s: ***REDACTED***", key)
385+
} else {
386+
log.Printf("%s: %v", key, viper.Get(key))
394387
}
395388
}
396389
}

0 commit comments

Comments
 (0)