Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Danil-Grigorev <[email protected]>
  • Loading branch information
Danil-Grigorev committed Oct 27, 2024
1 parent 332423c commit 159e746
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions examples/crd_derive_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ pub struct FooSpec {
set_listable: Vec<u32>,
// Field with CEL validation
#[serde(default)]
#[validated(rule="self != 'illegal'", message="string cannot be illegal")]
#[validated(rule="self != 'not legal'")]
#[validated(rule = "self != 'illegal'", message = "string cannot be illegal")]
#[validated(rule = "self != 'not legal'")]
cel_validated: Option<String>,
}
// https://kubernetes.io/docs/reference/using-api/server-side-apply/#merge-strategy
Expand Down
5 changes: 1 addition & 4 deletions kube-derive/src/custom_resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,7 @@ pub(crate) fn cel_validation(_: TokenStream, input: TokenStream) -> TokenStream
Ok(di) => di,

Check warning on line 552 in kube-derive/src/custom_resource.rs

View check run for this annotation

Codecov / codecov/patch

kube-derive/src/custom_resource.rs#L549-L552

Added lines #L549 - L552 were not covered by tests
};

if !ast
.attrs
.iter().any(|attr| attr.path().is_ident("derive"))
{
if !ast.attrs.iter().any(|attr| attr.path().is_ident("derive")) {
return syn::Error::new(
ast.ident.span(),

Check warning on line 557 in kube-derive/src/custom_resource.rs

View check run for this annotation

Codecov / codecov/patch

kube-derive/src/custom_resource.rs#L555-L557

Added lines #L555 - L557 were not covered by tests
r#"#[cel_validation] macro should be placed before the #[derive(JsonSchema)] macro"#,
Expand Down
5 changes: 4 additions & 1 deletion kube-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,10 @@ pub fn derive_custom_resource(input: proc_macro::TokenStream) -> proc_macro::Tok
/// assert!(serde_json::to_string(&Struct::crd()).unwrap().contains(r#""rule":"self != ''""#));
/// ```
#[proc_macro_attribute]
pub fn cel_validation(args: proc_macro::TokenStream, input: proc_macro::TokenStream) -> proc_macro::TokenStream {
pub fn cel_validation(

Check warning on line 346 in kube-derive/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

kube-derive/src/lib.rs#L346

Added line #L346 was not covered by tests
args: proc_macro::TokenStream,
input: proc_macro::TokenStream,
) -> proc_macro::TokenStream {
custom_resource::cel_validation(args.into(), input.into()).into()

Check warning on line 350 in kube-derive/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

kube-derive/src/lib.rs#L350

Added line #L350 was not covered by tests
}

Expand Down

0 comments on commit 159e746

Please sign in to comment.