Skip to content

Commit 97b64e4

Browse files
handling duplicate if different schema is provided
1 parent 5ee74f6 commit 97b64e4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

controllers/postgresql/grant_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func (r *GrantReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl
224224
return ctrl.Result{}, nil
225225
}
226226
} else if currentGrantType == common.GRANTTABLE {
227-
if check_all.MatchString(*existingGrant.Spec.Table) {
227+
if check_all.MatchString(*existingGrant.Spec.Table) && existingGrant.Spec.Schema != grant.Spec.Schema{
228228
reason := fmt.Sprintf(
229229
"Already a grant `%s/%s` created with ALL tables permission for role `%s/%s`. So delete this grant `%s/%s`",
230230
existingGrant.Namespace,
@@ -237,7 +237,7 @@ func (r *GrantReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl
237237
r.appendGrantStatusCondition(ctx, grant, common.FAIL, metav1.ConditionFalse, GRANTDUPLICATED, reason)
238238
grantLogger.Error(err, reason)
239239
return ctrl.Result{}, nil
240-
} else if existingGrant.Spec.Table == grant.Spec.Table {
240+
} else if existingGrant.Spec.Table == grant.Spec.Table && existingGrant.Spec.Schema != grant.Spec.Schema{
241241
reason := fmt.Sprintf(
242242
"Already a grant `%s/%s` created with `%s` table permission for role `%s/%s`. So delete this grant `%s/%s`",
243243
existingGrant.Namespace,

0 commit comments

Comments
 (0)