0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-06-30 02:31:10 +00:00

chore(code): fix code problems reported by Qodana (#1934)

Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
Pavel Boldyrev 2025-04-27 21:07:01 -04:00 committed by GitHub
parent 794e959cf2
commit ebd5399e14
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 27 additions and 30 deletions

View File

@ -382,9 +382,7 @@ func (d *CustomStorageDevice) UnmarshalJSON(b []byte) error {
//
// It will return true if any attribute of the current CustomStorageDevice was changed.
func (d *CustomStorageDevice) MergeWith(m CustomStorageDevice) bool {
updated := false
updated = ptr.UpdateIfChanged(&d.AIO, m.AIO) || updated
updated := ptr.UpdateIfChanged(&d.AIO, m.AIO)
updated = ptr.UpdateIfChanged(&d.Backup, m.Backup) || updated
updated = ptr.UpdateIfChanged(&d.BurstableReadSpeedMbps, m.BurstableReadSpeedMbps) || updated
updated = ptr.UpdateIfChanged(&d.BurstableWriteSpeedMbps, m.BurstableWriteSpeedMbps) || updated

View File

@ -73,7 +73,7 @@ func (r *CustomVirtiofsShare) EncodeValues(key string, v *url.Values) error {
}
// EncodeValues converts a CustomVirtiofsShares dict to multiple URL values.
func (r CustomVirtiofsShares) EncodeValues(key string, v *url.Values) error {
func (r CustomVirtiofsShares) EncodeValues(_ string, v *url.Values) error {
for s, d := range r {
if err := d.EncodeValues(s, v); err != nil {
return fmt.Errorf("failed to encode virtiofs share %s: %w", s, err)

View File

@ -85,7 +85,6 @@ const (
dvInitializationIPConfigIPv6Address = ""
dvInitializationIPConfigIPv6Gateway = ""
dvInitializationUserAccountPassword = ""
dvInitializationType = ""
dvKeyboardLayout = "en-us"
dvKVMArguments = ""
dvMachineType = ""
@ -290,9 +289,9 @@ const (
mkVirtiofs = "virtiofs"
mkVirtiofsMapping = "mapping"
mkVirtiofsCache = "cache"
mkVirtiofsDirectIo = "direct_io"
mkVirtiofsExposeAcl = "expose_acl"
mkVirtiofsExposeXattr = "expose_xattr"
mkVirtiofsDirectIO = "direct_io"
mkVirtiofsExposeACL = "expose_acl"
mkVirtiofsExposeXAttr = "expose_xattr"
mkWatchdog = "watchdog"
// a workaround for the lack of proper support of default and undefined values in SDK.
mkWatchdogEnabled = "enabled"
@ -1495,19 +1494,19 @@ func VM() *schema.Resource {
Default: dvVirtiofsCache,
ValidateDiagFunc: VirtiofsCacheValidator(),
},
mkVirtiofsDirectIo: {
mkVirtiofsDirectIO: {
Type: schema.TypeBool,
Description: "Whether to allow direct io",
Optional: true,
Default: dvVirtiofsDirectIo,
},
mkVirtiofsExposeAcl: {
mkVirtiofsExposeACL: {
Type: schema.TypeBool,
Description: "Enable POSIX ACLs, implies xattr support",
Optional: true,
Default: dvVirtiofsExposeAcl,
},
mkVirtiofsExposeXattr: {
mkVirtiofsExposeXAttr: {
Type: schema.TypeBool,
Description: "Enable support for extended attributes",
Optional: true,
@ -3411,15 +3410,15 @@ func vmGetVirtiofsShares(d *schema.ResourceData) vms.CustomVirtiofsShares {
mapping, _ := block[mkVirtiofsMapping].(string)
cache, _ := block[mkVirtiofsCache].(string)
direct_io := types.CustomBool(block[mkVirtiofsDirectIo].(bool))
expose_acl := types.CustomBool(block[mkVirtiofsExposeAcl].(bool))
expose_xattr := types.CustomBool(block[mkVirtiofsExposeXattr].(bool))
directIO := types.CustomBool(block[mkVirtiofsDirectIO].(bool))
exposeACL := types.CustomBool(block[mkVirtiofsExposeACL].(bool))
exposeXAttr := types.CustomBool(block[mkVirtiofsExposeXAttr].(bool))
share := vms.CustomVirtiofsShare{
DirId: mapping,
DirectIo: &direct_io,
ExposeAcl: &expose_acl,
ExposeXattr: &expose_xattr,
DirectIo: &directIO,
ExposeAcl: &exposeACL,
ExposeXattr: &exposeXAttr,
}
if cache != "" {
@ -4064,25 +4063,25 @@ func vmReadCustom(
}
if pp.DirectIo != nil {
share[mkVirtiofsDirectIo] = *pp.DirectIo
share[mkVirtiofsDirectIO] = *pp.DirectIo
} else {
share[mkVirtiofsDirectIo] = dvVirtiofsDirectIo
share[mkVirtiofsDirectIO] = dvVirtiofsDirectIo
}
if pp.ExposeAcl != nil {
share[mkVirtiofsExposeAcl] = *pp.ExposeAcl
share[mkVirtiofsExposeACL] = *pp.ExposeAcl
} else {
share[mkVirtiofsExposeAcl] = dvVirtiofsExposeAcl
share[mkVirtiofsExposeACL] = dvVirtiofsExposeAcl
}
switch {
case pp.ExposeXattr != nil:
share[mkVirtiofsExposeXattr] = *pp.ExposeXattr
share[mkVirtiofsExposeXAttr] = *pp.ExposeXattr
case pp.ExposeAcl != nil && bool(*pp.ExposeAcl):
// expose-xattr implies expose-acl
share[mkVirtiofsExposeXattr] = true
share[mkVirtiofsExposeXAttr] = true
default:
share[mkVirtiofsExposeXattr] = dvVirtiofsExposeXattr
share[mkVirtiofsExposeXAttr] = dvVirtiofsExposeXattr
}
virtiofsMap[pi] = share

View File

@ -388,17 +388,17 @@ func TestVMSchema(t *testing.T) {
test.AssertOptionalArguments(t, virtiofsSchema, []string{
mkVirtiofsCache,
mkVirtiofsDirectIo,
mkVirtiofsExposeAcl,
mkVirtiofsExposeXattr,
mkVirtiofsDirectIO,
mkVirtiofsExposeACL,
mkVirtiofsExposeXAttr,
})
test.AssertValueTypes(t, virtiofsSchema, map[string]schema.ValueType{
mkVirtiofsMapping: schema.TypeString,
mkVirtiofsCache: schema.TypeString,
mkVirtiofsDirectIo: schema.TypeBool,
mkVirtiofsExposeAcl: schema.TypeBool,
mkVirtiofsExposeXattr: schema.TypeBool,
mkVirtiofsDirectIO: schema.TypeBool,
mkVirtiofsExposeACL: schema.TypeBool,
mkVirtiofsExposeXAttr: schema.TypeBool,
})
vgaSchema := test.AssertNestedSchemaExistence(t, s, mkVGA)