Skip to content

Commit 0521da0

Browse files
committed
Export redact and select field lists
Signed-off-by: Charlie Egan <[email protected]>
1 parent 6f453d7 commit 0521da0

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

pkg/datagatherer/k8s/dynamic.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,7 @@ func redactList(list *unstructured.UnstructuredList) error {
176176
for _, gvk := range gvks {
177177
// If this item is a Secret then we need to redact it.
178178
if gvk.Kind == "Secret" && (gvk.Group == "core" || gvk.Group == "") {
179-
Select([]string{
180-
"kind",
181-
"apiVersion",
182-
"metadata.name",
183-
"metadata.namespace",
184-
"type",
185-
"/data/tls.crt",
186-
"/data/ca.crt",
187-
}, &resource)
179+
Select(SecretSelectedFields, &resource)
188180

189181
// break when the object has been processed as a secret, no
190182
// other kinds have redact modifications

pkg/datagatherer/k8s/fieldfilter.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ import (
99
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
1010
)
1111

12+
// SecretSelectedFields is the list of fields sent from Secret objects to the
13+
// backend
14+
var SecretSelectedFields = []string{
15+
"kind",
16+
"apiVersion",
17+
"metadata.name",
18+
"metadata.namespace",
19+
"type",
20+
"/data/tls.crt",
21+
"/data/ca.crt",
22+
}
23+
1224
// Select removes all but the supplied fields from the resource
1325
func Select(fields []string, resource *unstructured.Unstructured) error {
1426
// convert the object to JSON for field filtering

0 commit comments

Comments
 (0)