]> git.proxmox.com Git - pve-storage.git/commitdiff
plugin: change name, separator and error message for dir overrides
authorLeo Nunner <l.nunner@proxmox.com>
Thu, 5 Jan 2023 16:16:57 +0000 (17:16 +0100)
committerWolfgang Bumiller <w.bumiller@errno.eu>
Mon, 9 Jan 2023 09:47:20 +0000 (10:47 +0100)
Rename the "dirs" parameter to "content-dirs". Switch from a "vtype:/dir"
format to "vtype=/dir", and remove the misleading error message talking
about "absolute" paths. One might expect these to be absolute over the
whole system, while in reality they are relative to the mountpoint of
the storage.

Signed-off-by: Leo Nunner <l.nunner@proxmox.com>
PVE/Storage/CIFSPlugin.pm
PVE/Storage/DirPlugin.pm
PVE/Storage/NFSPlugin.pm
PVE/Storage/Plugin.pm
test/get_subdir_test.pm

index 4284c353d935027e82d716790731c322079c6b88..d238844e85af9ea95739eacb90510bac1d674dce 100644 (file)
@@ -128,7 +128,7 @@ sub properties {
 sub options {
     return {
        path => { fixed => 1 },
-       dirs => { optional => 1 },
+       'content-dirs' => { optional => 1 },
        server => { fixed => 1 },
        share => { fixed => 1 },
        nodes => { optional => 1 },
index 3c907ca0ddae9a29ace298d1c9be760df6e4e2d6..9e305f52c79b823c2233c91112c7f41045887ef6 100644 (file)
@@ -54,7 +54,7 @@ sub properties {
 sub options {
     return {
        path => { fixed => 1 },
-       dirs => { optional => 1 },
+       'content-dirs' => { optional => 1 },
        nodes => { optional => 1 },
        shared => { optional => 1 },
        disable => { optional => 1 },
index b7e831862d878442046b48a3ecfea899d1cee1f9..0bdde84c791866a9913f37be29cd06ad50c0bed6 100644 (file)
@@ -79,7 +79,7 @@ sub properties {
 sub options {
     return {
        path => { fixed => 1 },
-       dirs => { optional => 1 },
+       'content-dirs' => { optional => 1 },
        server => { fixed => 1 },
        export => { fixed => 1 },
        nodes => { optional => 1 },
index 5cb3d900360530689df62c4a3c4ce3e338cf6f70..a3aac611b5a77fa7a5bb07b7bb00eaa2b84cbf2d 100644 (file)
@@ -181,8 +181,8 @@ my $defaultData = {
            default => 'metadata',
            optional => 1,
        },
-       dirs => {
-           description => "Overrides for default directories",
+       'content-dirs' => {
+           description => "Overrides for default content type directories.",
            type => "string", format => "pve-dir-override-list",
            optional => 1,
        },
@@ -213,7 +213,7 @@ sub valid_content_types {
 sub dirs_hash_to_string {
     my $hash = shift;
 
-    return join(',', map { "$_:$hash->{$_}" } sort keys %$hash);
+    return join(',', map { "$_=$hash->{$_}" } sort keys %$hash);
 }
 
 sub default_format {
@@ -350,8 +350,8 @@ PVE::JSONSchema::register_format('pve-dir-override', \&verify_dir_override);
 sub verify_dir_override {
     my ($value, $noerr) = @_;
 
-    if($value =~ m/^([a-z]+):(.+)$/ &&
-       verify_content($1, $noerr) && verify_path($2, $noerr)) {
+    if($value =~ m/^([a-z]+)=\/.+$/ &&
+       verify_content($1, $noerr)) {
        return $value;
     }
 
@@ -429,12 +429,12 @@ sub decode_value {
        #}
 
        return $res;
-    } elsif ($key eq 'dirs') {
+    } elsif ($key eq 'content-dirs') {
        my $valid_content = $def->{content}->[0];
        my $res = {};
 
        foreach my $dir (PVE::Tools::split_list($value)) {
-           my ($content, $path) = split(/:/, $dir, 2);
+           my ($content, $path) = split(/=/, $dir, 2);
 
            if (!$valid_content->{$content}) {
                warn "storage does not support content type '$content'\n";
@@ -458,7 +458,7 @@ sub encode_value {
     } elsif ($key eq 'content') {
        my $res = content_hash_to_string($value) || 'none';
        return $res;
-    } elsif ($key eq 'dirs') {
+    } elsif ($key eq 'content-dirs') {
        my $res = dirs_hash_to_string($value);
        return $res;
     }
@@ -654,7 +654,7 @@ sub get_subdir {
     die "storage definition has no path\n" if !$path;
     die "unknown vtype '$vtype'\n" if !exists($vtype_subdirs->{$vtype});
 
-    my $subdir = $scfg->{dirs}->{$vtype} // "/".$vtype_subdirs->{$vtype};
+    my $subdir = $scfg->{"content-dirs"}->{$vtype} // "/".$vtype_subdirs->{$vtype};
 
     return $path.$subdir;
 }
index 26c08d53a68a1ada77c7d79518b6f9df28ff25fb..ff42985bb783d049011cf405fac196d0e88be912 100644 (file)
@@ -30,8 +30,8 @@ foreach my $type (keys %$vtype_subdirs) {
 # creates additional tests for overrides
 foreach my $type (keys %$vtype_subdirs) {
     my $override = "/${type}_override";
-    my $scfg_with_override = { path => '/some/path', dirs => { $type => $override } };
-    push @$tests, [ $scfg_with_override, $type, "$scfg_with_override->{path}$scfg_with_override->{dirs}->{$type}" ];
+    my $scfg_with_override = { path => '/some/path', 'content-dirs' => { $type => $override } };
+    push @$tests, [ $scfg_with_override, $type, "$scfg_with_override->{path}$scfg_with_override->{'content-dirs'}->{$type}" ];
 }
 
 plan tests => scalar @$tests;