From 0aa2b505e59985d347149b90dd05d21ca041092b Mon Sep 17 00:00:00 2001 From: cgeopapa Date: Sun, 9 Feb 2025 05:20:12 +0200 Subject: [PATCH] fix(file): fix for datastore does not support content type "dump" (#1752) * fix(provider): fix for datastore does not support content type "dump" Signed-off-by: cgeopapa * fix: move ContentType override further in the flow Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> * fix: update docs Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> --------- Signed-off-by: cgeopapa Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> --- docs/resources/virtual_environment_file.md | 8 ++++---- proxmoxtf/resource/file.go | 5 +++++ proxmoxtf/resource/validators/file.go | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/docs/resources/virtual_environment_file.md b/docs/resources/virtual_environment_file.md index db468af5..90c36275 100644 --- a/docs/resources/virtual_environment_file.md +++ b/docs/resources/virtual_environment_file.md @@ -11,7 +11,7 @@ Use this resource to upload files to a Proxmox VE node. The file can be a backup ## Example Usage -### Backups (`dump`) +### Backups (`backup`) -> The resource with this content type uses SSH access to the node. You might need to configure the [`ssh` option in the `provider` section](../index.md#node-ip-address-used-for-ssh-connection). @@ -19,12 +19,12 @@ Use this resource to upload files to a Proxmox VE node. The file can be a backup ```hcl resource "proxmox_virtual_environment_file" "backup" { - content_type = "dump" + content_type = "backup" datastore_id = "local" node_name = "pve" source_file { - path = "vzdump-lxc-100-2023_11_08-23_10_05.tar" + path = "vzdump-lxc-100-2023_11_08-23_10_05.tar.zst" } } ``` @@ -123,7 +123,7 @@ resource "proxmox_virtual_environment_file" "ubuntu_container_template" { - `content_type` - (Optional) The content type. If not specified, the content type will be inferred from the file extension. Valid values are: - - `dump` (allowed extensions: `.vzdump`) + - `backup` (allowed extensions: `.vzdump`, `.tar.gz`, `.tar.xz`, `tar.zst`) - `iso` (allowed extensions: `.iso`, `.img`) - `snippets` (allowed extensions: any) - `vztmpl` (allowed extensions: `.tar.gz`, `.tar.xz`, `tar.zst`) diff --git a/proxmoxtf/resource/file.go b/proxmoxtf/resource/file.go index 40b96cd9..3e62558b 100644 --- a/proxmoxtf/resource/file.go +++ b/proxmoxtf/resource/file.go @@ -587,6 +587,11 @@ func fileCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag }...) } + // PVE expects backups to be located at the "dump" directory of the datastore. + if *contentType == "backup" { + request.ContentType = "dump" + } + err = capi.SSH().NodeStreamUpload(ctx, nodeName, *datastore.Path, request) if err != nil { diags = append(diags, diag.FromErr(err)...) diff --git a/proxmoxtf/resource/validators/file.go b/proxmoxtf/resource/validators/file.go index 6dc9b7c0..8cd2e57e 100644 --- a/proxmoxtf/resource/validators/file.go +++ b/proxmoxtf/resource/validators/file.go @@ -20,7 +20,7 @@ import ( // ContentType returns a schema validation function for a content type on a storage device. func ContentType() schema.SchemaValidateDiagFunc { return validation.ToDiagFunc(validation.StringInSlice([]string{ - "dump", + "backup", "iso", "snippets", "vztmpl",