From c1d3715ce79815d02d9dd322ae08dbaa1b187e2f Mon Sep 17 00:00:00 2001 From: Matthias Bertschy Date: Thu, 27 Jun 2024 11:53:58 +0200 Subject: [PATCH] export ParseCalicoSelector Signed-off-by: Matthias Bertschy --- armometadata/k8sutils.go | 4 ++-- armometadata/k8sutils_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/armometadata/k8sutils.go b/armometadata/k8sutils.go index 1020006..4754a47 100644 --- a/armometadata/k8sutils.go +++ b/armometadata/k8sutils.go @@ -154,14 +154,14 @@ func ExtractMetadataFromJsonBytes(input []byte) (Metadata, error) { case m.ApiVersion == "security.istio.io/v1" && strings.HasPrefix(jsonPath, "spec.selector.matchLabels."): m.PodSelectorMatchLabels[unquote(key)] = unquote(value) case m.ApiVersion == "projectcalico.org/v3" && jsonPath == "spec.selector": - m.PodSelectorMatchLabels = parseCalicoSelector(value) + m.PodSelectorMatchLabels = ParseCalicoSelector(value) } return true }) return m, err } -func parseCalicoSelector(value []byte) map[string]string { +func ParseCalicoSelector(value []byte) map[string]string { selector := map[string]string{} for _, rule := range strings.Split(unquote(value), "&&") { s := strings.Split(rule, "==") diff --git a/armometadata/k8sutils_test.go b/armometadata/k8sutils_test.go index 1f80d8d..870f24e 100644 --- a/armometadata/k8sutils_test.go +++ b/armometadata/k8sutils_test.go @@ -311,7 +311,7 @@ func Test_parseCalicoSelector(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - assert.Equalf(t, tt.want, parseCalicoSelector(tt.value), "parseCalicoSelector(%v)", tt.value) + assert.Equalf(t, tt.want, ParseCalicoSelector(tt.value), "ParseCalicoSelector(%v)", tt.value) }) } }