Add implementation plan for CLI and configuration test coverage

This commit is contained in:
2026-07-18 10:14:02 -05:00
parent 3c35124db4
commit 50191ee694
3 changed files with 715 additions and 8 deletions

View File

@@ -1,6 +1,7 @@
package config
import (
"reflect"
"strings"
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
@@ -126,17 +127,47 @@ func redactOptions(values map[string]any) map[string]any {
}
func redactOptionValue(value any) any {
switch typed := value.(type) {
case map[string]any:
return redactOptions(typed)
case []any:
items := make([]any, len(typed))
for i, item := range typed {
items[i] = redactOptionValue(item)
if value == nil {
return nil
}
reflected := reflect.ValueOf(value)
switch reflected.Kind() {
case reflect.Map:
if reflected.Type().Key().Kind() != reflect.String {
return value
}
if reflected.IsNil() {
return nil
}
out := make(map[string]any, reflected.Len())
iterator := reflected.MapRange()
for iterator.Next() {
key := iterator.Key().String()
if sensitiveConfigKey(key) {
out[key] = "[REDACTED]"
continue
}
out[key] = redactOptionValue(iterator.Value().Interface())
}
return out
case reflect.Slice:
if reflected.IsNil() {
return nil
}
if reflected.Type().Elem().Kind() == reflect.Uint8 {
out := reflect.MakeSlice(reflected.Type(), reflected.Len(), reflected.Len())
reflect.Copy(out, reflected)
return out.Interface()
}
fallthrough
case reflect.Array:
items := make([]any, reflected.Len())
for i := 0; i < reflected.Len(); i++ {
items[i] = redactOptionValue(reflected.Index(i).Interface())
}
return items
default:
return typed
return value
}
}