fix: agent enroll failed (#15)
This commit is contained in:
parent
9812249268
commit
356f710e4a
|
@ -31,6 +31,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/buger/jsonparser"
|
||||||
log "github.com/cihub/seelog"
|
log "github.com/cihub/seelog"
|
||||||
"infini.sh/console/plugin/managed/server"
|
"infini.sh/console/plugin/managed/server"
|
||||||
httprouter "infini.sh/framework/core/api/router"
|
httprouter "infini.sh/framework/core/api/router"
|
||||||
|
@ -661,6 +662,9 @@ func (h *APIHandler) getESNodeInfoViaProxy(esHost string, esSchema string, auth
|
||||||
|
|
||||||
func (h *APIHandler) getESNodeInfoViaProxyWithConfig(cfg *elastic.ElasticsearchConfig, auth *model.BasicAuth, endpoint string) (success, tryAgain bool, info *elastic.LocalNodeInfo) {
|
func (h *APIHandler) getESNodeInfoViaProxyWithConfig(cfg *elastic.ElasticsearchConfig, auth *model.BasicAuth, endpoint string) (success, tryAgain bool, info *elastic.LocalNodeInfo) {
|
||||||
body := util.MustToJSONBytes(cfg)
|
body := util.MustToJSONBytes(cfg)
|
||||||
|
if cfg.BasicAuth != nil {
|
||||||
|
body, _ = jsonparser.Set(body, []byte(`"`+cfg.BasicAuth.Password.Get()+`"`), "basic_auth", "password")
|
||||||
|
}
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
req := &util.Request{
|
req := &util.Request{
|
||||||
|
|
Loading…
Reference in New Issue