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

Add a compile_error if setting selectable fields on K8s < 1.30 #1612

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions kube-derive/src/custom_resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,17 @@ pub(crate) fn derive(input: proc_macro2::TokenStream) -> proc_macro2::TokenStrea
quote! {}
};

// Known constraints that are hard to enforce elsewhere
let compile_constraints = if !selectable.is_empty() {
quote! {
#k8s_openapi::k8s_if_le_1_29! {
compile_error!("selectable fields require Kubernetes >= 1.30");
}
}
} else {
quote! {}
};

let jsondata = quote! {
#schemagen

Expand Down Expand Up @@ -493,6 +504,7 @@ pub(crate) fn derive(input: proc_macro2::TokenStream) -> proc_macro2::TokenStrea

// Concat output
quote! {
#compile_constraints
#root_obj
#impl_resource
#impl_default
Expand Down
Loading