Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Techassi
Copy link
Contributor

@Techassi Techassi commented Dec 2, 2024

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:

#[kube(
    version = "v1alpha1",
    kind = "MyScaler",
    namespaced,
    scale = r#"{"specReplicasPath": ".spec.replicas", "statusReplicaPath": ".status.replicas", "labelSelectorPath": ".spec.labelSelector"}"#
)]
struct ScalerSpec {}

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.

#[kube(
    version = "v1alpha1",
    kind = "MyScaler",
    namespaced,
    scale(
        specReplicasPath = ".spec.replicas",
        statusReplicaPath = ".status.replicas",
        labelSelectorPath = ".spec.labelSelector"
   )
)]
struct ScalerSpec {}

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]>
Copy link

codecov bot commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 4.08163% with 47 lines in your changes missing coverage. Please review.

Project coverage is 75.1%. Comparing base (60d3ebc) to head (a36d0bd).

Files with missing lines Patch % Lines
kube-derive/src/custom_resource.rs 4.1% 47 Missing ⚠️
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     
Files with missing lines Coverage Δ
kube/src/lib.rs 88.5% <ø> (ø)
kube-derive/src/custom_resource.rs 67.2% <4.1%> (-15.2%) ⬇️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant