0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-08-22 11:28:33 +00:00

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 <cgeocodgod@gmail.com>

* 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 <cgeocodgod@gmail.com>
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
cgeopapa 2025-02-09 05:20:12 +02:00 committed by GitHub
parent 96594e4270
commit 0aa2b505e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 5 deletions

View File

@ -11,7 +11,7 @@ Use this resource to upload files to a Proxmox VE node. The file can be a backup
## Example Usage ## 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). -> 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 ```hcl
resource "proxmox_virtual_environment_file" "backup" { resource "proxmox_virtual_environment_file" "backup" {
content_type = "dump" content_type = "backup"
datastore_id = "local" datastore_id = "local"
node_name = "pve" node_name = "pve"
source_file { 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 - `content_type` - (Optional) The content type. If not specified, the content
type will be inferred from the file extension. Valid values are: 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`) - `iso` (allowed extensions: `.iso`, `.img`)
- `snippets` (allowed extensions: any) - `snippets` (allowed extensions: any)
- `vztmpl` (allowed extensions: `.tar.gz`, `.tar.xz`, `tar.zst`) - `vztmpl` (allowed extensions: `.tar.gz`, `.tar.xz`, `tar.zst`)

View File

@ -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) err = capi.SSH().NodeStreamUpload(ctx, nodeName, *datastore.Path, request)
if err != nil { if err != nil {
diags = append(diags, diag.FromErr(err)...) diags = append(diags, diag.FromErr(err)...)

View File

@ -20,7 +20,7 @@ import (
// ContentType returns a schema validation function for a content type on a storage device. // ContentType returns a schema validation function for a content type on a storage device.
func ContentType() schema.SchemaValidateDiagFunc { func ContentType() schema.SchemaValidateDiagFunc {
return validation.ToDiagFunc(validation.StringInSlice([]string{ return validation.ToDiagFunc(validation.StringInSlice([]string{
"dump", "backup",
"iso", "iso",
"snippets", "snippets",
"vztmpl", "vztmpl",