Skip to content

Commit 02d31ca

Browse files
committed
Bug fixings
1 parent da6a699 commit 02d31ca

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

proxmox.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -457,17 +457,13 @@ func (p ProxmoxVE) NodesNodeQemuVMIDConfigSetSSHKeys(node string, vmid string, C
457457
SSHKeys = url.PathEscape(SSHKeys)
458458
SSHKeys = r.Replace(SSHKeys)
459459

460-
SSHKeys = url.PathEscape(SSHKeys)
461-
SSHKeys = r.Replace(SSHKeys)
462-
463-
PostBody := ""
460+
Params := url.Values{}
464461
if CIUser != "" {
465-
PostBody = fmt.Sprintf("ciuser=%s&sshkeys=%s,", CIUser, SSHKeys)
466-
} else {
467-
PostBody = fmt.Sprintf("sshkeys=%s,", SSHKeys)
462+
Params.Set("ciuser", CIUser)
468463
}
464+
Params.Set("sshkeys", SSHKeys)
469465

470-
response, err := p.client.R().SetHeader("Content-Type", "application/x-www-form-urlencoded").SetBody(PostBody).Post(p.getURL(path))
466+
response, err := p.client.R().SetHeader("Content-Type", "application/x-www-form-urlencoded").SetBody(Params.Encode()).Post(p.getURL(path))
471467

472468
if err != nil {
473469
return "", err

0 commit comments

Comments
 (0)