From 4879eef80b0e9edf261e132df9a562b87d690ff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Sat, 10 Oct 2026 21:13:41 -0300 Subject: [PATCH] refactor(xcat): reuse whitespace trimming in blade and credential paths --- xCAT-server/lib/perl/xCAT/BladeUtils.pm | 4 +++- xCAT-server/lib/xcat/plugins/credentials.pm | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/BladeUtils.pm b/xCAT-server/lib/perl/xCAT/BladeUtils.pm index fd2fef6f2..66588b216 100644 --- a/xCAT-server/lib/perl/xCAT/BladeUtils.pm +++ b/xCAT-server/lib/perl/xCAT/BladeUtils.pm @@ -3,6 +3,8 @@ package xCAT::BladeUtils; use strict; use warnings; +use xCAT::StringUtils qw(trim); + sub blade_nodes_from_mp { my @entries = @_; my %hwtype; @@ -12,7 +14,7 @@ sub blade_nodes_from_mp { next unless ref $entry eq 'HASH' and defined $entry->{node}; $hwtype{ $entry->{node} } = defined $entry->{nodetype} ? lc( $entry->{nodetype} ) : q{}; - $hwtype{ $entry->{node} } =~ s/^\s+|\s+$//gx; + $hwtype{ $entry->{node} } = trim($hwtype{ $entry->{node} }); $ownmpa{ $entry->{node} } = $entry->{mpa} if defined $entry->{mpa}; } diff --git a/xCAT-server/lib/xcat/plugins/credentials.pm b/xCAT-server/lib/xcat/plugins/credentials.pm index 785dc843e..9a69047dd 100644 --- a/xCAT-server/lib/xcat/plugins/credentials.pm +++ b/xCAT-server/lib/xcat/plugins/credentials.pm @@ -38,6 +38,7 @@ use xCAT::Utils; use xCAT::NetworkUtils; use xCAT::PasswordUtils; use xCAT::TableUtils; +use xCAT::StringUtils qw(trim); use xCAT::MsgUtils; use Getopt::Long; @@ -410,7 +411,7 @@ sub _delegated_signer_allowed { sub _endpoint_identities { my $endpoint = shift; return unless defined($endpoint); - $endpoint =~ s/^\s+|\s+$//g; + $endpoint = trim($endpoint); return unless length($endpoint); my %identities;