[pve-devel] [PATCH v2 pve-manager 01/10] ceph: tools: refactor installation check as guard clause
Max Carrara
m.carrara at proxmox.com
Mon Jul 1 16:10:31 CEST 2024
Signed-off-by: Max Carrara <m.carrara at proxmox.com>
Tested-by: Lukas Wagner <l.wagner at proxmox.com>
Reviewed-by: Lukas Wagner <l.wagner at proxmox.com>
---
Changes v1 --> v2:
* none
PVE/Ceph/Tools.pm | 37 +++++++++++++++++++------------------
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/PVE/Ceph/Tools.pm b/PVE/Ceph/Tools.pm
index 9b97171e..087c4ef3 100644
--- a/PVE/Ceph/Tools.pm
+++ b/PVE/Ceph/Tools.pm
@@ -57,24 +57,25 @@ my $config_files = {
sub get_local_version {
my ($noerr) = @_;
- if (check_ceph_installed('ceph_bin', $noerr)) {
- my $ceph_version;
- run_command(
- [ $ceph_service->{ceph_bin}, '--version' ],
- noerr => $noerr,
- outfunc => sub { $ceph_version = shift if !defined $ceph_version },
- );
- return undef if !defined $ceph_version;
-
- if ($ceph_version =~ /^ceph.*\sv?(\d+(?:\.\d+)+(?:-pve\d+)?)\s+(?:\(([a-zA-Z0-9]+)\))?/) {
- my ($version, $buildcommit) = ($1, $2);
- my $subversions = [ split(/\.|-/, $version) ];
-
- # return (version, buildid, major, minor, ...) : major;
- return wantarray
- ? ($version, $buildcommit, $subversions)
- : $subversions->[0];
- }
+ return undef if !check_ceph_installed('ceph_bin', $noerr);
+
+ my $ceph_version;
+ run_command(
+ [ $ceph_service->{ceph_bin}, '--version' ],
+ noerr => $noerr,
+ outfunc => sub { $ceph_version = shift if !defined $ceph_version },
+ );
+
+ return undef if !defined $ceph_version;
+
+ if ($ceph_version =~ /^ceph.*\sv?(\d+(?:\.\d+)+(?:-pve\d+)?)\s+(?:\(([a-zA-Z0-9]+)\))?/) {
+ my ($version, $buildcommit) = ($1, $2);
+ my $subversions = [ split(/\.|-/, $version) ];
+
+ # return (version, buildid, major, minor, ...) : major;
+ return wantarray
+ ? ($version, $buildcommit, $subversions)
+ : $subversions->[0];
}
return undef;
--
2.39.2
More information about the pve-devel
mailing list