Skip to content

Commit

Permalink
Fix null pointer when secret has no owner (#168)
Browse files Browse the repository at this point in the history
Resolves #166
  • Loading branch information
181192 authored Mar 25, 2021
1 parent 5b782aa commit bb751ae
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/azure-keyvault-controller/controller/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,10 @@ func createNewSecretFromExisting(akvs *akv.AzureKeyVaultSecret, values map[strin
if existingSecret.Type != corev1.SecretTypeOpaque {
if !isOwnedBy(existingSecret, akvs) {
controlledBy := metav1.GetControllerOf(existingSecret)
return nil, fmt.Errorf("cannot update existing secret %s/%s of type %s controlled by %s, as this azurekeyvalutsecret %s would overwrite keys", existingSecret.Namespace, existingSecret.Name, existingSecret.Type, controlledBy.Name, akvs.Name)
if controlledBy != nil {
return nil, fmt.Errorf("cannot update existing secret %s/%s of type %s controlled by %s, as this azurekeyvalutsecret %s would overwrite keys", existingSecret.Namespace, existingSecret.Name, existingSecret.Type, controlledBy.Name, akvs.Name)
}
return nil, fmt.Errorf("cannot update existing secret %s/%s of type %s not controlled by akv2k8s, as this azurekeyvalutsecret %s would overwrite keys", existingSecret.Namespace, existingSecret.Name, existingSecret.Type, akvs.Name)
}
}

Expand Down

0 comments on commit bb751ae

Please sign in to comment.