mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-07-01 19:12:59 +00:00
fix(vm): cpu.architecture
showed as new attribute at re-apply after creation (#1524)
Fix for another use case of mismanaged default value. This one was a bit trickier to spot as it triggered only when provider is authenticated using root@pam, as architecture change is allowed only for root. Removing default value altogether, as the PVE API default for this attribute is an empty string. VM2 resource will have no such issue, related: #1310, #1311 Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
parent
35b6571bf4
commit
c20d79dfbe
@ -55,6 +55,7 @@ func BIOSValidator() schema.SchemaValidateDiagFunc {
|
||||
// CPUArchitectureValidator returns a schema validation function for a CPU architecture.
|
||||
func CPUArchitectureValidator() schema.SchemaValidateDiagFunc {
|
||||
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
||||
"",
|
||||
"aarch64",
|
||||
"x86_64",
|
||||
}, false))
|
||||
|
@ -58,7 +58,7 @@ const (
|
||||
dvCloneNodeName = ""
|
||||
dvCloneFull = true
|
||||
dvCloneRetries = 1
|
||||
dvCPUArchitecture = "x86_64"
|
||||
dvCPUArchitecture = ""
|
||||
dvCPUCores = 1
|
||||
dvCPUHotplugged = 0
|
||||
dvCPULimit = 0
|
||||
@ -1890,8 +1890,7 @@ func vmCreateClone(ctx context.Context, d *schema.ResourceData, m interface{}) d
|
||||
}
|
||||
|
||||
// Only the root account is allowed to change the CPU architecture, which makes this check necessary.
|
||||
if client.API().IsRootTicket() ||
|
||||
cpuArchitecture != dvCPUArchitecture {
|
||||
if client.API().IsRootTicket() && cpuArchitecture != "" {
|
||||
updateBody.CPUArchitecture = &cpuArchitecture
|
||||
}
|
||||
|
||||
@ -2574,8 +2573,7 @@ func vmCreateCustom(ctx context.Context, d *schema.ResourceData, m interface{})
|
||||
}
|
||||
|
||||
// Only the root account is allowed to change the CPU architecture, which makes this check necessary.
|
||||
if client.API().IsRootTicket() ||
|
||||
cpuArchitecture != dvCPUArchitecture {
|
||||
if client.API().IsRootTicket() && cpuArchitecture != "" {
|
||||
createBody.CPUArchitecture = &cpuArchitecture
|
||||
}
|
||||
|
||||
@ -4845,8 +4843,7 @@ func vmUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
|
||||
cpuAffinity := cpuBlock[mkCPUAffinity].(string)
|
||||
|
||||
// Only the root account is allowed to change the CPU architecture, which makes this check necessary.
|
||||
if client.API().IsRootTicket() ||
|
||||
cpuArchitecture != dvCPUArchitecture {
|
||||
if client.API().IsRootTicket() && cpuArchitecture != "" {
|
||||
updateBody.CPUArchitecture = &cpuArchitecture
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user