Skip to content

Commit 8cffbd9

Browse files
committed
Send secret annotations to platform
To allow users to filter out system certificates, we need to check their annotations. Currently, the agent does not send these. This commit modifies the agent to provide annotations in the request to the backend
1 parent 2ae7e2c commit 8cffbd9

File tree

2 files changed

+5
-18
lines changed

2 files changed

+5
-18
lines changed

pkg/datagatherer/k8s/dynamic_test.go

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,31 +61,17 @@ func getSecret(name, namespace string, data map[string]interface{}, isTLS bool,
6161
}
6262

6363
metadata, _ := object.Object["metadata"].(map[string]interface{})
64+
annotations := make(map[string]interface{})
6465

6566
// if we're creating a 'raw' secret as scraped that was applied by kubectl
6667
if withLastApplied {
6768
jsonData, _ := json.Marshal(data)
68-
metadata["annotations"] = map[string]interface{}{
69-
"kubectl.kubernetes.io/last-applied-configuration": string(jsonData),
70-
}
69+
annotations["kubectl.kubernetes.io/last-applied-configuration"] = string(jsonData)
7170
}
7271

73-
return object
74-
}
72+
metadata["annotations"] = annotations
7573

76-
func asUnstructuredList(items ...*unstructured.Unstructured) *unstructured.UnstructuredList {
77-
itemsNonPtr := make([]unstructured.Unstructured, len(items))
78-
for i, u := range items {
79-
itemsNonPtr[i] = *u
80-
}
81-
return &unstructured.UnstructuredList{
82-
Object: map[string]interface{}{
83-
"metadata": map[string]interface{}{
84-
"resourceVersion": "",
85-
},
86-
},
87-
Items: itemsNonPtr,
88-
}
74+
return object
8975
}
9076

9177
func sortGatheredResources(list []*api.GatheredResource) {

pkg/datagatherer/k8s/fieldfilter.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
var SecretSelectedFields = []string{
1515
"kind",
1616
"apiVersion",
17+
"metadata.annotations",
1718
"metadata.name",
1819
"metadata.namespace",
1920
"metadata.ownerReferences",

0 commit comments

Comments
 (0)