Commit 4051f04e by Torkel Ödegaard

Merge pull request #3202 from mtanda/cloudwatch_sort

sort CloudWatch suggestion region and namspace
parents 0fb110a4 02a37d67
...@@ -2,6 +2,7 @@ package cloudwatch ...@@ -2,6 +2,7 @@ package cloudwatch
import ( import (
"encoding/json" "encoding/json"
"sort"
"github.com/grafana/grafana/pkg/middleware" "github.com/grafana/grafana/pkg/middleware"
"github.com/grafana/grafana/pkg/util" "github.com/grafana/grafana/pkg/util"
...@@ -69,8 +70,8 @@ func init() { ...@@ -69,8 +70,8 @@ func init() {
// Please update the region list in public/app/plugins/datasource/cloudwatch/partials/config.html // Please update the region list in public/app/plugins/datasource/cloudwatch/partials/config.html
func handleGetRegions(req *cwRequest, c *middleware.Context) { func handleGetRegions(req *cwRequest, c *middleware.Context) {
regions := []string{ regions := []string{
"us-east-1", "us-west-2", "us-west-1", "eu-west-1", "eu-central-1", "ap-southeast-1", "ap-northeast-1", "ap-southeast-1", "ap-southeast-2", "cn-north-1",
"ap-southeast-2", "ap-northeast-1", "sa-east-1", "cn-north-1", "eu-central-1", "eu-west-1", "sa-east-1", "us-east-1", "us-west-1", "us-west-2",
} }
result := []interface{}{} result := []interface{}{}
...@@ -82,8 +83,14 @@ func handleGetRegions(req *cwRequest, c *middleware.Context) { ...@@ -82,8 +83,14 @@ func handleGetRegions(req *cwRequest, c *middleware.Context) {
} }
func handleGetNamespaces(req *cwRequest, c *middleware.Context) { func handleGetNamespaces(req *cwRequest, c *middleware.Context) {
result := []interface{}{} keys := []string{}
for key := range metricsMap { for key := range metricsMap {
keys = append(keys, key)
}
sort.Sort(sort.StringSlice(keys))
result := []interface{}{}
for _, key := range keys {
result = append(result, util.DynMap{"text": key, "value": key}) result = append(result, util.DynMap{"text": key, "value": key})
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment