0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-08-22 19:38:35 +00:00

fix(vm,lxc): error parsing disk ID when datastore name contains . (#1894)

Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
Pavel Boldyrev 2025-04-11 09:02:15 -04:00 committed by GitHub
parent c84e7bb5f4
commit 13401465c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 4 deletions

View File

@ -243,11 +243,18 @@ func (d *CustomStorageDevice) UnmarshalJSON(b []byte) error {
if len(v) == 1 {
d.FileVolume = v[0]
ext := filepath.Ext(v[0])
// split file volume into datastore ID and path
_, pathInDatastore, hasDatastoreID := strings.Cut(v[0], ":")
if hasDatastoreID {
// we don't set them here,... but probably should
// d.DatastoreID = &probablyDatastoreID
// d.FileID = &pathInDatastore
ext := filepath.Ext(pathInDatastore)
if ext != "" {
format := string([]byte(ext)[1:])
d.Format = &format
}
}
} else if len(v) == 2 {
switch v[0] {
case "aio":

View File

@ -38,6 +38,18 @@ func TestCustomStorageDevice_UnmarshalJSON(t *testing.T) {
SSD: types.CustomBool(true).Pointer(),
},
},
{
name: "volume with dot",
line: `"volumes.hdd:base-269-disk-0,cache=writeback,discard=on,iothread=1,size=8G,ssd=1"`,
want: &CustomStorageDevice{
Cache: ptr.Ptr("writeback"),
Discard: ptr.Ptr("on"),
FileVolume: "volumes.hdd:base-269-disk-0",
IOThread: types.CustomBool(true).Pointer(),
Size: ds8gig,
SSD: types.CustomBool(true).Pointer(),
},
},
{
name: "raw volume type",
line: `"nfs:2041/vm-2041-disk-0.raw,discard=ignore,ssd=1,iothread=1,size=8G"`,