fix: build error with basicAuth.Password
This commit is contained in:
parent
80bb9b61a7
commit
ae3b792f7f
|
@ -22,7 +22,6 @@ func bootstrapRequirementCheck() error{
|
|||
return nil
|
||||
}
|
||||
|
||||
|
||||
func checkElasticsearchRequirements() error {
|
||||
log.Trace("start to check system cluster requirement")
|
||||
var esConfigs = []elastic.ElasticsearchConfig{}
|
||||
|
@ -54,7 +53,7 @@ func checkElasticsearchRequirements() error{
|
|||
}
|
||||
var req = util.NewGetRequest(targetEsConfig.GetAnyEndpoint(), nil)
|
||||
if targetEsConfig.BasicAuth != nil {
|
||||
req.SetBasicAuth(targetEsConfig.BasicAuth.Username, targetEsConfig.BasicAuth.Password)
|
||||
req.SetBasicAuth(targetEsConfig.BasicAuth.Username, targetEsConfig.BasicAuth.Password.Get())
|
||||
}
|
||||
|
||||
result, err := util.ExecuteRequest(req)
|
||||
|
@ -66,7 +65,6 @@ func checkElasticsearchRequirements() error{
|
|||
return fmt.Errorf("failed to retrive cluster version info")
|
||||
}
|
||||
|
||||
|
||||
versionNumber, err := jsonparser.GetString(result.Body, "version", "number")
|
||||
if err != nil {
|
||||
return fmt.Errorf("check system cluster requirement error: %v, got response: %s", err, string(result.Body))
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package config
|
||||
|
||||
const LastCommitLog = "48882e67badf2813406d1b9bdc65c20f22c0f8fd"
|
||||
const BuildDate = "2024-03-20T02:20:55Z"
|
||||
const LastCommitLog = "N/A"
|
||||
const BuildDate = "N/A"
|
||||
|
||||
const EOLDate = "2024-12-31T10:10:10Z"
|
||||
const EOLDate = "N/A"
|
||||
|
||||
const Version = "1.0.0_SNAPSHOT"
|
||||
const Version = "0.0.1-SNAPSHOT"
|
||||
|
||||
const BuildNumber = "001"
|
||||
|
|
|
@ -15,6 +15,7 @@ import (
|
|||
"infini.sh/framework/core/util"
|
||||
"infini.sh/framework/modules/pipeline"
|
||||
)
|
||||
|
||||
type TaskWorker struct {
|
||||
model.Instance
|
||||
}
|
||||
|
@ -134,7 +135,7 @@ func (inst *TaskWorker) TryConnectWithTimeout(duration time.Duration) error {
|
|||
|
||||
func (inst *TaskWorker) doRequest(req *util.Request, resBody interface{}) error {
|
||||
if inst.BasicAuth != nil && inst.BasicAuth.Username != "" {
|
||||
req.SetBasicAuth(inst.BasicAuth.Username, inst.BasicAuth.Password)
|
||||
req.SetBasicAuth(inst.BasicAuth.Username, inst.BasicAuth.Password.Get())
|
||||
}
|
||||
result, err := util.ExecuteRequest(req)
|
||||
if err != nil {
|
||||
|
|
|
@ -631,7 +631,6 @@ func (h *APIHandler) internalProcessBind(clusterID,clusterUUID,instanceID,instan
|
|||
return nil
|
||||
}
|
||||
|
||||
|
||||
func (h *APIHandler) getESNodeInfoViaProxy(esHost string, esSchema string, auth *model.BasicAuth, endpoint string) (success, tryAgain bool, info *elastic.LocalNodeInfo) {
|
||||
esConfig := elastic.ElasticsearchConfig{Host: esHost, Schema: esSchema, BasicAuth: auth}
|
||||
return h.getESNodeInfoViaProxyWithConfig(&esConfig, auth, endpoint)
|
||||
|
@ -648,7 +647,7 @@ func (h *APIHandler) getESNodeInfoViaProxyWithConfig(cfg *elastic.ElasticsearchC
|
|||
Body: body,
|
||||
}
|
||||
if auth != nil {
|
||||
req.SetBasicAuth(auth.Username, auth.Password)
|
||||
req.SetBasicAuth(auth.Username, auth.Password.Get())
|
||||
}
|
||||
|
||||
obj := elastic.LocalNodeInfo{}
|
||||
|
|
|
@ -189,7 +189,7 @@ func getAgentIngestConfigs(instance string, items map[string]BindingItem) (strin
|
|||
}
|
||||
if auth, ok := dv.(model.BasicAuth); ok {
|
||||
username = auth.Username
|
||||
password = auth.Password
|
||||
password = auth.Password.Get()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import (
|
|||
)
|
||||
|
||||
const emailServerConfigFile = "send_email.yml"
|
||||
|
||||
func RefreshEmailServer() error {
|
||||
q := orm.Query{
|
||||
Size: 10,
|
||||
|
@ -82,7 +83,7 @@ func GeneratePipelineConfig(servers []model.EmailServer) (string, error) {
|
|||
smtpServers := map[string]util.MapStr{}
|
||||
for _, srv := range servers {
|
||||
key := getEmailPasswordKey(srv)
|
||||
err := keystore.SetValue(key, []byte(srv.Auth.Password))
|
||||
err := keystore.SetValue(key, []byte(srv.Auth.Password.Get()))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,9 @@ import (
|
|||
"bytes"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"github.com/buger/jsonparser"
|
||||
log "github.com/cihub/seelog"
|
||||
"github.com/gopkg.in/gomail.v2"
|
||||
"infini.sh/console/model"
|
||||
"infini.sh/console/model/alerting"
|
||||
"infini.sh/console/plugin/api/email/common"
|
||||
|
@ -17,8 +19,6 @@ import (
|
|||
"infini.sh/framework/core/orm"
|
||||
"infini.sh/framework/core/util"
|
||||
"net/http"
|
||||
"github.com/buger/jsonparser"
|
||||
"github.com/gopkg.in/gomail.v2"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
@ -108,7 +108,7 @@ func saveBasicAuthToCredential(srv *model.EmailServer)(string, error){
|
|||
Payload: map[string]interface{}{
|
||||
"basic_auth": map[string]interface{}{
|
||||
"username": srv.Auth.Username,
|
||||
"password": srv.Auth.Password,
|
||||
"password": srv.Auth.Password.Get(),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -356,7 +356,7 @@ func (h *EmailAPI) testEmailServer(w http.ResponseWriter, req *http.Request, ps
|
|||
message.SetHeader("Subject", "INFINI platform test email")
|
||||
|
||||
message.SetBody("text/plain", "This is just a test email, do not reply!")
|
||||
d := gomail.NewDialerWithTimeout(reqBody.Host, reqBody.Port, reqBody.Auth.Username, reqBody.Auth.Password, 3*time.Second)
|
||||
d := gomail.NewDialerWithTimeout(reqBody.Host, reqBody.Port, reqBody.Auth.Username, reqBody.Auth.Password.Get(), 3*time.Second)
|
||||
d.TLSConfig = &tls.Config{InsecureSkipVerify: true}
|
||||
d.SSL = reqBody.TLS
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"infini.sh/framework/lib/go-ucfg"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
@ -97,7 +98,7 @@ func (module *Module) Start() error {
|
|||
return
|
||||
}
|
||||
if basicAuth, ok := bv.(model.BasicAuth); ok {
|
||||
err = keystore.SetValue("SYSTEM_CLUSTER_PASS", []byte(basicAuth.Password))
|
||||
err = keystore.SetValue("SYSTEM_CLUSTER_PASS", []byte(basicAuth.Password.Get()))
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
@ -283,7 +284,7 @@ func (module *Module) initTempClient(r *http.Request) (error, elastic.API, Setup
|
|||
Endpoint: request.Cluster.Endpoint,
|
||||
BasicAuth: &model.BasicAuth{
|
||||
Username: request.Cluster.Username,
|
||||
Password: request.Cluster.Password,
|
||||
Password: ucfg.SecretString(request.Cluster.Password),
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -458,7 +459,7 @@ func (module *Module) initialize(w http.ResponseWriter, r *http.Request, ps http
|
|||
if oldCfg.CredentialID != "" && !secretMismatch {
|
||||
basicAuth, _ := elastic1.GetBasicAuth(&oldCfg)
|
||||
if basicAuth != nil {
|
||||
if basicAuth.Username == request.Cluster.Username && basicAuth.Password == request.Cluster.Password {
|
||||
if basicAuth.Username == request.Cluster.Username && basicAuth.Password.Get() == request.Cluster.Password {
|
||||
reuseOldCred = true
|
||||
}
|
||||
}
|
||||
|
@ -528,7 +529,7 @@ func (module *Module) initialize(w http.ResponseWriter, r *http.Request, ps http
|
|||
panic(err)
|
||||
}
|
||||
}
|
||||
err = keystore.SetValue("SYSTEM_CLUSTER_PASS", []byte(cfg.BasicAuth.Password))
|
||||
err = keystore.SetValue("SYSTEM_CLUSTER_PASS", []byte(cfg.BasicAuth.Password.Get()))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue