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 2 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]>
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