Skip to content

Commit

Permalink
Fix Helm warnings seen in cofidectl up
Browse files Browse the repository at this point in the history
After #62 merged we started seeing some warnings during cofidectl up.
This is due to a change in the type of the Helm values generated for
matchLabels in clusterSPIFFEIDs from map[string]any to
map[string]string.

This change reverts to map[string]any, which removes the warning.

Fixes: #65
  • Loading branch information
markgoddard committed Dec 6, 2024
1 parent 9a46cb8 commit 15b7fee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions internal/pkg/attestationpolicy/attestationpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ func getAPLabelSelectorHelmConfig(selector *attestation_policy_proto.APLabelSele
return nil
}

var matchExpressions = []map[string]any{}
matchLabels := map[string]any{}
for k, v := range selector.MatchLabels {
matchLabels[k] = v
}

matchExpressions := []map[string]any{}
for _, me := range selector.MatchExpressions {
matchExpressions = append(matchExpressions, map[string]any{
"key": me.GetKey(),
Expand All @@ -81,7 +85,7 @@ func getAPLabelSelectorHelmConfig(selector *attestation_policy_proto.APLabelSele
}

return map[string]any{
"matchLabels": selector.MatchLabels,
"matchLabels": matchLabels,
"matchExpressions": matchExpressions,
}
}
2 changes: 1 addition & 1 deletion pkg/provider/helm/values_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func TestHelmValuesGenerator_GenerateValues_success(t *testing.T) {
},
"namespaceSelector": Values{
"matchExpressions": []map[string]any{},
"matchLabels": map[string]string{
"matchLabels": map[string]any{
"kubernetes.io/metadata.name": "ns1",
},
},
Expand Down

0 comments on commit 15b7fee

Please sign in to comment.