public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: Lorenz Stechauner <l.stechauner@proxmox.com>,
	pve-devel@lists.proxmox.com
Subject: Re: [pve-devel] [PATCH v2 storage 1/2] storage: rename REs for iso and vztmpl extensions
Date: Wed, 1 Sep 2021 12:23:33 +0200	[thread overview]
Message-ID: <0cc29d0d-c55b-4d7b-9e0c-70d0f330e1f6@proxmox.com> (raw)
In-Reply-To: <b2c8485d-d253-f60f-a51d-0ac2885ed642@proxmox.com>

Am 16.08.21 um 10:46 schrieb Lorenz Stechauner:
> 
> On 13.08.21 12:09, Fabian Ebner wrote:
>> Am 05.08.21 um 09:34 schrieb Lorenz Stechauner:
>>> these changes make it more clear, how many capture groups each
>>> RE inclues.
>>>
>>> Signed-off-by: Lorenz Stechauner <l.stechauner@proxmox.com>
>>> ---
>>>   PVE/API2/Storage/Status.pm |  8 ++++----
>>>   PVE/Storage.pm             | 11 +++++++----
>>>   PVE/Storage/Plugin.pm      |  8 ++++----
>>>   3 files changed, 15 insertions(+), 12 deletions(-)
>>>
>>> diff --git a/PVE/API2/Storage/Status.pm b/PVE/API2/Storage/Status.pm
>>> index b838461..3acb647 100644
>>> --- a/PVE/API2/Storage/Status.pm
>>> +++ b/PVE/API2/Storage/Status.pm
>>> @@ -424,12 +424,12 @@ __PACKAGE__->register_method ({
>>>       my $path;
>>>         if ($content eq 'iso') {
>>> -        if ($filename !~ m![^/]+$PVE::Storage::iso_extension_re$!) {
>>> +        if ($filename !~ m![^/]+$PVE::Storage::ISO_EXT_RE_0$!) {
>>>           raise_param_exc({ filename => "wrong file extension" });
>>>           }
>>>           $path = PVE::Storage::get_iso_dir($cfg, $param->{storage});
>>>       } elsif ($content eq 'vztmpl') {
>>> -        if ($filename !~ m![^/]+$PVE::Storage::vztmpl_extension_re$!) {
>>> +        if ($filename !~ m![^/]+$PVE::Storage::VZTMPL_EXT_RE_1$!) {
>>>           raise_param_exc({ filename => "wrong file extension" });
>>>           }
>>>           $path = PVE::Storage::get_vztmpl_dir($cfg, $param->{storage});
>>> @@ -584,12 +584,12 @@ __PACKAGE__->register_method({
>>>         my $path;
>>>       if ($content eq 'iso') {
>>> -        if ($filename !~ m![^/]+$PVE::Storage::iso_extension_re$!) {
>>> +        if ($filename !~ m![^/]+$PVE::Storage::ISO_EXT_RE_0$!) {
>>>           raise_param_exc({ filename => "wrong file extension" });
>>>           }
>>>           $path = PVE::Storage::get_iso_dir($cfg, $storage);
>>>       } elsif ($content eq 'vztmpl') {
>>> -        if ($filename !~ m![^/]+$PVE::Storage::vztmpl_extension_re$!) {
>>> +        if ($filename !~ m![^/]+$PVE::Storage::VZTMPL_EXT_RE_1$!) {
>>>           raise_param_exc({ filename => "wrong file extension" });
>>>           }
>>>           $path = PVE::Storage::get_vztmpl_dir($cfg, $storage);
>>> diff --git a/PVE/Storage.pm b/PVE/Storage.pm
>>> index c04b5a2..b5c2460 100755
>>> --- a/PVE/Storage.pm
>>> +++ b/PVE/Storage.pm
>>> @@ -101,9 +101,12 @@ if ( -d '/usr/share/perl5/PVE/Storage/Custom' ) {
>>>   # initialize all plugins
>>>   PVE::Storage::Plugin->init();
>>>   -our $iso_extension_re = qr/\.(?:iso|img)/i;
>>> +# the following REs indicate the number or capture groups via the 
>>> trailing digit
>>> +# CAUTION don't forget to update the digits accordingly after 
>>> messing with the capture groups
>>>   -our $vztmpl_extension_re = qr/\.tar\.([gx]z)/i;
>>
>> Removing this is not backwards compatible and requires a versioned 
>> Breaks for pve-manager.
> makes sense. should I split this commit in two, where in the first part 
> I add the new variable and in the second part remove the old one? or is 
> it enough to state the need for "breaks" in the commit message?

If we want to do the Breaks now, it's enough to mention it. I don't 
think you need to split the patch.
If we don't want to do the Breaks now, adding a reminder comment like
     # FIXME: Remove with PVE 8.0 and add a versioned breaks for pve-manager
is probably the way to go.

And which of those we want, is for the release team to decide.

>>
>>> +our $ISO_EXT_RE_0 = qr/\.(?:iso|img)/i;
>>> +
>>> +our $VZTMPL_EXT_RE_1 = qr/\.tar\.([gx]z)/i;
>>>     #  PVE::Storage utility functions
>>>   @@ -574,10 +577,10 @@ sub path_to_volume_id {
>>>               return ('images', $info->{volid});
>>>           }
>>>           }
>>> -    } elsif ($path =~ m!^$isodir/([^/]+$iso_extension_re)$!) {
>>> +    } elsif ($path =~ m!^$isodir/([^/]+$ISO_EXT_RE_0)$!) {
>>>           my $name = $1;
>>>           return ('iso', "$sid:iso/$name");
>>> -    } elsif ($path =~ m!^$tmpldir/([^/]+$vztmpl_extension_re)$!) {
>>> +    } elsif ($path =~ m!^$tmpldir/([^/]+$VZTMPL_EXT_RE_1)$!) {
>>>           my $name = $1;
>>>           return ('vztmpl', "$sid:vztmpl/$name");
>>>       } elsif ($path =~ m!^$privatedir/(\d+)$!) {
>>> diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
>>> index b1865cb..502951f 100644
>>> --- a/PVE/Storage/Plugin.pm
>>> +++ b/PVE/Storage/Plugin.pm
>>> @@ -516,9 +516,9 @@ sub parse_volname {
>>>       my ($vmid, $name) = ($1, $2);
>>>       my (undef, $format, $isBase) = parse_name_dir($name);
>>>       return ('images', $name, $vmid, undef, undef, $isBase, $format);
>>> -    } elsif ($volname =~ 
>>> m!^iso/([^/]+$PVE::Storage::iso_extension_re)$!) {
>>> +    } elsif ($volname =~ m!^iso/([^/]+$PVE::Storage::ISO_EXT_RE_0)$!) {
>>>       return ('iso', $1);
>>> -    } elsif ($volname =~ 
>>> m!^vztmpl/([^/]+$PVE::Storage::vztmpl_extension_re)$!) {
>>> +    } elsif ($volname =~ 
>>> m!^vztmpl/([^/]+$PVE::Storage::VZTMPL_EXT_RE_1)$!) {
>>>       return ('vztmpl', $1);
>>>       } elsif ($volname =~ m!^rootdir/(\d+)$!) {
>>>       return ('rootdir', $1, $1);
>>> @@ -1045,12 +1045,12 @@ my $get_subdir_files = sub {
>>>       my $info;
>>>         if ($tt eq 'iso') {
>>> -        next if $fn !~ m!/([^/]+$PVE::Storage::iso_extension_re)$!i;
>>> +        next if $fn !~ m!/([^/]+$PVE::Storage::ISO_EXT_RE_0)$!i;
>>>             $info = { volid => "$sid:iso/$1", format => 'iso' };
>>>         } elsif ($tt eq 'vztmpl') {
>>> -        next if $fn !~ m!/([^/]+$PVE::Storage::vztmpl_extension_re)$!;
>>> +        next if $fn !~ m!/([^/]+$PVE::Storage::VZTMPL_EXT_RE_1)$!;
>>>             $info = { volid => "$sid:vztmpl/$1", format => "t$2" };
>>>




  reply	other threads:[~2021-09-01 10:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-05  7:34 [pve-devel] [PATCH-SERIES v2 storage/manager] factoring out RE for backup extension Lorenz Stechauner
2021-08-05  7:34 ` [pve-devel] [PATCH v2 storage 1/2] storage: rename REs for iso and vztmpl extensions Lorenz Stechauner
2021-08-13 10:09   ` Fabian Ebner
2021-08-16  8:46     ` Lorenz Stechauner
2021-09-01 10:23       ` Fabian Ebner [this message]
2021-08-05  7:34 ` [pve-devel] [PATCH v2 storage 2/2] storage/plugin: factoring out regex for backup extension re Lorenz Stechauner
2021-08-13 10:10   ` Fabian Ebner
2021-08-05  7:34 ` [pve-devel] [PATCH v2 manager 1/1] api: aplinfo: rename REs for iso and vztmpl extensions Lorenz Stechauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0cc29d0d-c55b-4d7b-9e0c-70d0f330e1f6@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=l.stechauner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal