Explorar o código

fix: assign default value to prevent nil panic (#2722)

Signed-off-by: Moritz Johner <beller.moritz@googlemail.com>
Moritz Johner %!s(int64=3) %!d(string=hai) anos
pai
achega
d59512e604
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      pkg/provider/kubernetes/client.go

+ 3 - 0
pkg/provider/kubernetes/client.go

@@ -363,6 +363,9 @@ func (c *Client) removeProperty(ctx context.Context, extSecret *v1.Secret, remot
 }
 
 func (c *Client) updateProperty(ctx context.Context, extSecret *v1.Secret, remoteRef esv1beta1.PushRemoteRef, value []byte) error {
+	if extSecret.Data == nil {
+		extSecret.Data = make(map[string][]byte)
+	}
 	// otherwise update remote secret
 	extSecret.Data[remoteRef.GetProperty()] = value
 	_, uErr := c.userSecretClient.Update(ctx, extSecret, metav1.UpdateOptions{})