Skip to content

Add explicit Apply method to ClientApplicator#115

Merged
DMilmont merged 1 commit intoreddit:mainfrom
DMilmont:clientapplicator-explicit-apply
May 6, 2026
Merged

Add explicit Apply method to ClientApplicator#115
DMilmont merged 1 commit intoreddit:mainfrom
DMilmont:clientapplicator-explicit-apply

Conversation

@DMilmont
Copy link
Copy Markdown
Contributor

@DMilmont DMilmont commented May 6, 2026

When consumers use a newer controller-runtime than the SDK, the promoted method set on ClientApplicator breaks. This will also be a problem if/when the SDK itself upgrades.

Note: The SDK itself is not yet on controller-runtime v0.22, making this a preemptive fix. That said, the change is minimal and removes complexity that any consumer on v0.22+ would otherwise have to work around independently. It also means one (minor) fewer thing to address if/when this is upgraded to v0.22+

This is probably worth discussing if this is worth adding now vs later (v0.22+)

Closes # #114

💸 TL;DR

controller-runtime v0.22 added Apply to client.Client. Since ClientApplicator embeds both client.Client and Applicator (which also has Apply), Go's method promotion becomes ambiguous for consumers on v0.22+. This adds an explicit Apply method that delegates to Applicator.Apply, resolving the ambiguity with zero behavioral change.

📜 Details

Background:

  • PR Fix controller-runtime v0.23 Apply ambiguity #108 fixed internal SDK call sites affected by this ambiguity but did not address the ClientApplicator struct's public API.
  • PR add option to do server side apply #113 (server-side apply option) is orthogonal and can coexist with this change.
  • This fix is backwards compatible: on controller-runtime v0.21 (current), promotion still works the same way. The explicit method simply makes the delegation unambiguous regardless of controller-runtime version.

What changed:

  • Added func (ca *ClientApplicator) Apply(...) that delegates to ca.Applicator.Apply(...)
  • Added var _ Applicator = (*ClientApplicator)(nil) compile-time check

Why now:
Downstream consumers that depend on achilles-sdk but use controller-runtime v0.22+ are currently broken by this ambiguity. This will also be required when achilles-sdk itself upgrades to v0.22.

🧪 Testing Steps / Validation

  • go build ./... passes across the entire SDK
  • Compile-time interface satisfaction check (var _ Applicator = (*ClientApplicator)(nil)) serves as a regression guard
  • Existing tests in pkg/io/applicator_test.go exercise applicator.Apply(...) and compile cleanly with the new explicit method
  • Zero behavioral change - the explicit method delegates identically to what promotion previously resolved

✅ Checks

  • CI tests (if present) are passing
  • Adheres to code style for repo
  • Contributor License Agreement (CLA) completed if not a Reddit employee - am Reddit employee

Resolves method ambiguity for external consumers that use a newer
controller-runtime (v0.22+) where client.Client gains its own Apply
method. Without this, *ClientApplicator has two promoted Apply methods
with incompatible signatures, causing compile errors in downstream repos.

Includes a compile-time interface satisfaction check for Applicator.
@DMilmont DMilmont marked this pull request as ready for review May 6, 2026 19:41
@DMilmont DMilmont requested a review from a team as a code owner May 6, 2026 19:41
@DMilmont DMilmont requested a review from erik-ringsmuth May 6, 2026 19:41
@erik-ringsmuth erik-ringsmuth requested a review from harveyxia May 6, 2026 20:20
Copy link
Copy Markdown

@erik-ringsmuth erik-ringsmuth left a comment

Choose a reason for hiding this comment

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

I like this approach! I'm adding @harveyxia as well since he had a different idea, but I think this is better because it's not a breaking change.

Copy link
Copy Markdown
Collaborator

@harveyxia harveyxia left a comment

Choose a reason for hiding this comment

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

Awesome, nice and simple fix that is backwards compatible.

And users will still have access to the controller-runtime method by calling c.Client.Apply()

@DMilmont DMilmont merged commit fcb905d into reddit:main May 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants