Fix error message if URL is unparseable in influxdb output (#4511)

This commit is contained in:
Daniel Nelson 2018-08-07 11:07:46 -07:00 committed by GitHub
parent a5409d7cf2
commit 4dfb80d0fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 7 deletions

View File

@ -141,36 +141,36 @@ func (i *InfluxDB) Connect() error {
} }
for _, u := range urls { for _, u := range urls {
u, err := url.Parse(u) parts, err := url.Parse(u)
if err != nil { if err != nil {
return fmt.Errorf("error parsing url [%s]: %v", u, err) return fmt.Errorf("error parsing url [%q]: %v", u, err)
} }
var proxy *url.URL var proxy *url.URL
if len(i.HTTPProxy) > 0 { if len(i.HTTPProxy) > 0 {
proxy, err = url.Parse(i.HTTPProxy) proxy, err = url.Parse(i.HTTPProxy)
if err != nil { if err != nil {
return fmt.Errorf("error parsing proxy_url [%s]: %v", proxy, err) return fmt.Errorf("error parsing proxy_url [%s]: %v", i.HTTPProxy, err)
} }
} }
switch u.Scheme { switch parts.Scheme {
case "udp", "udp4", "udp6": case "udp", "udp4", "udp6":
c, err := i.udpClient(u) c, err := i.udpClient(parts)
if err != nil { if err != nil {
return err return err
} }
i.clients = append(i.clients, c) i.clients = append(i.clients, c)
case "http", "https", "unix": case "http", "https", "unix":
c, err := i.httpClient(ctx, u, proxy) c, err := i.httpClient(ctx, parts, proxy)
if err != nil { if err != nil {
return err return err
} }
i.clients = append(i.clients, c) i.clients = append(i.clients, c)
default: default:
return fmt.Errorf("unsupported scheme [%s]: %q", u, u.Scheme) return fmt.Errorf("unsupported scheme [%q]: %q", u, parts.Scheme)
} }
} }