@@ -27,6 +27,8 @@ import (
2727 "strings"
2828 "time"
2929
30+ "golang.org/x/exp/slices"
31+
3032 corev1 "k8s.io/api/core/v1"
3133 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3234 "k8s.io/apimachinery/pkg/runtime"
@@ -224,7 +226,7 @@ func (r *GrantReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl
224226 return ctrl.Result {}, nil
225227 }
226228 } else if currentGrantType == common .GRANTTABLE {
227- if check_all .MatchString (* existingGrant .Spec .Table ) && existingGrant .Spec .Schema ! = grant .Spec .Schema {
229+ if check_all .MatchString (* existingGrant .Spec .Table ) && existingGrant .Spec .Schema = = grant .Spec .Schema {
228230 reason := fmt .Sprintf (
229231 "Already a grant `%s/%s` created with ALL tables permission for role `%s/%s`. So delete this grant `%s/%s`" ,
230232 existingGrant .Namespace ,
@@ -237,7 +239,7 @@ func (r *GrantReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl
237239 r .appendGrantStatusCondition (ctx , grant , common .FAIL , metav1 .ConditionFalse , GRANTDUPLICATED , reason )
238240 grantLogger .Error (err , reason )
239241 return ctrl.Result {}, nil
240- } else if existingGrant .Spec .Table == grant .Spec .Table && existingGrant .Spec .Schema ! = grant .Spec .Schema {
242+ } else if existingGrant .Spec .Table == grant .Spec .Table && existingGrant .Spec .Schema = = grant .Spec .Schema {
241243 reason := fmt .Sprintf (
242244 "Already a grant `%s/%s` created with `%s` table permission for role `%s/%s`. So delete this grant `%s/%s`" ,
243245 existingGrant .Namespace ,
@@ -572,7 +574,7 @@ func (r *GrantReconciler) ObserveGrantState(ctx context.Context, grant *postgres
572574
573575 case common .GRANTTABLE :
574576 if check_all .MatchString (privileges [0 ]) {
575- privileges = []string {"INSERT" , "SELECT" , "UPDATE" , "DELETE" , "TRUNCATE" , "REFERENCES" , "TRIGGER" }
577+ privileges = []string {"INSERT" , "SELECT" , "UPDATE" , "DELETE" , "TRUNCATE" , "REFERENCES" , "TRIGGER" , "USAGE" }
576578 }
577579
578580 if check_all .MatchString (table ) {
@@ -603,6 +605,8 @@ func (r *GrantReconciler) ObserveGrantState(ctx context.Context, grant *postgres
603605 }
604606 sort .Sort (sort .StringSlice (privileges ))
605607 sort .Sort (sort .StringSlice (futureTablesResults ))
608+ privileges = slices .Compact (privileges )
609+ futureTablesResults = slices .Compact (futureTablesResults )
606610 if cmp .Equal (privileges , futureTablesResults ) {
607611 isGrantStateNotChanged = true
608612 } else {
0 commit comments