Skip to content

Commit

Permalink
Add a compile_error if setting selectable fields on K8s < 1.30 (#1612)
Browse files Browse the repository at this point in the history
Signed-off-by: clux <[email protected]>
  • Loading branch information
clux authored Oct 18, 2024
1 parent 7526539 commit ecbdafc
Showing 1 changed file with 12 additions and 0 deletions.
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

0 comments on commit ecbdafc

Please sign in to comment.