-
-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Native client apply support #1574
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1574 +/- ##
=======================================
- Coverage 75.2% 75.0% -0.2%
=======================================
Files 82 82
Lines 7335 7355 +20
=======================================
Hits 5514 5514
- Misses 1821 1841 +20
|
0288752
to
78f7608
Compare
kube-client/src/client/client_ext.rs
Outdated
let req = match subresource { | ||
Subresource::Core => req.patch(name, pp, patch).map_err(Error::BuildRequest)?, | ||
Subresource::Status => req | ||
.patch_subresource("status", name, pp, patch) | ||
.map_err(Error::BuildRequest)?, | ||
Subresource::Scale => req | ||
.patch_subresource("scale", name, pp, patch) | ||
.map_err(Error::BuildRequest)?, | ||
Subresource::Custom(subresource) => req | ||
.patch_subresource(subresource, name, pp, patch) | ||
.map_err(Error::BuildRequest)?, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting idea with the enum here. i am a little skeptical of it's benefit because it means the documentation must be smashed together for all the variants. separated is fairly easy to read on the client side, and doesn't require a new enum (that i'm pretty sure they'd only need to create for this call anyway).
the original style in api:
client.patch
client.patch_status
client.patch_scale
client.patch_subresource
feels preferable to me, unless you have any good reasons.
kube-client/src/client/client_ext.rs
Outdated
K: ResourceExt + Serialize + DeserializeOwned + Clone + Debug, | ||
<K as Resource>::DynamicType: Default, | ||
{ | ||
let name = resource.meta().name.as_ref().ok_or(Error::NameResolve)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name assumption actually severely constrains the usability of patch
to only Patch::Apply
and the subset of others that happen to be typed to contain the complete metadata.
I.e. it generally excludes merge patches, strategic merge patches and json patches
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My idea/end goal here is to simplify some of the pain points, occurring while using Apply
patch, without introducing a custom DSL, like in https://pkg.go.dev/k8s.io/client-go/applyconfigurations, just to provide a apiVersion and kind for the apply patch.
It makes sense to address this incompatibility with other patch types. Need to think it through
0928b11
to
aa70e33
Compare
Signed-off-by: Danil-Grigorev <[email protected]>
Signed-off-by: Danil-Grigorev <[email protected]>
Signed-off-by: Danil-Grigorev <[email protected]>
Signed-off-by: Danil-Grigorev <[email protected]>
d8c68fd
to
770b954
Compare
Motivation
Add support for resource apply using
unstable-client
implementation.This implementation addresses the need for https://pkg.go.dev/k8s.io/client-go/applyconfigurations, where the need for a custom DSL is justified by limitations of default values for the go structures.
It seems with exception of some resources where API is not designed to use SSA patch, and a separate patch definition needed, this abstraction can simplify usage of the SSA in general cases.
Equivalent structs in rust allow to distinguish a
nil
value from an””
(empty string), as a pointer value is wrapped inOption<V>
, thus rendering current state of structures sufficient to address limitation in native to object SSA patch usage.However there is a second problem with
TypeMeta
. When constructing an object from a type, like&Pod::default()
, the structure does not containtype
meta from the beginning, although generated ork8s-openapi
definitions have all the necessary information for constructing the field.Solution
Provide a native to the client
.apply
and.apply_status
methods. These can be used to pass a subset of resource changes to be applied via SSA patch.