mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-08-24 20:38:34 +00:00
fix rootfs unmarshalling from API response
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
parent
93f6b3ed0e
commit
c39a061825
@ -71,7 +71,6 @@ func TestAccResourceContainer(t *testing.T) {
|
||||
unprivileged = true
|
||||
disk {
|
||||
datastore_id = "local-lvm"
|
||||
mount_options = ["discard"]
|
||||
size = 4
|
||||
}
|
||||
mount_point {
|
||||
@ -144,6 +143,7 @@ func TestAccResourceContainer(t *testing.T) {
|
||||
disk {
|
||||
datastore_id = "local-lvm"
|
||||
size = 4
|
||||
mount_options = ["discard"]
|
||||
}
|
||||
mount_point {
|
||||
volume = "local-lvm"
|
||||
@ -180,6 +180,55 @@ func TestAccResourceContainer(t *testing.T) {
|
||||
"description": "my\ndescription\nvalue\n",
|
||||
"device_passthrough.#": "1",
|
||||
"initialization.0.dns.#": "0",
|
||||
"disk.0.mount_options.#": "1",
|
||||
}),
|
||||
),
|
||||
},
|
||||
{
|
||||
// remove disk options
|
||||
Config: te.RenderConfig(`
|
||||
resource "proxmox_virtual_environment_container" "test_container" {
|
||||
node_name = "{{.NodeName}}"
|
||||
vm_id = {{.TestContainerID}}
|
||||
timeout_delete = 10
|
||||
unprivileged = true
|
||||
disk {
|
||||
datastore_id = "local-lvm"
|
||||
size = 4
|
||||
}
|
||||
mount_point {
|
||||
volume = "local-lvm"
|
||||
size = "4G"
|
||||
path = "mnt/local"
|
||||
}
|
||||
device_passthrough {
|
||||
path = "/dev/zero"
|
||||
}
|
||||
description = <<-EOT
|
||||
my
|
||||
description
|
||||
value
|
||||
EOT
|
||||
initialization {
|
||||
hostname = "test"
|
||||
ip_config {
|
||||
ipv4 {
|
||||
address = "172.16.10.10/15"
|
||||
gateway = "172.16.0.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
network_interface {
|
||||
name = "vmbr0"
|
||||
}
|
||||
operating_system {
|
||||
template_file_id = "local:vztmpl/{{.ImageFileName}}"
|
||||
type = "ubuntu"
|
||||
}
|
||||
}`, WithRootUser()),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
ResourceAttributes(accTestContainerName, map[string]string{
|
||||
"disk.0.mount_options.#": "0",
|
||||
}),
|
||||
),
|
||||
},
|
||||
|
@ -875,6 +875,8 @@ func (r *CustomRootFS) UnmarshalJSON(b []byte) error {
|
||||
r.Volume = v[0]
|
||||
} else if len(v) == 2 {
|
||||
switch v[0] {
|
||||
case "volume":
|
||||
r.Volume = v[1]
|
||||
case "acl":
|
||||
bv := types.CustomBool(v[1] == "1")
|
||||
r.ACL = &bv
|
||||
@ -902,7 +904,7 @@ func (r *CustomRootFS) UnmarshalJSON(b []byte) error {
|
||||
case "size":
|
||||
r.Size = new(types.DiskSize)
|
||||
|
||||
err := r.Size.UnmarshalJSON([]byte(v[1]))
|
||||
err = r.Size.UnmarshalJSON([]byte(v[1]))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to unmarshal disk size: %w", err)
|
||||
}
|
||||
|
@ -2310,10 +2310,6 @@ func containerRead(ctx context.Context, d *schema.ResourceData, m interface{}) d
|
||||
// Default value of "storage" is "local" according to the API documentation.
|
||||
disk[mkDiskDatastoreID] = "local"
|
||||
disk[mkDiskSize] = dvDiskSize
|
||||
disk[mkDiskMountOptions] = nil
|
||||
disk[mkDiskACL] = dvDiskACL
|
||||
disk[mkDiskReplicate] = dvDiskReplicate
|
||||
disk[mkDiskQuota] = dvDiskQuota
|
||||
}
|
||||
|
||||
currentDisk := d.Get(mkDisk).([]interface{})
|
||||
@ -3016,6 +3012,8 @@ func containerUpdate(ctx context.Context, d *schema.ResourceData, m interface{})
|
||||
}
|
||||
|
||||
updateBody.RootFS = rootFS
|
||||
|
||||
rebootRequired = true
|
||||
}
|
||||
|
||||
if d.HasChange(mkFeatures) {
|
||||
|
Loading…
Reference in New Issue
Block a user