Skip to content

Call typed defaulter for reconciled object#677

Merged
scothis merged 1 commit intoreconcilerio:mainfrom
scothis:typed-defaults
Feb 4, 2026
Merged

Call typed defaulter for reconciled object#677
scothis merged 1 commit intoreconcilerio:mainfrom
scothis:typed-defaults

Conversation

@scothis
Copy link
Member

@scothis scothis commented Feb 4, 2026

controller-runtime now encourages the use of a typed webhook methods instead of using runtime.Object. This change in method signature was causing the Default method to be missed during a reconcile, allowing non-defaulted objects to be processed. It is now called when the generic type matches the type being reconciled.

For example:

_ admission.Defaulter[*TestResource] = &TestResource{}

func (*TestResource) Default(ctx context.Context, obj *TestResource) error {
    ...
}

controller-runtime now encourages the use of a typed webhook methods
instead of using runtime.Object. This change in method signature was
causing the Default method to be missed during a reconcile, allowing
non-defaulted objects to be processed. It is now called when the
generic type matches the type being reconciled.

For example:

    _ admission.Defaulter[*TestResource] = &TestResource{}

    func (*TestResource) Default(ctx context.Context, obj *TestResource) error {
        ...
    }

Signed-off-by: Scott Andrews <scott@andrews.me>
@codecov
Copy link

codecov bot commented Feb 4, 2026

Codecov Report

❌ Patch coverage is 37.50000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.18%. Comparing base (9c9ed61) to head (3d3a747).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
reconcilers/webhook.go 25.00% 2 Missing and 1 partial ⚠️
reconcilers/resource.go 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #677      +/-   ##
==========================================
- Coverage   60.25%   60.18%   -0.08%     
==========================================
  Files          39       39              
  Lines        3628     3634       +6     
==========================================
+ Hits         2186     2187       +1     
- Misses       1329     1332       +3     
- Partials      113      115       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@scothis scothis merged commit e094974 into reconcilerio:main Feb 4, 2026
2 of 4 checks passed
@scothis scothis deleted the typed-defaults branch February 4, 2026 19:12
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.

1 participant