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:
parent
c84e7bb5f4
commit
13401465c9
@ -243,10 +243,17 @@ func (d *CustomStorageDevice) UnmarshalJSON(b []byte) error {
|
|||||||
if len(v) == 1 {
|
if len(v) == 1 {
|
||||||
d.FileVolume = v[0]
|
d.FileVolume = v[0]
|
||||||
|
|
||||||
ext := filepath.Ext(v[0])
|
// split file volume into datastore ID and path
|
||||||
if ext != "" {
|
_, pathInDatastore, hasDatastoreID := strings.Cut(v[0], ":")
|
||||||
format := string([]byte(ext)[1:])
|
if hasDatastoreID {
|
||||||
d.Format = &format
|
// 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 {
|
} else if len(v) == 2 {
|
||||||
switch v[0] {
|
switch v[0] {
|
||||||
|
@ -38,6 +38,18 @@ func TestCustomStorageDevice_UnmarshalJSON(t *testing.T) {
|
|||||||
SSD: types.CustomBool(true).Pointer(),
|
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",
|
name: "raw volume type",
|
||||||
line: `"nfs:2041/vm-2041-disk-0.raw,discard=ignore,ssd=1,iothread=1,size=8G"`,
|
line: `"nfs:2041/vm-2041-disk-0.raw,discard=ignore,ssd=1,iothread=1,size=8G"`,
|
||||||
|
Loading…
Reference in New Issue
Block a user