Prometheus: Use default POST method if no httpMethod provided (#38446)

* Prometheus: If no httpMethod, use default POST method

* Use http.MethodPost
This commit is contained in:
Ivana Huckova 2021-08-23 09:25:40 -04:00 committed by GitHub
parent 49fdab7e43
commit 74fef637af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"net/http"
"regexp"
"strings"
"time"
@ -70,6 +71,7 @@ func (s *Service) Init() error {
func newInstanceSettings() datasource.InstanceFactoryFunc {
return func(settings backend.DataSourceInstanceSettings) (instancemgmt.Instance, error) {
defaultHttpMethod := http.MethodPost
jsonData := map[string]interface{}{}
err := json.Unmarshal(settings.JSONData, &jsonData)
if err != nil {
@ -82,7 +84,7 @@ func newInstanceSettings() datasource.InstanceFactoryFunc {
httpMethod, ok := jsonData["httpMethod"].(string)
if !ok {
return nil, errors.New("no http method provided")
httpMethod = defaultHttpMethod
}
// timeInterval can be a string or can be missing.