Skip to content

Commit

Permalink
Merge branch 'access-policies-fix' of https://github.com/cnadolny/azu…
Browse files Browse the repository at this point in the history
…re-service-operator into access-policies-fix
  • Loading branch information
cnadolny committed Feb 29, 2020
2 parents 9b6aa84 + 5447f85 commit 264faef
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pkg/resourcemanager/azuresql/azuresqluser/azuresqluser.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,27 +146,31 @@ func (s *AzureSqlUserManager) Ensure(ctx context.Context, obj runtime.Object, op
}

var adminSecretClient secrets.SecretClient
// if the admin credentials haven't been set, default admin credentials to servername
if len(instance.Spec.AdminSecret) == 0 {
instance.Spec.AdminSecret = instance.Namespace + "-" + instance.Spec.Server
}

var key types.NamespacedName
// if the admin secret keyvault is not specified, assume it is a kube secret
if len(instance.Spec.AdminSecretKeyVault) == 0 {
if options.KubeClient != nil {
adminSecretClient = k8sSecrets.New(options.KubeClient)
if len(instance.Spec.AdminSecret) == 0 {
instance.Spec.AdminSecret = instance.Spec.Server
}
key = types.NamespacedName{Name: instance.Spec.AdminSecret, Namespace: instance.Namespace}
} else {
return false, err
}
} else {
adminSecretClient = keyvaultSecrets.New(instance.Spec.AdminSecretKeyVault)
if len(instance.Spec.AdminSecret) == 0 {
instance.Spec.AdminSecret = instance.Namespace + "-" + instance.Spec.Server
}
key = types.NamespacedName{Name: instance.Spec.AdminSecret}
}

// need this to detect missing databases
dbClient := azuresqldb.NewAzureSqlDbManager(s.Log)

// get admin creds for server
key := types.NamespacedName{Name: instance.Spec.AdminSecret}
adminSecret, err := adminSecretClient.Get(ctx, key)
if err != nil {
instance.Status.Provisioning = false
Expand Down

0 comments on commit 264faef

Please sign in to comment.