parent
ba2f72075f
commit
09a9d34430
|
@ -207,7 +207,7 @@ func (c *CommandLine) Run() error {
|
|||
c.Version()
|
||||
|
||||
if c.Type == QueryLanguageFlux {
|
||||
repl, err := getFluxREPL(c.Host, c.Port, c.Ssl)
|
||||
repl, err := getFluxREPL(c.Host, c.Port, c.Ssl, c.ClientConfig.Username, c.ClientConfig.Password)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -1194,7 +1194,7 @@ func (c *CommandLine) ExecuteFluxQuery(query string) error {
|
|||
}()
|
||||
}
|
||||
|
||||
repl, err := getFluxREPL(c.Host, c.Port, c.Ssl)
|
||||
repl, err := getFluxREPL(c.Host, c.Port, c.Ssl, c.ClientConfig.Username, c.ClientConfig.Password)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -30,10 +30,12 @@ func (q *replQuerier) Query(ctx context.Context, compiler flux.Compiler) (flux.R
|
|||
return q.client.Query(ctx, req)
|
||||
}
|
||||
|
||||
func getFluxREPL(host string, port int, ssl bool) (*repl.REPL, error) {
|
||||
func getFluxREPL(host string, port int, ssl bool, username, password string) (*repl.REPL, error) {
|
||||
c, err := client.NewHTTP(host, port, ssl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.Username = username
|
||||
c.Password = password
|
||||
return repl.New(&replQuerier{client: c}), nil
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ var (
|
|||
// API endpoint.
|
||||
type HTTP struct {
|
||||
Addr string
|
||||
Username string
|
||||
Password string
|
||||
InsecureSkipVerify bool
|
||||
url *url.URL
|
||||
}
|
||||
|
@ -66,6 +68,9 @@ func (s *HTTP) Query(ctx context.Context, r *ProxyRequest) (flux.ResultIterator,
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if s.Username != "" {
|
||||
hreq.SetBasicAuth(s.Username, s.Password)
|
||||
}
|
||||
|
||||
hreq.Header.Set("Content-Type", "application/json")
|
||||
hreq.Header.Set("Accept", "text/csv")
|
||||
|
|
Loading…
Reference in New Issue