Skip to content

Conversation

cbandy
Copy link
Member

@cbandy cbandy commented Aug 25, 2025

This is the same idea as #4253, but for the PostgresCluster controller: it separates the client.Client interface into three. Similarly, this increases the amount of code covered by make check.

This refactor is another step toward my goal of a single, shared SSA Apply function.

Checklist:

  • Have you added an explanation of what your changes do and why you'd like them to be included?
  • Have you updated or added documentation for the change, as applicable?
  • Have you tested your changes on all related environments with successful results, as applicable?
    • Have you added automated tests?

Type of Changes:

  • Testing enhancement
  • Other

Wait for these and rebase after:

obj.Labels = map[string]string{naming.LabelCluster: clusterName}

if err := r.Client.Create(ctx, obj); err != nil {
if err := tClient.Create(ctx, obj); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It takes me a moment to remember what part is setup and what part is test, but when I do, I like this distinction

We want to be mindful of our interactions with the Kubernetes API, and
these interfaces will help keep functions focused. These interfaces are
also narrower than client.Reader and client.Writer and may help us keep
RBAC markers accurate.

A new constructor populates these fields with a single client.Client.
The client.WithFieldOwner constructor allows us to drop our Owner field
and patch method.

This allows `make check` to cover 9% more of the "postgrescluster" package.
@cbandy cbandy enabled auto-merge (rebase) September 19, 2025 16:27
@cbandy cbandy merged commit af97e79 into CrunchyData:main Sep 19, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants