public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
	Fiona Ebner <f.ebner@proxmox.com>
Subject: Re: [pve-devel] [PATCH storage] api: config: add/update storage: check for type mismatch first
Date: Fri, 9 Jun 2023 17:29:03 +0200	[thread overview]
Message-ID: <76ef5ad7-c5d4-5f49-f4c9-f583771ee4ce@proxmox.com> (raw)
In-Reply-To: <20230609134504.44255-1-f.ebner@proxmox.com>

On 09/06/2023 15:45, Fiona Ebner wrote:
> This avoids confusing errors about other properties when the storage
> type doesn't match. By highlighting that the type doesn't match, users
> should know right away what the issue is.
> 
> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
> ---
>  src/PVE/API2/Storage/Config.pm | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/PVE/API2/Storage/Config.pm b/src/PVE/API2/Storage/Config.pm
> index 821db21..a1ab5a7 100755
> --- a/src/PVE/API2/Storage/Config.pm
> +++ b/src/PVE/API2/Storage/Config.pm
> @@ -87,7 +87,7 @@ sub create_or_update {
>  	die "Storage ID '${sid}' already exists on node ${node}\n"
>  	    if !defined($scfg->{nodes}) || $scfg->{nodes}->{$node};
>  
> -	push @$verify_params, 'type';
> +	unshift $verify_params->@*, 'type'; # check for type mismatch right away
>  	for my $key (@$verify_params) {

can we do something like:

for my $key ('type', $verify_params->@*) {
    ...

a line less and a bit more straight forward IMO

>  	    if (!defined($scfg->{$key})) {
>  		die "Option '${key}' is not configured for storage '$sid', "





      reply	other threads:[~2023-06-09 15:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-09 13:45 Fiona Ebner
2023-06-09 15:29 ` Thomas Lamprecht [this message]

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=76ef5ad7-c5d4-5f49-f4c9-f583771ee4ce@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=f.ebner@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