pkg/tsdb: fix ineffassign isues

This commit is contained in:
Mario Trangoni 2018-04-22 20:51:58 +02:00
parent 6b5854936d
commit 556219b192
4 changed files with 10 additions and 4 deletions

View File

@ -271,7 +271,7 @@ func parseQuery(model *simplejson.Json) (*CloudWatchQuery, error) {
}
}
period := 300
var period int
if regexp.MustCompile(`^\d+$`).Match([]byte(p)) {
period, err = strconv.Atoi(p)
if err != nil {

View File

@ -40,6 +40,9 @@ func (qp *InfluxdbQueryParser) Parse(model *simplejson.Json, dsInfo *models.Data
}
parsedInterval, err := tsdb.GetIntervalFrom(dsInfo, model, time.Millisecond*1)
if err != nil {
return nil, err
}
return &Query{
Measurement: measurement,

View File

@ -62,9 +62,8 @@ func (query *Query) renderTags() []string {
}
}
textValue := ""
// quote value unless regex or number
var textValue string
if tag.Operator == "=~" || tag.Operator == "!~" {
textValue = tag.Value
} else if tag.Operator == "<" || tag.Operator == ">" {
@ -107,7 +106,7 @@ func (query *Query) renderSelectors(queryContext *tsdb.TsdbQuery) string {
}
func (query *Query) renderMeasurement() string {
policy := ""
var policy string
if query.Policy == "" || query.Policy == "default" {
policy = ""
} else {

View File

@ -83,6 +83,10 @@ func (e *OpenTsdbExecutor) createRequest(dsInfo *models.DataSource, data OpenTsd
u.Path = path.Join(u.Path, "api/query")
postData, err := json.Marshal(data)
if err != nil {
plog.Info("Failed marshalling data", "error", err)
return nil, fmt.Errorf("Failed to create request. error: %v", err)
}
req, err := http.NewRequest(http.MethodPost, u.String(), strings.NewReader(string(postData)))
if err != nil {