From f07431b21d056c7dca59e6592a023ed10e5805da Mon Sep 17 00:00:00 2001 From: ZJY <764763903@qq.com> Date: Thu, 2 Sep 2021 11:37:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E5=8B=BF=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/container.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/models/container.go b/models/container.go index 185b7e2..8a6d809 100644 --- a/models/container.go +++ b/models/container.go @@ -349,8 +349,10 @@ func (c *Container) read() error { } func (c *Container) getToken() error { - logs.Warn(string(c.Version)) - if c.Version == "2.9" { + version, err := GetQlVersion(c.Address) + logs.Warn(err) + if version == "2.9" { + logs.Info("获取新版token") req := httplib.Get(c.Address + fmt.Sprintf(`/open/auth/token?client_id=%s&client_secret=%s`, c.Username, c.Password)) req.Header("Content-Type", "application/json;charset=UTF-8") if rsp, err := req.Response(); err == nil { @@ -365,7 +367,7 @@ func (c *Container) getToken() error { return err } } else { - logs.Warn("旧版token") + logs.Info("获取旧版token") req := httplib.Post(c.Address + "/api/login") req.Header("Content-Type", "application/json;charset=UTF-8") req.Body(fmt.Sprintf(`{"username":"%s","password":"%s"}`, c.Username, c.Password)) @@ -391,6 +393,7 @@ func (c *Container) request(ss ...string) ([]byte, error) { if s == GET || s == POST || s == PUT || s == DELETE { method = s } else if strings.Contains(s, "/api/") { + logs.Info(c.Version) //if c.Version == "2.9" { // api = strings.ReplaceAll(s, "api", "open") //} else {