[plugin] fix naming (#42)
[plugin] fix naming Co-authored-by: Kassian Sun <kassiansun@outlook.com>
This commit is contained in:
parent
24ca0c91a5
commit
08a1673c1a
|
@ -5,6 +5,14 @@ import (
|
|||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
uri2 "net/url"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
log "github.com/cihub/seelog"
|
||||
"github.com/valyala/fasttemplate"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
|
@ -27,13 +35,6 @@ import (
|
|||
elastic1 "infini.sh/framework/modules/elastic/common"
|
||||
"infini.sh/framework/modules/security"
|
||||
"infini.sh/framework/plugins/replay"
|
||||
"io"
|
||||
"net/http"
|
||||
uri2 "net/url"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Module struct {
|
||||
|
@ -60,6 +61,7 @@ func (module *Module) Setup() {
|
|||
}
|
||||
|
||||
var setupFinishedCallback = []func(){}
|
||||
|
||||
func RegisterSetupCallback(f func()) {
|
||||
setupFinishedCallback = append(setupFinishedCallback, f)
|
||||
}
|
||||
|
@ -169,7 +171,6 @@ func (module *Module) validate(w http.ResponseWriter, r *http.Request, ps httpro
|
|||
module.WriteJSON(w, result, code)
|
||||
}()
|
||||
|
||||
|
||||
err, client, _ := module.initTempClient(r)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -177,7 +178,7 @@ func (module *Module) validate(w http.ResponseWriter, r *http.Request, ps httpro
|
|||
|
||||
//validate version
|
||||
verInfo, err := adapter.ClusterVersion(elastic.GetMetadata(cfg.ID))
|
||||
if verInfo.Version.Distribution == elastic.Elasticsarch {
|
||||
if verInfo.Version.Distribution == elastic.Elasticsearch {
|
||||
if verInfo.Version.Number != "" {
|
||||
ver := &util.Version{}
|
||||
ver, err = util.ParseSemantic(verInfo.Version.Number)
|
||||
|
@ -243,7 +244,9 @@ func (module *Module) validate(w http.ResponseWriter, r *http.Request, ps httpro
|
|||
|
||||
success = true
|
||||
}
|
||||
|
||||
var cfg elastic.ElasticsearchConfig
|
||||
|
||||
func (module *Module) initTempClient(r *http.Request) (error, elastic.API, SetupRequest) {
|
||||
request := SetupRequest{}
|
||||
err := module.DecodeJSON(r, &request)
|
||||
|
@ -280,7 +283,6 @@ func (module *Module) initTempClient(r *http.Request) (error, elastic.API,SetupR
|
|||
cfg.Schema = uri.Scheme
|
||||
}
|
||||
|
||||
|
||||
cfg.ID = GlobalSystemElasticsearchID
|
||||
cfg.Name = "INFINI_SYSTEM (" + util.PickRandomName() + ")"
|
||||
elastic.InitMetadata(&cfg, true)
|
||||
|
@ -402,7 +404,7 @@ func (module *Module) initialize(w http.ResponseWriter, r *http.Request, ps http
|
|||
//INDEX_PREFIX
|
||||
ver := elastic.GetClient(GlobalSystemElasticsearchID).GetVersion()
|
||||
dslTplFileName := "initialization.tpl"
|
||||
if ver.Distribution == "" || ver.Distribution == elastic.Elasticsarch { //elasticsearch distribution
|
||||
if ver.Distribution == "" || ver.Distribution == elastic.Elasticsearch { //elasticsearch distribution
|
||||
majorVersion := elastic.GetClient(GlobalSystemElasticsearchID).GetMajorVersion()
|
||||
if majorVersion == 6 {
|
||||
dslTplFileName = "initialization_v6.tpl"
|
||||
|
@ -411,7 +413,6 @@ func (module *Module) initialize(w http.ResponseWriter, r *http.Request, ps http
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
dslTplFile := path.Join(global.Env().GetConfigDir(), dslTplFileName)
|
||||
dslFile := path.Join(global.Env().GetConfigDir(), "initialization.dsl")
|
||||
|
||||
|
@ -480,7 +481,6 @@ func (module *Module) initialize(w http.ResponseWriter, r *http.Request, ps http
|
|||
//init security
|
||||
security.InitSecurity()
|
||||
|
||||
|
||||
toSaveCfg := cfg
|
||||
if request.Cluster.Username != "" || request.Cluster.Password != "" {
|
||||
cred := credential.Credential{
|
||||
|
@ -545,7 +545,6 @@ func (module *Module) initialize(w http.ResponseWriter, r *http.Request, ps http
|
|||
panic(err)
|
||||
}
|
||||
|
||||
|
||||
//save to local file
|
||||
file := path.Join(global.Env().GetConfigDir(), "system_config.yml")
|
||||
_, err = util.FilePutContent(file, fmt.Sprintf("configs.template:\n - name: \"system\"\n path: ./config/system_config.tpl\n variable:\n "+
|
||||
|
|
Loading…
Reference in New Issue