api: oci image pull: add optional OCI image filename parameter

Give the user the ability to choose a custom destination file name for
the OCI image.

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
Link: https://lore.proxmox.com/20251117171528.262443-4-f.schauer@proxmox.com
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Filip Schauer
2025-11-17 18:13:16 +01:00
committed by Thomas Lamprecht
parent 0ed80aaf31
commit 21584f8350

View File

@ -933,6 +933,14 @@ __PACKAGE__->register_method({
. '(?:\.(?:[a-zA-Z\d]|[a-zA-Z\d][a-zA-Z\d-]*[a-zA-Z\d]))*(?::\d+)?/)?[a-z\d]+' . '(?:\.(?:[a-zA-Z\d]|[a-zA-Z\d][a-zA-Z\d-]*[a-zA-Z\d]))*(?::\d+)?/)?[a-z\d]+'
. '(?:/[a-z\d]+(?:(?:(?:[._]|__|[-]*)[a-z\d]+)+)?)*:\w[\w.-]{0,127}$', . '(?:/[a-z\d]+(?:(?:(?:[._]|__|[-]*)[a-z\d]+)+)?)*:\w[\w.-]{0,127}$',
}, },
filename => {
description =>
"Custom destination file name of the OCI image. Caution: This will be normalized!",
optional => 1,
minLength => 1,
maxLength => 255,
type => 'string',
},
}, },
}, },
returns => { returns => {
@ -959,7 +967,8 @@ __PACKAGE__->register_method({
die "storage '$storage' is not configured for content-type 'vztmpl'\n" die "storage '$storage' is not configured for content-type 'vztmpl'\n"
if !$scfg->{content}->{vztmpl}; if !$scfg->{content}->{vztmpl};
my $filename = PVE::Storage::normalize_content_filename($reference) . ".tar"; my $filename =
PVE::Storage::normalize_content_filename($param->{filename} // $reference) . ".tar";
my $tmp_filename = "$filename.tmp.$$"; my $tmp_filename = "$filename.tmp.$$";
my $path = PVE::Storage::get_vztmpl_dir($cfg, $storage); my $path = PVE::Storage::get_vztmpl_dir($cfg, $storage);
PVE::Storage::activate_storage($cfg, $storage); PVE::Storage::activate_storage($cfg, $storage);