Skip to content

Commit 356f710

Browse files
authored
fix: agent enroll failed (#15)
1 parent 9812249 commit 356f710

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

modules/agent/api/elasticsearch.go

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"context"
3232
"errors"
3333
"fmt"
34+
"github.com/buger/jsonparser"
3435
log "github.com/cihub/seelog"
3536
"infini.sh/console/plugin/managed/server"
3637
httprouter "infini.sh/framework/core/api/router"
@@ -661,6 +662,9 @@ func (h *APIHandler) getESNodeInfoViaProxy(esHost string, esSchema string, auth
661662

662663
func (h *APIHandler) getESNodeInfoViaProxyWithConfig(cfg *elastic.ElasticsearchConfig, auth *model.BasicAuth, endpoint string) (success, tryAgain bool, info *elastic.LocalNodeInfo) {
663664
body := util.MustToJSONBytes(cfg)
665+
if cfg.BasicAuth != nil {
666+
body, _ = jsonparser.Set(body, []byte(`"`+cfg.BasicAuth.Password.Get()+`"`), "basic_auth", "password")
667+
}
664668
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
665669
defer cancel()
666670
req := &util.Request{

0 commit comments

Comments
 (0)