0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-07-01 19:12:59 +00:00

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>
This commit is contained in:
Pavel Boldyrev 2023-11-05 19:30:43 -05:00 committed by GitHub
parent 3fd6b6b2ce
commit 3f582d8163
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -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://<your-cluster-endpoint>:8006/`.
`https://<your-cluster-endpoint>: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`.

View File

@ -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{