Sfoglia il codice sorgente

cloudwatch: return a distinct list of regions

Marcus Efraimsson 7 anni fa
parent
commit
52f398e7f7
1 ha cambiato i file con 12 aggiunte e 1 eliminazioni
  1. 12 1
      pkg/tsdb/cloudwatch/metric_find_query.go

+ 12 - 1
pkg/tsdb/cloudwatch/metric_find_query.go

@@ -249,7 +249,18 @@ func (e *CloudWatchExecutor) handleGetRegions(ctx context.Context, parameters *s
 		plog.Error("Failed to get regions", "error", err)
 		plog.Error("Failed to get regions", "error", err)
 	} else {
 	} else {
 		for _, region := range r.Regions {
 		for _, region := range r.Regions {
-			regions = append(regions, *region.RegionName)
+			exists := false
+
+			for _, existingRegion := range regions {
+				if existingRegion == *region.RegionName {
+					exists = true
+					break
+				}
+			}
+
+			if !exists {
+				regions = append(regions, *region.RegionName)
+			}
 		}
 		}
 	}
 	}
 	sort.Strings(regions)
 	sort.Strings(regions)