[pve-devel] [PATCH v1 pve-manager 2/8] ceph: tools: update Ceph version regex

Lukas Wagner l.wagner at proxmox.com
Wed Jun 5 16:48:36 CEST 2024



On  2024-04-30 17:28, Max Carrara wrote:
> Make the regex more maintainable declaring it as a variable, breaking it
> up and commenting it by using the x flag.
> 
> Also remove the part that parses our Debian revision (e.g. -pve1) from
> the version, as we do not actually include that in our Ceph builds.
> 
> The part of the regex that parses the build commit hash is made
> mandatory (remove '?' after its group).
> 
> Signed-off-by: Max Carrara <m.carrara at proxmox.com>
> ---
>  PVE/Ceph/Tools.pm | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/PVE/Ceph/Tools.pm b/PVE/Ceph/Tools.pm
> index 087c4ef3..a00d23e1 100644
> --- a/PVE/Ceph/Tools.pm
> +++ b/PVE/Ceph/Tools.pm
> @@ -68,7 +68,18 @@ sub get_local_version {
>  
>      return undef if !defined $ceph_version;
>  
> -    if ($ceph_version =~ /^ceph.*\sv?(\d+(?:\.\d+)+(?:-pve\d+)?)\s+(?:\(([a-zA-Z0-9]+)\))?/) {
> +    my $re_ceph_version = qr/
> +	# Skip ahead to the version, which may optionally start with 'v'
> +	^ceph.*\sv?
> +
> +	# Parse the version X.Y, X.Y.Z, etc.
> +	( \d+ (?:\.\d+)+ ) \s+
> +
> +	# Parse the git commit hash between parentheses
> +	(?: \( ([a-zA-Z0-9]+) \) )
> +    /x;

TIL about the x modifier! Neat!

-- 
- Lukas




More information about the pve-devel mailing list