Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix null pointer when secret has no owner #168

Merged
merged 1 commit into from
Mar 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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