Skip to content

Commit

Permalink
fix(vm): only set initialization.upgrade attribute when not using c…
Browse files Browse the repository at this point in the history
…ustom cloud-init file (#1253)

* fix: ignore upgrade parameter when custom cloud-init file is used

Signed-off-by: Kai <nankeen@users.noreply.github.com>

* fix acceptance tests, make `upgrade` computed

Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>

---------

Signed-off-by: Kai <nankeen@users.noreply.github.com>
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
Co-authored-by: Kai <nankeen@users.noreply.github.com>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
  • Loading branch information
3 people committed May 6, 2024
1 parent b6af836 commit 9762405
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fwprovider/tests/resource_vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func TestAccResourceVMInitialization(t *testing.T) {
}`),
Check: resource.ComposeTestCheckFunc(
testResourceAttributes("proxmox_virtual_environment_vm.test_vm_cloudinit", map[string]string{
"initialization.0.upgrade": "true",
"initialization.0.upgrade": "false",
}),
),
}}},
Expand Down
4 changes: 2 additions & 2 deletions proxmoxtf/resource/vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ func VM() *schema.Resource {
Type: schema.TypeBool,
Description: "Whether to do an automatic package upgrade after the first boot",
Optional: true,
Default: dvInitializationUpgrade,
Computed: true,
},
},
},
Expand Down Expand Up @@ -2970,7 +2970,7 @@ func vmGetCloudInitConfig(d *schema.ResourceData) *vms.CustomCloudInitConfig {
initializationConfig.Type = &initializationType
}

if initializationBlock[mkInitializationUpgrade] != nil {
if initializationBlock[mkInitializationUpgrade] != nil && initializationConfig.Files == nil {
v := types.CustomBool(initializationBlock[mkInitializationUpgrade].(bool))
initializationConfig.Upgrade = &v
}
Expand Down

0 comments on commit 9762405

Please sign in to comment.