From fc8a47373a61b7831bf409c4ac3a78ea46de7c87 Mon Sep 17 00:00:00 2001 From: sunjiacheng Date: Tue, 21 Feb 2023 21:48:20 +0800 Subject: [PATCH] [build] fix src/* imports (#27) [build] fix src/* imports Co-authored-by: Kassian Sun --- plugin/api/alerting/channel.go | 13 +++++++------ plugin/api/insight/dashboard.go | 21 +++++++++++---------- plugin/api/insight/visualization.go | 13 +++++++------ service/alerting/init.go | 17 +++++++++-------- 4 files changed, 34 insertions(+), 30 deletions(-) diff --git a/plugin/api/alerting/channel.go b/plugin/api/alerting/channel.go index e9135c91..a7a3dc6d 100644 --- a/plugin/api/alerting/channel.go +++ b/plugin/api/alerting/channel.go @@ -6,14 +6,15 @@ package alerting import ( "fmt" + "net/http" + "strconv" + "strings" + + log "github.com/cihub/seelog" "infini.sh/console/model/alerting" httprouter "infini.sh/framework/core/api/router" "infini.sh/framework/core/orm" "infini.sh/framework/core/util" - "net/http" - log "src/github.com/cihub/seelog" - "strconv" - "strings" ) func (h *AlertAPI) createChannel(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { @@ -140,7 +141,7 @@ func (h *AlertAPI) deleteChannel(w http.ResponseWriter, req *http.Request, ps ht } h.WriteJSON(w, util.MapStr{ - "ids": reqBody.ChannelIDs , + "ids": reqBody.ChannelIDs, "result": "deleted", }, 200) } @@ -148,7 +149,7 @@ func (h *AlertAPI) deleteChannel(w http.ResponseWriter, req *http.Request, ps ht func (h *AlertAPI) searchChannel(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { var ( - keyword = h.GetParameterOrDefault(req, "keyword", "") + keyword = h.GetParameterOrDefault(req, "keyword", "") queryDSL = `{"query":{"bool":{"must":[%s]}}, "size": %d, "from": %d}` strSize = h.GetParameterOrDefault(req, "size", "20") strFrom = h.GetParameterOrDefault(req, "from", "0") diff --git a/plugin/api/insight/dashboard.go b/plugin/api/insight/dashboard.go index 0ec9b26e..1409357c 100644 --- a/plugin/api/insight/dashboard.go +++ b/plugin/api/insight/dashboard.go @@ -5,13 +5,14 @@ package insight import ( + "net/http" + "strconv" + + log "github.com/cihub/seelog" httprouter "infini.sh/framework/core/api/router" "infini.sh/framework/core/insight" "infini.sh/framework/core/orm" "infini.sh/framework/core/util" - "net/http" - log "src/github.com/cihub/seelog" - "strconv" ) func (h *InsightAPI) createDashboard(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { @@ -145,10 +146,10 @@ func (h *InsightAPI) deleteDashboard(w http.ResponseWriter, req *http.Request, p func (h *InsightAPI) searchDashboard(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { var ( - keyword = h.GetParameterOrDefault(req, "keyword", "") - strSize = h.GetParameterOrDefault(req, "size", "20") - strFrom = h.GetParameterOrDefault(req, "from", "0") - clusterID = h.GetParameter(req, "cluster_id") + keyword = h.GetParameterOrDefault(req, "keyword", "") + strSize = h.GetParameterOrDefault(req, "size", "20") + strFrom = h.GetParameterOrDefault(req, "from", "0") + clusterID = h.GetParameter(req, "cluster_id") ) size, _ := strconv.Atoi(strSize) if size <= 0 { @@ -163,8 +164,8 @@ func (h *InsightAPI) searchDashboard(w http.ResponseWriter, req *http.Request, p if keyword != "" { must = append(must, util.MapStr{ "query_string": util.MapStr{ - "default_field":"*", - "query": keyword, + "default_field": "*", + "query": keyword, }, }) } @@ -199,4 +200,4 @@ func (h *InsightAPI) searchDashboard(w http.ResponseWriter, req *http.Request, p return } h.Write(w, res.Raw) -} \ No newline at end of file +} diff --git a/plugin/api/insight/visualization.go b/plugin/api/insight/visualization.go index 576aaa19..a32512c3 100644 --- a/plugin/api/insight/visualization.go +++ b/plugin/api/insight/visualization.go @@ -6,14 +6,15 @@ package insight import ( "fmt" + "net/http" + "strconv" + "strings" + + log "github.com/cihub/seelog" httprouter "infini.sh/framework/core/api/router" "infini.sh/framework/core/insight" "infini.sh/framework/core/orm" "infini.sh/framework/core/util" - "net/http" - log "src/github.com/cihub/seelog" - "strconv" - "strings" ) func (h *InsightAPI) createVisualization(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { @@ -131,7 +132,7 @@ func (h *InsightAPI) deleteVisualization(w http.ResponseWriter, req *http.Reques func (h *InsightAPI) searchVisualization(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { var ( - keyword = h.GetParameterOrDefault(req, "keyword", "") + keyword = h.GetParameterOrDefault(req, "keyword", "") queryDSL = `{"query":{"bool":{"must":[%s]}}, "size": %d, "from": %d}` strSize = h.GetParameterOrDefault(req, "size", "20") strFrom = h.GetParameterOrDefault(req, "from", "0") @@ -160,4 +161,4 @@ func (h *InsightAPI) searchVisualization(w http.ResponseWriter, req *http.Reques return } h.Write(w, res.Raw) -} \ No newline at end of file +} diff --git a/service/alerting/init.go b/service/alerting/init.go index 6ae4605d..2230a334 100644 --- a/service/alerting/init.go +++ b/service/alerting/init.go @@ -5,12 +5,13 @@ package alerting import ( + "time" + + log "github.com/cihub/seelog" "infini.sh/console/model/alerting" "infini.sh/framework/core/orm" "infini.sh/framework/core/task" "infini.sh/framework/core/util" - log "src/github.com/cihub/seelog" - "time" ) func InitTasks() error { @@ -36,10 +37,10 @@ func InitTasks() error { } eng := GetEngine(rule.Resource.Type) task.RegisterScheduleTask(task.ScheduleTask{ - ID: rule.ID, - Interval: rule.Schedule.Interval, + ID: rule.ID, + Interval: rule.Schedule.Interval, Description: rule.Metrics.Expression, - Task: eng.GenerateTask(*rule), + Task: eng.GenerateTask(*rule), }) task.StartTask(rule.ID) } @@ -68,8 +69,8 @@ func getRuleLastTermTime() (map[string]time.Time, error) { }, } q := &orm.Query{ - RawQuery: util.MustToJSONBytes(query), - Size: 1000, + RawQuery: util.MustToJSONBytes(query), + Size: 1000, WildcardIndex: true, } err, result := orm.Search(alerting.Alert{}, q) @@ -93,5 +94,5 @@ func getRuleLastTermTime() (map[string]time.Time, error) { type ruleTime struct { Created time.Time `json:"created"` - RuleID string `json:"rule_id"` + RuleID string `json:"rule_id"` }