From 17f5b061065762ae14b513292d4b38b11fcfb5c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Wed, 2 Sep 2026 19:32:29 -0300 Subject: [PATCH] refactor(confluent): share first-row attribute flattening MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Vinícius Ferrão <2031761+viniciusferrao@users.noreply.github.com> --- xCAT-server/lib/xcat/plugins/confluent.pm | 31 ++++++++++------------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/confluent.pm b/xCAT-server/lib/xcat/plugins/confluent.pm index ec1e435c4..27c1c573e 100644 --- a/xCAT-server/lib/xcat/plugins/confluent.pm +++ b/xCAT-server/lib/xcat/plugins/confluent.pm @@ -194,6 +194,17 @@ sub process_request { } } +sub _first_node_attribute_rows { + my $entries = shift; + my @rows; + foreach my $entry (@{$entries}) { + foreach my $node (keys %{$entry}) { + push @rows, $entry->{$node}->[0]; + } + } + return @rows; +} + # Read the file, get db info, update the file contents, and then write the file sub makeconfluentcfg { my $req = shift; @@ -264,24 +275,8 @@ sub makeconfluentcfg { } } @cfgents1 = @tmpcfgents1; - @tmpcfgents1 = (); - foreach my $ent (@cfgents2) - { - foreach my $nodeent (keys %$ent) - { - push @tmpcfgents1, $ent->{$nodeent}->[0]; - } - } - @cfgents2 = @tmpcfgents1; - @tmpcfgents1 = (); - foreach my $ent (@cfgents3) - { - foreach my $nodeent (keys %$ent) - { - push @tmpcfgents1, $ent->{$nodeent}->[0]; - } - } - @cfgents3 = @tmpcfgents1; + @cfgents2 = _first_node_attribute_rows(\@cfgents2); + @cfgents3 = _first_node_attribute_rows(\@cfgents3); @tmpcfgents1 = (); foreach my $ent (@cfgents4) {