From 0a0620b8705966852104cd62c03427eba20aff68 Mon Sep 17 00:00:00 2001 From: Lan Phan Date: Fri, 13 Sep 2024 15:31:51 +0700 Subject: [PATCH] add new tag unprintable to prevent printing specific field --- pkg/dynamic/print_config.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/dynamic/print_config.go b/pkg/dynamic/print_config.go index a60d30618..4013cb893 100644 --- a/pkg/dynamic/print_config.go +++ b/pkg/dynamic/print_config.go @@ -91,6 +91,10 @@ func PrintConfig(s interface{}, f io.Writer, style *table.Style, withColor bool, continue } if jtag := tt.Tag.Get("json"); jtag != "" && jtag != "-" { + unprintable := tt.Tag.Get("unprintable") + if unprintable == "true" { + continue + } name := strings.Split(jtag, ",")[0] if _, ok := redundantSet[name]; ok { continue @@ -106,6 +110,10 @@ func PrintConfig(s interface{}, f io.Writer, style *table.Style, withColor bool, } default: name := strings.Split(jsonTag, ",")[0] + unprintable := t.Tag.Get("unprintable") + if unprintable == "true" { + continue + } if _, ok := redundantSet[name]; ok { continue }