[pve-devel] [PATCH storage] api: config: add/update storage: check for type mismatch first
Thomas Lamprecht
t.lamprecht at proxmox.com
Fri Jun 9 17:29:03 CEST 2023
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 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) {
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', "
More information about the pve-devel
mailing list