Skip to content

Commit 7e7a3b7

Browse files
committed
fix: patch roles properly (#7)
Patch call expects a modified existing resource as the first argument, not a set of new values. Now this logic should match official docs: https://sdk.operatorframework.io/docs/building-operators/golang/references/client/#patch Signed-off-by: Szymon Soloch <[email protected]>
1 parent 039848f commit 7e7a3b7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

internal/cnpgi/operator/reconciler.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,10 @@ func (r ReconcilerImplementation) ensureRole(
184184
"namespace", newRole.Namespace,
185185
"rules", newRole.Rules,
186186
)
187-
// TODO: Something is wrong here, we also should check for ownership.
188-
return r.Client.Patch(ctx, newRole, client.MergeFrom(&role))
187+
188+
patch := client.MergeFrom(role.DeepCopy())
189+
role.Rules = newRole.Rules
190+
return r.Client.Patch(ctx, &role, patch)
189191
}
190192

191193
func (r ReconcilerImplementation) ensureRoleBinding(

0 commit comments

Comments
 (0)