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