1
0
Fork 0
mirror of https://github.com/external-secrets/external-secrets.git synced 2024-12-14 11:57:59 +00:00

Use maps.Equal to compare maps (#3460)

Signed-off-by: shuheiktgw <s-kitagawa@mercari.com>
This commit is contained in:
Shuhei Kitagawa 2024-05-08 05:10:35 +09:00 committed by GitHub
parent bddca97cf2
commit 13dd16bf6d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -19,6 +19,7 @@ import (
"encoding/json"
"errors"
"fmt"
"maps"
"strconv"
"strings"
@ -181,7 +182,7 @@ func (c *Client) PushSecret(ctx context.Context, secret *corev1.Secret, pushSecr
return err
}
if !mapEqual(gcpSecret.Annotations, annotations) || !mapEqual(gcpSecret.Labels, labels) {
if !maps.Equal(gcpSecret.Annotations, annotations) || !maps.Equal(gcpSecret.Labels, labels) {
_, err = c.smClient.UpdateSecret(ctx, &secretmanagerpb.UpdateSecretRequest{
Secret: &secretmanagerpb.Secret{
Name: gcpSecret.Name,
@ -548,17 +549,3 @@ func getDataByProperty(data []byte, property string) gjson.Result {
}
return gjson.Get(payload, property)
}
func mapEqual(m1, m2 map[string]string) bool {
if len(m1) != len(m2) {
return false
}
for k1, v1 := range m1 {
if v2, ok := m2[k1]; !ok || v1 != v2 {
return false
}
}
return true
}