From a7deca1df54282b64d0f97434861c12db2ae8ccc Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Wed, 11 Nov 2015 14:06:47 +0900 Subject: [PATCH 1/2] sort regions by alphabetical order --- pkg/api/cloudwatch/metrics.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/api/cloudwatch/metrics.go b/pkg/api/cloudwatch/metrics.go index 1357fccb127..4dbc86c420d 100644 --- a/pkg/api/cloudwatch/metrics.go +++ b/pkg/api/cloudwatch/metrics.go @@ -69,8 +69,8 @@ func init() { // Please update the region list in public/app/plugins/datasource/cloudwatch/partials/config.html func handleGetRegions(req *cwRequest, c *middleware.Context) { regions := []string{ - "us-east-1", "us-west-2", "us-west-1", "eu-west-1", "eu-central-1", "ap-southeast-1", - "ap-southeast-2", "ap-northeast-1", "sa-east-1", "cn-north-1", + "ap-northeast-1", "ap-southeast-1", "ap-southeast-2", "cn-north-1", + "eu-central-1", "eu-west-1", "sa-east-1", "us-east-1", "us-west-1", "us-west-2", } result := []interface{}{} From 02a37d670cd234b537ef3c46ac0c28f968fbd1b2 Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Wed, 11 Nov 2015 14:15:20 +0900 Subject: [PATCH 2/2] sort namespaces by alphabetical order --- pkg/api/cloudwatch/metrics.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/api/cloudwatch/metrics.go b/pkg/api/cloudwatch/metrics.go index 4dbc86c420d..813dc9d0b89 100644 --- a/pkg/api/cloudwatch/metrics.go +++ b/pkg/api/cloudwatch/metrics.go @@ -2,6 +2,7 @@ package cloudwatch import ( "encoding/json" + "sort" "github.com/grafana/grafana/pkg/middleware" "github.com/grafana/grafana/pkg/util" @@ -82,8 +83,14 @@ func handleGetRegions(req *cwRequest, c *middleware.Context) { } func handleGetNamespaces(req *cwRequest, c *middleware.Context) { - result := []interface{}{} + keys := []string{} 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}) }