-
-
Notifications
You must be signed in to change notification settings - Fork 323
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
feat: Add typed scale argument to derive macro #1656
base: main
Are you sure you want to change the base?
Conversation
This allows cutomizing the scale subresource by providing key-value items instead of a raw JSON string. For backwards-compatibility, it is still supported to provide a JSON string. However, all examples and tests were converted to the new format. Signed-off-by: Techassi <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1656 +/- ##
=======================================
- Coverage 75.6% 75.1% -0.4%
=======================================
Files 82 82
Lines 7405 7453 +48
=======================================
+ Hits 5591 5592 +1
- Misses 1814 1861 +47
|
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.
Hey there. Thanks for this! Apologise for the delay.
I think this makes sense, given you've made it non-breaking, but ideally the dependency on the openapi crate should be severed if it's just for the interface. Have added a few suggestive comments.
@@ -19,6 +19,7 @@ proc-macro2.workspace = true | |||
quote.workspace = true | |||
syn = { workspace = true, features = ["extra-traits"] } | |||
serde_json.workspace = true | |||
k8s-openapi = { workspace = true, features = ["latest"] } |
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 feels unfortunate. don't really want a derive crate (which is hard to optimise compile wise) to depend on such a big crate.
/// Customize the scale subresource, see [Kubernetes docs][1]. | ||
/// | ||
/// [1]: https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#scale-subresource | ||
scale: Option<Scale>, |
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.
if the dependency is just for this struct, then maybe we should inline that for the interface instead. It would also avoid having to do the newtyping you do below.
// - To enable backwards-compatibility. Up to version 0.97.0 it was only possible to set scale | ||
// subresource values as a JSON string. |
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.
Maybe there's a way to add a deprecated message to the old way?
No worries. I will shortly take a look at your comments. I will also see if we can get rid of the |
Motivation
Customizing the
scale
subresource via#[kube(scale = r#"{}"#)]
can feel very out-of-place and requires writing a raw JSON string. In addition, this can lead to a very long line, eg:Solution
This allows customizing the scale subresource by providing key-value items instead of a raw JSON string. For backwards-compatibility, it is still supported to provide a JSON string. However, all examples and tests were converted to the new format.