Skip to content
This repository has been archived by the owner on Jan 28, 2022. It is now read-only.

Commit

Permalink
Putting back in ACL check.
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonTheDeveloper committed Nov 26, 2019
1 parent 5cd0976 commit f81c590
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions controllers/secretscope_controller_databricks.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ func (r *SecretScopeReconciler) submitACLs(instance *databricksv1alpha1.SecretSc
// verifyWorkspace checks if Databricks cluster supports ACLs, and checks if secret scope exists.
func (r *SecretScopeReconciler) verifyWorkspace(instance *databricksv1alpha1.SecretScope) error {
scope := instance.ObjectMeta.Name
initialManagePrincipal := instance.Spec.InitialManagePrincipal

// try create secret scope to see if exists or not.
list, err := r.APIClient.Secrets().ListSecretScopes()
Expand All @@ -168,6 +169,21 @@ func (r *SecretScopeReconciler) verifyWorkspace(instance *databricksv1alpha1.Sec
}
}

// create the secret scope here otherwise we cannot verify ACL support.
err = r.APIClient.Secrets().CreateSecretScope(scope, initialManagePrincipal)
if err != nil {
return err
}

// try to list ACLs to see if cluster supports ACL.
if instance.Spec.SecretScopeACLs != nil {
if _, err = r.APIClient.Secrets().ListSecretACLs(scope); err != nil {
// delete secret scope because we're unable to deploy scope with ACL.
_ = r.APIClient.Secrets().DeleteSecretScope(scope)
return err
}
}

return nil
}

Expand All @@ -189,15 +205,8 @@ func (r *SecretScopeReconciler) checkSecrets(instance *databricksv1alpha1.Secret

func (r *SecretScopeReconciler) submit(instance *databricksv1alpha1.SecretScope) error {
scope := instance.ObjectMeta.Name
initialManagePrincipal := instance.Spec.InitialManagePrincipal

// try create secret scope to see if exists or not.
err := r.APIClient.Secrets().CreateSecretScope(scope, initialManagePrincipal)
if err != nil {
return err
}

err = r.submitSecrets(instance)
err := r.submitSecrets(instance)
if err != nil {
return err
}
Expand Down

0 comments on commit f81c590

Please sign in to comment.