Skip to content

Conversation

Danil-Grigorev
Copy link
Member

@Danil-Grigorev Danil-Grigorev commented Oct 15, 2024

Motivation

KEP 4358 allows to define new field - selectableFields within the CRD schema, enabled by default (beta) in 1.31.

Solution

Expose the selectable key in kube() macro, allowing to provide a set of values into generated CRD.

Example:

#[kube(
    group = "clux.dev",
    version = "v1",
    kind = "Foo",
    namespaced,
    selectable = "spec.key",
    selectable = "spec.name"
)]

Signed-off-by: Danil-Grigorev <danil.grigorev@suse.com>
@clux clux added the changelog-add changelog added category for prs label Oct 15, 2024
@clux clux added this to the 0.97.0 milestone Oct 15, 2024
Signed-off-by: Danil-Grigorev <danil.grigorev@suse.com>
Copy link

codecov bot commented Oct 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.2%. Comparing base (95cf702) to head (9ed7f88).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1605     +/-   ##
=======================================
+ Coverage   75.2%   75.2%   +0.1%     
=======================================
  Files         82      82             
  Lines       7335    7342      +7     
=======================================
+ Hits        5514    5521      +7     
  Misses      1821    1821             
Files with missing lines Coverage Δ
kube-derive/src/custom_resource.rs 81.2% <100.0%> (+0.8%) ⬆️
kube-derive/src/lib.rs 0.0% <ø> (ø)
kube-derive/tests/crd_schema_test.rs 96.9% <ø> (ø)

Copy link
Member

@clux clux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Nice KEP also, had missed this! Maybe add a quick markdown header for it in the lib.rs file so people can discover it?

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>
@Danil-Grigorev Danil-Grigorev force-pushed the selectable-fields-support branch from 705e04c to 9ed7f88 Compare October 16, 2024 15:57
@Danil-Grigorev
Copy link
Member Author

Looks like CI failures are unrelated to the PR.

@clux
Copy link
Member

clux commented Oct 16, 2024

Looks like CI failures are unrelated to the PR.

indeed. dunno what's up with the rustls build atm. C library type errors :|

@clux clux merged commit 9dd62b9 into kube-rs:main Oct 17, 2024
17 checks passed
@aviramha
Copy link
Contributor

I think this breaks the Kubernetes version guarantee - requires openapi to upgraded to 1.31 to compile kube-rs as a dependency. @clux

@clux
Copy link
Member

clux commented Oct 18, 2024

oops, good spot. we need to version gate it!

@aviramha
Copy link
Contributor

can we rollback this until it's version gate? can't build main as dependency :(
also, perhaps the dev requirement should adhere to the policy so we can guarantee better?

@Danil-Grigorev
Copy link
Member Author

It should not break CRD generation for pre 1.31 clusters if the selectable is not specified @aviramha

@aviramha
Copy link
Contributor

It should not break CRD generation for pre 1.31 clusters if the selectable is not specified @aviramha

I think there's some ambiguity whether the MK8SV is runtime or compilation, in my case, if we use "earliest" on k8s open api we can't compile this commit.

@Danil-Grigorev
Copy link
Member Author

@clux
Copy link
Member

clux commented Oct 18, 2024

i think you can use a https://docs.rs/k8s-openapi/latest/k8s_openapi/macro.k8s_if_ge_1_30.html around an if that factors out the fields: Vec... ^

@aviramha: a bit off-topic, but is there any reason you don't use latest? you generally don't lose anything by going newer.

@aviramha
Copy link
Contributor

i think you can use a https://docs.rs/k8s-openapi/latest/k8s_openapi/macro.k8s_if_ge_1_30.html around an if that factors out the fields: Vec... ^

@aviramha: a bit off-topic, but is there any reason you don't use latest? you generally don't lose anything by going newer.

It's pretty much the first dependency we added, and earliest felt safest. I think it still makes sense, so devs won't try to use API that isn't compatible with older clusters by accident.

@Danil-Grigorev
Copy link
Member Author

Thanks for the pointer @clux, was about to ask how the version gating done elsewhere, will prepare a PR in a moment :)

@clux
Copy link
Member

clux commented Oct 18, 2024

also had a quick look, i think this will do it: #1609

@clux clux mentioned this pull request Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog-add changelog added category for prs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants