mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-06-30 02:31:10 +00:00
fix(vm): prevent cloud-init username reset to " "
during create (#1863)
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
parent
af46a9c71a
commit
c9fcb30762
@ -494,6 +494,24 @@ func TestAccResourceVMInitialization(t *testing.T) {
|
||||
}),
|
||||
),
|
||||
}}},
|
||||
{"native cloud-init: username should not change", []resource.TestStep{{
|
||||
Config: te.RenderConfig(`
|
||||
resource "proxmox_virtual_environment_vm" "test_vm_cloudinit4" {
|
||||
node_name = "{{.NodeName}}"
|
||||
started = false
|
||||
initialization {
|
||||
user_account {
|
||||
keys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOQCHPhOV9XsJa3uq4bmKymklNy6ktgBB/+2umizgnnY"]
|
||||
}
|
||||
}
|
||||
}`),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
NoResourceAttributesSet("proxmox_virtual_environment_vm.test_vm_cloudinit4", []string{
|
||||
"initialization.0.username",
|
||||
"initialization.0.password",
|
||||
}),
|
||||
),
|
||||
}}},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
@ -2937,7 +2937,9 @@ func vmGetCloudInitConfig(d *schema.ResourceData) *vms.CustomCloudInitConfig {
|
||||
}
|
||||
|
||||
username := initializationUserAccountBlock[mkInitializationUserAccountUsername].(string)
|
||||
initializationConfig.Username = &username
|
||||
if username != "" {
|
||||
initializationConfig.Username = &username
|
||||
}
|
||||
}
|
||||
|
||||
initializationUserDataFileID := initializationBlock[mkInitializationUserDataFileID].(string)
|
||||
|
Loading…
Reference in New Issue
Block a user