public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v2 storage] api: config: add/update storage: check for type mismatch first
Date: Mon, 12 Jun 2023 16:27:33 +0200	[thread overview]
Message-ID: <20230612142733.74433-1-f.ebner@proxmox.com> (raw)

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>
---

Changes in v2:
    * Avoid unshift, prepend type directly to loop list.

 src/PVE/API2/Storage/Config.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/PVE/API2/Storage/Config.pm b/src/PVE/API2/Storage/Config.pm
index 821db21..0716916 100755
--- a/src/PVE/API2/Storage/Config.pm
+++ b/src/PVE/API2/Storage/Config.pm
@@ -87,8 +87,8 @@ 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';
-	for my $key (@$verify_params) {
+	# check for type mismatch first to get a clear error
+	for my $key ('type', $verify_params->@*) {
 	    if (!defined($scfg->{$key})) {
 		die "Option '${key}' is not configured for storage '$sid', "
 		    ."expected it to be '$storage_params->{$key}'";
-- 
2.39.2





             reply	other threads:[~2023-06-12 14:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-12 14:27 Fiona Ebner [this message]
2023-06-15 12:19 ` [pve-devel] applied: " Thomas Lamprecht

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=20230612142733.74433-1-f.ebner@proxmox.com \
    --to=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