Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add ObjectRef::from as alias for ::from_obj #1598

Merged
merged 1 commit into from
Oct 9, 2024

Conversation

nightkr
Copy link
Member

@nightkr nightkr commented Oct 9, 2024

Motivation

This allows things that rely on From/Into to perform the conversion implicitly. For example, we (@stackabletech) use ObjectRefs to normalize object path formatting in errors. When using SNAFU, this would simplify the error annotations from:

do_stuff().with_context(|_| ErrorCaseSnafu { pod: ObjectRef::from_obj(&pod) })?

to:

do_stuff().context(ErrorCaseSnafu { pod: &pod })?

Solution

The From impl just delegates to ::from_obj(). Maybe it would even make sense to deprecate ::from_obj, but I think it makes sense to keep it to highlight it as a first-class operation.

Signed-off-by: Natalie Klestrup Röijezon <nat@nullable.se>
@nightkr nightkr added runtime controller runtime related ergonomics ergonomics of the public interface labels Oct 9, 2024
@nightkr nightkr requested a review from clux October 9, 2024 10:53
Copy link

codecov bot commented Oct 9, 2024

Codecov Report

Attention: Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 75.2%. Comparing base (62f95cd) to head (1ed864a).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
kube-runtime/src/reflector/object_ref.rs 33.4% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1598     +/-   ##
=======================================
- Coverage   75.2%   75.2%   -0.0%     
=======================================
  Files         82      82             
  Lines       7334    7336      +2     
=======================================
  Hits        5514    5514             
- Misses      1820    1822      +2     
Files with missing lines Coverage Δ
kube-runtime/src/reflector/object_ref.rs 68.0% <33.4%> (-1.3%) ⬇️

Copy link
Member

@clux clux left a comment

Choose a reason for hiding this comment

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

Nice. LGTM

@clux clux added the changelog-add changelog added category for prs label Oct 9, 2024
@clux clux added this to the 0.96.0 milestone Oct 9, 2024
@nightkr nightkr merged commit 023ecc3 into kube-rs:main Oct 9, 2024
17 checks passed
@nightkr nightkr deleted the feature/objectref-from branch October 9, 2024 14:03
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
changelog-add changelog added category for prs ergonomics ergonomics of the public interface runtime controller runtime related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants