Skip to content

Commit 6b789fe

Browse files
committed
fix: tests
1 parent ab2d249 commit 6b789fe

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

internal/controller/postgres_controller.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func (r *PostgresReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
170170
}
171171

172172
desiredOwner := instance.Spec.MasterRole
173-
// reconcile instance.Spec.MasterRole if it was changed
173+
// If no owner was specified, use default owner name
174174
if desiredOwner == "" {
175175
desiredOwner = fmt.Sprintf("%s-group", instance.Spec.Database)
176176
}
@@ -181,15 +181,12 @@ func (r *PostgresReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
181181
if err != nil {
182182
return requeue(errors.NewInternalError(err))
183183
}
184-
instance.Status.Roles.Owner = desiredOwner
185-
}
186-
187-
// reconcile the desired owner of the database
188-
if instance.Status.Roles.Owner != "" {
184+
// Alter database owner if the owner role was changed
189185
err = r.pg.AlterDatabaseOwner(instance.Spec.Database, instance.Status.Roles.Owner)
190186
if err != nil {
191187
return requeue(errors.NewInternalError(err))
192188
}
189+
instance.Status.Roles.Owner = desiredOwner
193190
}
194191

195192
// create extensions

internal/controller/postgresuser_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ func (r *PostgresUserReconciler) Reconcile(ctx context.Context, req ctrl.Request
195195
desiredGroup = database.Status.Roles.Owner
196196
}
197197

198+
// Ability user to be reassigned to another group role
198199
currentGroup := instance.Status.PostgresGroup
199200
if desiredGroup != "" && currentGroup != desiredGroup {
200201

0 commit comments

Comments
 (0)