* [pve-devel] [PATCH storage] api: config: add/update storage: check for type mismatch first
@ 2023-06-09 13:45 Fiona Ebner
2023-06-09 15:29 ` Thomas Lamprecht
0 siblings, 1 reply; 2+ messages in thread
From: Fiona Ebner @ 2023-06-09 13:45 UTC (permalink / raw)
To: pve-devel
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) {
if (!defined($scfg->{$key})) {
die "Option '${key}' is not configured for storage '$sid', "
--
2.39.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [pve-devel] [PATCH storage] api: config: add/update storage: check for type mismatch first
2023-06-09 13:45 [pve-devel] [PATCH storage] api: config: add/update storage: check for type mismatch first Fiona Ebner
@ 2023-06-09 15:29 ` Thomas Lamprecht
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2023-06-09 15:29 UTC (permalink / raw)
To: Proxmox VE development discussion, Fiona Ebner
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', "
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-09 15:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-09 13:45 [pve-devel] [PATCH storage] api: config: add/update storage: check for type mismatch first Fiona Ebner
2023-06-09 15:29 ` Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox