WIP: Native client apply support#1574
Conversation
Codecov Report❌ 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
🚀 New features to boost your workflow:
|
0288752 to
78f7608
Compare
| 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.
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.patchclient.patch_statusclient.patch_scaleclient.patch_subresource
feels preferable to me, unless you have any good reasons.
| 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.
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.
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 <danil.grigorev@suse.com>
Signed-off-by: Danil-Grigorev <danil.grigorev@suse.com>
Signed-off-by: Danil-Grigorev <danil.grigorev@suse.com>
Signed-off-by: Danil-Grigorev <danil.grigorev@suse.com>
d8c68fd to
770b954
Compare
Motivation
Add support for resource apply using
unstable-clientimplementation.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
nilvalue 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 containtypemeta from the beginning, although generated ork8s-openapidefinitions have all the necessary information for constructing the field.Solution
Provide a native to the client
.applyand.apply_statusmethods. These can be used to pass a subset of resource changes to be applied via SSA patch.