Browse Source

Use DescribeCluster as ListCluster is a Paginated API

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De Loof 5 năm trước cách đây
mục cha
commit
f8bf0078aa
1 tập tin đã thay đổi với 5 bổ sung8 xóa
  1. 5 8
      ecs/pkg/amazon/ecs.go

+ 5 - 8
ecs/pkg/amazon/ecs.go

@@ -2,8 +2,7 @@ package amazon
 
 import (
 	"errors"
-	"strings"
-
+	"github.com/aws/aws-sdk-go/aws"
 	"github.com/aws/aws-sdk-go/service/ecs"
 	"github.com/sirupsen/logrus"
 )
@@ -40,13 +39,11 @@ func (c client) DeleteCluster() error {
 
 func (c client) ClusterExists() (bool, error) {
 	logrus.Debug("Check if cluster was already created: ", c.Cluster)
-	clusters, err := c.ECS.ListClusters(nil)
+	clusters, err := c.ECS.DescribeClusters(&ecs.DescribeClustersInput{
+		Clusters: []*string{aws.String(c.Cluster)},
+	})
 	if err != nil {
 		return false, err
 	}
-	found := false
-	for _, arn := range clusters.ClusterArns {
-		found = found || strings.HasSuffix(*arn, "/"+c.Cluster)
-	}
-	return found, nil
+	return len(clusters.Clusters) > 0, nil
 }