[pve-devel] [PATCH storage] api: config: add/update storage: check for type mismatch first

Fiona Ebner f.ebner at proxmox.com
Fri Jun 9 15:45:04 CEST 2023


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 at 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) {
 	    if (!defined($scfg->{$key})) {
 		die "Option '${key}' is not configured for storage '$sid', "
-- 
2.39.2






More information about the pve-devel mailing list