From 3f582d816334d4db370e8a5124f27ae4842c93f1 Mon Sep 17 00:00:00 2001 From: Pavel Boldyrev <627562+bpg@users.noreply.github.com> Date: Sun, 5 Nov 2023 19:30:43 -0500 Subject: [PATCH] fix(provider): sanitize PVE endpoint value (#686) Ignore `/api2/json` path in case it is present in the endpoint. Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> --- docs/index.md | 3 ++- proxmox/api/client.go | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index 89f51cb8..0cc64cd5 100644 --- a/docs/index.md +++ b/docs/index.md @@ -186,7 +186,8 @@ Proxmox `provider` block: - `endpoint` - (Required) The endpoint for the Proxmox Virtual Environment API (can also be sourced from `PROXMOX_VE_ENDPOINT`). Usually this is - `https://:8006/`. + `https://:8006/`. **Do not** include `/api2/json` at + the end. - `insecure` - (Optional) Whether to skip the TLS verification step (can also be sourced from `PROXMOX_VE_INSECURE`). If omitted, defaults to `false`. diff --git a/proxmox/api/client.go b/proxmox/api/client.go index 17e11e38..11227b5d 100644 --- a/proxmox/api/client.go +++ b/proxmox/api/client.go @@ -84,6 +84,9 @@ func NewConnection(endpoint string, insecure bool) (*Connection, error) { transport = logging.NewLoggingHTTPTransport(transport) } + // make sure the path does not contain "/api2/json" + u.Path = "" + return &Connection{ endpoint: strings.TrimRight(u.String(), "/"), httpClient: &http.Client{