Update source timeseries client to change if meta server is set

pull/10616/head
Chris Goller 2017-02-24 14:48:42 -06:00
parent 1f9be2e4aa
commit e1764a7c02
1 changed files with 13 additions and 2 deletions

View File

@ -1,6 +1,9 @@
package server
import (
"context"
"strings"
"github.com/influxdata/chronograf"
"github.com/influxdata/chronograf/enterprise"
"github.com/influxdata/chronograf/influx"
@ -40,8 +43,16 @@ type InfluxClient struct{}
// New creates a client to connect to OSS or enterprise
func (c *InfluxClient) New(src chronograf.Source, logger chronograf.Logger) (chronograf.TimeSeries, error) {
if src.Type == "influx-enterprise" {
return enterprise.NewClientWithURL(src.URL, src.Username, src.Password, false, logger)
if src.Type == "influx-enterprise" && src.MetaURL != "" {
dataNode := &influx.Client{
Logger: logger,
}
if err := dataNode.Connect(context.TODO(), &src); err != nil {
return nil, err
}
tls := strings.Contains(src.MetaURL, "https")
return enterprise.NewClientWithTimeSeries(logger, src.MetaURL, src.Username, src.Password, tls, dataNode)
}
return &influx.Client{
Logger: logger,