Skip to content

Commit 37d655b

Browse files
Techassisbernauer
andcommitted
refactor: Destructure Scale struct during token generation
Co-authored-by: Sebastian Bernauer <sebastian.bernauer@stackable.tech>
1 parent 2b27928 commit 37d655b

File tree

1 file changed

+22
-15
lines changed
  • crates/stackable-versioned-macros/src/codegen/container/struct

1 file changed

+22
-15
lines changed

crates/stackable-versioned-macros/src/codegen/container/struct/mod.rs

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use quote::quote;
55
use syn::{Generics, ItemStruct};
66

77
use crate::{
8-
attrs::container::{ContainerAttributes, StructCrdArguments},
8+
attrs::container::{ContainerAttributes, Scale, StructCrdArguments},
99
codegen::{
1010
Direction, VersionContext, VersionDefinition,
1111
changes::Neighbors,
@@ -272,20 +272,27 @@ impl Struct {
272272
_ => None,
273273
};
274274

275-
let scale = spec_gen_ctx.kubernetes_arguments.scale.as_ref().map(|s| {
276-
let spec_replicas_path = &s.spec_replicas_path;
277-
let status_replicas_path = &s.status_replicas_path;
278-
let label_selector_path = s
279-
.label_selector_path
280-
.as_ref()
281-
.map(|p| quote! { , label_selector_path = #p });
282-
283-
quote! { , scale(
284-
spec_replicas_path = #spec_replicas_path,
285-
status_replicas_path = #status_replicas_path
286-
#label_selector_path
287-
)}
288-
});
275+
let scale = spec_gen_ctx
276+
.kubernetes_arguments
277+
.scale
278+
.as_ref()
279+
.map(|scale| {
280+
let Scale {
281+
spec_replicas_path,
282+
status_replicas_path,
283+
label_selector_path,
284+
} = scale;
285+
286+
let label_selector_path = label_selector_path
287+
.as_ref()
288+
.map(|p| quote! { , label_selector_path = #p });
289+
290+
quote! { , scale(
291+
spec_replicas_path = #spec_replicas_path,
292+
status_replicas_path = #status_replicas_path
293+
#label_selector_path
294+
)}
295+
});
289296

290297
let shortnames: TokenStream = spec_gen_ctx
291298
.kubernetes_arguments

0 commit comments

Comments
 (0)