Skip to content

Commit

Permalink
Merge pull request #18 from armosec/netpol
Browse files Browse the repository at this point in the history
export ParseCalicoSelector
  • Loading branch information
matthyx authored Jun 27, 2024
2 parents 3f9b1a3 + c1d3715 commit 79eb014
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions armometadata/k8sutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "==")
Expand Down
2 changes: 1 addition & 1 deletion armometadata/k8sutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
}

0 comments on commit 79eb014

Please sign in to comment.