diff --git a/fwprovider/access/resource_acl_model.go b/fwprovider/access/resource_acl_model.go index 5344244d..a4a6b0be 100644 --- a/fwprovider/access/resource_acl_model.go +++ b/fwprovider/access/resource_acl_model.go @@ -72,7 +72,7 @@ func (r *aclResourceModel) intoUpdateBody() *access.ACLUpdateRequestBody { body := &access.ACLUpdateRequestBody{ Groups: nil, Path: r.Path, - Propagate: proxmoxtypes.CustomBoolPtr(r.Propagate), + Propagate: proxmoxtypes.CustomBool(r.Propagate).Pointer(), Roles: []string{r.RoleID}, Tokens: nil, Users: nil, diff --git a/fwprovider/access/resource_user_token.go b/fwprovider/access/resource_user_token.go index 54e2671f..331e0e5f 100644 --- a/fwprovider/access/resource_user_token.go +++ b/fwprovider/access/resource_user_token.go @@ -144,7 +144,7 @@ func (r *userTokenResource) Create(ctx context.Context, req resource.CreateReque body := access.UserTokenCreateRequestBody{ Comment: plan.Comment.ValueStringPointer(), - PrivSeparate: proxmoxtypes.CustomBoolPtr(plan.PrivSeparation.ValueBool()), + PrivSeparate: proxmoxtypes.CustomBoolPtr(plan.PrivSeparation.ValueBoolPointer()), } if !plan.ExpirationDate.IsNull() && plan.ExpirationDate.ValueString() != "" { @@ -215,7 +215,7 @@ func (r *userTokenResource) Update(ctx context.Context, req resource.UpdateReque body := access.UserTokenUpdateRequestBody{ Comment: plan.Comment.ValueStringPointer(), - PrivSeparate: proxmoxtypes.CustomBoolPtr(plan.PrivSeparation.ValueBool()), + PrivSeparate: proxmoxtypes.CustomBoolPtr(plan.PrivSeparation.ValueBoolPointer()), } if !plan.ExpirationDate.IsNull() && plan.ExpirationDate.ValueString() != "" { diff --git a/fwprovider/vm/resource.go b/fwprovider/vm/resource.go index 68aef1d7..8ffa3264 100644 --- a/fwprovider/vm/resource.go +++ b/fwprovider/vm/resource.go @@ -137,7 +137,7 @@ func (r *vmResource) create(ctx context.Context, plan vmModel, diags *diag.Diagn Description: plan.Description.ValueStringPointer(), Name: plan.Name.ValueStringPointer(), Tags: plan.Tags.ValueStringPointer(ctx, diags), - Template: proxmoxtypes.CustomBoolPtr(plan.Template.ValueBool()), + Template: proxmoxtypes.CustomBoolPtr(plan.Template.ValueBoolPointer()), VMID: int(plan.ID.ValueInt64()), } diff --git a/proxmox/nodes/vms/vms_types_test.go b/proxmox/nodes/vms/vms_types_test.go index 5f72cb56..d0b1a4c9 100644 --- a/proxmox/nodes/vms/vms_types_test.go +++ b/proxmox/nodes/vms/vms_types_test.go @@ -34,9 +34,9 @@ func TestCustomStorageDevice_UnmarshalJSON(t *testing.T) { Discard: ptr.Ptr("on"), Enabled: true, FileVolume: "local-lvm:vm-2041-disk-0", - IOThread: types.CustomBoolPtr(true), + IOThread: types.CustomBool(true).Pointer(), Size: ds8gig, - SSD: types.CustomBoolPtr(true), + SSD: types.CustomBool(true).Pointer(), }, }, { @@ -47,9 +47,9 @@ func TestCustomStorageDevice_UnmarshalJSON(t *testing.T) { Enabled: true, FileVolume: "nfs:2041/vm-2041-disk-0.raw", Format: ptr.Ptr("raw"), - IOThread: types.CustomBoolPtr(true), + IOThread: types.CustomBool(true).Pointer(), Size: ds8gig, - SSD: types.CustomBoolPtr(true), + SSD: types.CustomBool(true).Pointer(), }, }, } @@ -240,10 +240,10 @@ func TestCustomPCIDevice_UnmarshalJSON(t *testing.T) { want: &CustomPCIDevice{ DeviceIDs: &[]string{"81:00.4"}, MDev: nil, - PCIExpress: types.CustomBoolPtr(false), - ROMBAR: types.CustomBoolPtr(true), + PCIExpress: types.CustomBool(false).Pointer(), + ROMBAR: types.CustomBool(true).Pointer(), ROMFile: nil, - XVGA: types.CustomBoolPtr(false), + XVGA: types.CustomBool(false).Pointer(), }, }, { @@ -253,10 +253,10 @@ func TestCustomPCIDevice_UnmarshalJSON(t *testing.T) { DeviceIDs: nil, Mapping: ptr.Ptr("mappeddevice"), MDev: nil, - PCIExpress: types.CustomBoolPtr(false), - ROMBAR: types.CustomBoolPtr(true), + PCIExpress: types.CustomBool(false).Pointer(), + ROMBAR: types.CustomBool(true).Pointer(), ROMFile: nil, - XVGA: types.CustomBoolPtr(false), + XVGA: types.CustomBool(false).Pointer(), }, }, } @@ -337,7 +337,7 @@ func TestCustomUSBDevice_UnmarshalJSON(t *testing.T) { line: `"host=81:00,usb3=0"`, want: &CustomUSBDevice{ HostDevice: ptr.Ptr("81:00"), - USB3: types.CustomBoolPtr(false), + USB3: types.CustomBool(false).Pointer(), }, }, { @@ -346,7 +346,7 @@ func TestCustomUSBDevice_UnmarshalJSON(t *testing.T) { want: &CustomUSBDevice{ HostDevice: nil, Mapping: ptr.Ptr("mappeddevice"), - USB3: types.CustomBoolPtr(false), + USB3: types.CustomBool(false).Pointer(), }, }, } diff --git a/proxmox/types/common_types.go b/proxmox/types/common_types.go index d3607610..fdff1181 100644 --- a/proxmox/types/common_types.go +++ b/proxmox/types/common_types.go @@ -41,8 +41,12 @@ type CustomPrivileges []string type CustomTimestamp time.Time // CustomBoolPtr creates a pointer to a CustomBool. -func CustomBoolPtr(b bool) *CustomBool { - return ptr.Ptr(CustomBool(b)) +func CustomBoolPtr(b *bool) *CustomBool { + if b == nil { + return nil + } + + return ptr.Ptr(CustomBool(*b)) } // MarshalJSON converts a boolean to a JSON value.