mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-06-30 02:31:10 +00:00
fix(vm): unable to clone as non-root due to hook_script
(#756)
* fix(vm): unable to clone as non-root due to `hook_script` Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> * fix linter error Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> --------- Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
parent
cd24cf238c
commit
728eceb5e9
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@ -5,5 +5,9 @@
|
||||
"qcow",
|
||||
"virtio"
|
||||
],
|
||||
"go.lintTool": "golangci-lint",
|
||||
"go.lintFlags": [
|
||||
"--fast",
|
||||
],
|
||||
"go.testEnvFile": "${workspaceFolder}/test.env",
|
||||
}
|
||||
|
@ -2001,6 +2001,11 @@ func vmCreateClone(ctx context.Context, d *schema.ResourceData, m interface{}) d
|
||||
}
|
||||
}
|
||||
|
||||
vmConfig, err := vmAPI.GetVM(ctx)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
if len(initialization) > 0 {
|
||||
tflog.Trace(ctx, "Preparing the CloudInit configuration")
|
||||
|
||||
@ -2008,11 +2013,6 @@ func vmCreateClone(ctx context.Context, d *schema.ResourceData, m interface{}) d
|
||||
initializationDatastoreID := initializationBlock[mkResourceVirtualEnvironmentVMInitializationDatastoreID].(string)
|
||||
initializationInterface := initializationBlock[mkResourceVirtualEnvironmentVMInitializationInterface].(string)
|
||||
|
||||
vmConfig, err := vmAPI.GetVM(ctx)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
existingInterface := findExistingCloudInitDrive(vmConfig, vmID, "ide2")
|
||||
if initializationInterface == "" {
|
||||
initializationInterface = existingInterface
|
||||
@ -2131,9 +2131,11 @@ func vmCreateClone(ctx context.Context, d *schema.ResourceData, m interface{}) d
|
||||
}
|
||||
|
||||
hookScript := d.Get(mkResourceVirtualEnvironmentVMHookScriptFileID).(string)
|
||||
currentHookScript := vmConfig.HookScript
|
||||
|
||||
if len(hookScript) > 0 {
|
||||
updateBody.HookScript = &hookScript
|
||||
} else {
|
||||
} else if currentHookScript != nil {
|
||||
del = append(del, "hookscript")
|
||||
}
|
||||
|
||||
@ -2147,7 +2149,7 @@ func vmCreateClone(ctx context.Context, d *schema.ResourceData, m interface{}) d
|
||||
disk := d.Get(mkResourceVirtualEnvironmentVMDisk).([]interface{})
|
||||
efiDisk := d.Get(mkResourceVirtualEnvironmentVMEFIDisk).([]interface{})
|
||||
|
||||
vmConfig, e := vmAPI.GetVM(ctx)
|
||||
vmConfig, e = vmAPI.GetVM(ctx)
|
||||
if e != nil {
|
||||
if strings.Contains(e.Error(), "HTTP 404") ||
|
||||
(strings.Contains(e.Error(), "HTTP 500") && strings.Contains(e.Error(), "does not exist")) {
|
||||
|
Loading…
Reference in New Issue
Block a user