Skip to content

Commit d0949b6

Browse files
authored
Merge pull request #8 from Facets-cloud/pg-grant-stmt-fix
initialize statements in prev state if empty
2 parents 9ea2b75 + 1f9672f commit d0949b6

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

controllers/postgresql/grantstatement_controller.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,6 @@ func (r *GrantStatementReconciler) Reconcile(ctx context.Context, req ctrl.Reque
241241
return ctrl.Result{RequeueAfter: reconcileTime}, nil
242242
}
243243

244-
// Update the previous state in the status
245-
grantStatement.Status.PreviousGrantStatementState.Database = grantStatement.Spec.Database
246-
grantStatement.Status.PreviousGrantStatementState.RoleRef = grantStatement.Spec.RoleRef
247-
grantStatement.Status.PreviousGrantStatementState.Statements = grantStatement.Spec.Statements
248-
249244
r.appendGrantStatementStatusCondition(ctx, grantStatement, SUCCESS, metav1.ConditionTrue, GRANTSTATEMENT_EXECUTED, "Successfully executed grant statements")
250245
logger.Info(fmt.Sprintf("Successfully executed grant statements for GrantStatement %s", grantStatement.Name))
251246

@@ -375,6 +370,10 @@ func (r *GrantStatementReconciler) appendGrantStatementStatusCondition(ctx conte
375370
if len(grantStatement.Status.Conditions) > 5 {
376371
grantStatement.Status.Conditions = grantStatement.Status.Conditions[len(grantStatement.Status.Conditions)-5:]
377372
}
373+
// update previous state in the status
374+
grantStatement.Status.PreviousGrantStatementState.Database = grantStatement.Spec.Database
375+
grantStatement.Status.PreviousGrantStatementState.RoleRef = grantStatement.Spec.RoleRef
376+
grantStatement.Status.PreviousGrantStatementState.Statements = grantStatement.Spec.Statements
378377
err := r.Status().Update(ctx, grantStatement)
379378
if err != nil {
380379
logger.Error(err, fmt.Sprintf("Resource status update failed for GrantStatement %s", grantStatement.Name))

0 commit comments

Comments
 (0)