You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Api<PartialObjectMeta<K>> should opportunistically degrade to metadata requests (#1952)
* feat(kube-core): add metadata_api() to Resource trait
Add `fn metadata_api() -> bool` to the `Resource` trait (default false),
overridden to return true for `PartialObjectMeta<K>`. This allows
downstream code to detect metadata-only types at compile time and
automatically switch to efficient metadata-optimized API requests.
Ref: #1614
Signed-off-by: doxxx93 <doxxx93@gmail.com>
* feat(kube-client): auto-use metadata headers for PartialObjectMeta
Api methods get, list, watch, and patch now branch on
Resource::metadata_api() to automatically use metadata-optimized
Accept headers when K = PartialObjectMeta<_>, so the API server
returns only metadata instead of the full object.
Ref: #1614
Signed-off-by: doxxx93 <doxxx93@gmail.com>
* refactor(kube-runtime): deprecate metadata_watcher
With Api<PartialObjectMeta<K>> now automatically using metadata-only
requests, metadata_watcher is no longer needed. Users can use
watcher(Api::<PartialObjectMeta<K>>::all(client), config) instead.
Simplify the dynamic_watcher example to remove the runtime branching
and focus on dynamic resource watching.
Ref: #1614
Signed-off-by: doxxx93 <doxxx93@gmail.com>
* test(kube-client): verify PartialObjectMeta uses metadata headers
Add mock-based tests verifying that Api<PartialObjectMeta<Pod>>
sends the correct metadata-only Accept headers for get, list, watch,
and patch operations.
Ref: #1614
Signed-off-by: doxxx93 <doxxx93@gmail.com>
* refactor: cache metadata_api on Api to avoid tightening method bounds
PR review feedback (clux): the original PR added `K: Resource` to
`impl<K> Api<K>` in core_methods.rs (so it could call `K::metadata_api()`
per request), which forced the same bound onto `ApiMode for FullObject<K>`
and `ApiMode for MetaOnly<K>` in watcher.rs. This goes against the spirit
of #1393 by tightening method-level bounds beyond what the corresponding
Api/watcher constructors already require.
Cache the flag on `Api<K>` itself in the existing `impl<K: Resource> Api<K>`
constructors, then read `self.metadata_api` from the per-method code paths.
The Resource bound stays exactly where it was before this PR (Api
constructors and the public `watcher`/`metadata_watcher` signatures),
no user-visible API change.
See #1952 (comment)
Signed-off-by: doxxx93 <doxxx93@gmail.com>
---------
Signed-off-by: doxxx93 <doxxx93@gmail.com>
Co-authored-by: Eirik A <sszynrae@gmail.com>
0 commit comments