fixes openstack api endpoint with suffix trim adds openstack (#840)

api v2.0 check

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/728
This commit is contained in:
Nikolay Khramchikhin 2020-10-16 21:20:57 +03:00 committed by Aliaksandr Valialkin
parent 8d87b57fbf
commit a5d842caf8

View File

@ -3,11 +3,13 @@ package openstack
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
"strings"
"sync" "sync"
"time" "time"
@ -95,6 +97,11 @@ func newAPIConfig(sdc *SDConfig, baseDir string) (*apiConfig, error) {
// override sdc // override sdc
sdcAuth = readCredentialsFromEnv() sdcAuth = readCredentialsFromEnv()
} }
if strings.HasSuffix(sdcAuth.IdentityEndpoint, "v2.0") {
return nil, errors.New("identity_endpoint v2.0 is not supported")
}
// trim .0 from v3.0 for prometheus cfg compatibility
sdcAuth.IdentityEndpoint = strings.TrimSuffix(sdcAuth.IdentityEndpoint, ".0")
parsedURL, err := url.Parse(sdcAuth.IdentityEndpoint) parsedURL, err := url.Parse(sdcAuth.IdentityEndpoint)
if err != nil { if err != nil {