Browse Source

Prefer AWS API interface over actual implementation

This will help introduce mock-based tests

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

+ 14 - 5
ecs/pkg/amazon/client.go

@@ -3,11 +3,18 @@ package amazon
 import (
 	"github.com/aws/aws-sdk-go/aws"
 	"github.com/aws/aws-sdk-go/aws/session"
+	"github.com/aws/aws-sdk-go/service/cloudformation"
+	"github.com/aws/aws-sdk-go/service/cloudformation/cloudformationiface"
 	"github.com/aws/aws-sdk-go/service/cloudwatchlogs"
+	"github.com/aws/aws-sdk-go/service/cloudwatchlogs/cloudwatchlogsiface"
 	"github.com/aws/aws-sdk-go/service/ec2"
+	"github.com/aws/aws-sdk-go/service/ec2/ec2iface"
 	"github.com/aws/aws-sdk-go/service/ecs"
+	"github.com/aws/aws-sdk-go/service/ecs/ecsiface"
 	"github.com/aws/aws-sdk-go/service/elbv2"
+	"github.com/aws/aws-sdk-go/service/elbv2/elbv2iface"
 	"github.com/aws/aws-sdk-go/service/iam"
+	"github.com/aws/aws-sdk-go/service/iam/iamiface"
 	"github.com/docker/ecs-plugin/pkg/compose"
 )
 
@@ -35,6 +42,7 @@ func NewClient(profile string, cluster string, region string) (compose.API, erro
 		ELB: elbv2.New(sess),
 		CW: cloudwatchlogs.New(sess),
 		IAM: iam.New(sess),
+		CF: cloudformation.New(sess),
 	}, nil
 }
 
@@ -42,11 +50,12 @@ type client struct {
 	Cluster string
 	Region string
 	sess *session.Session
-	ECS *ecs.ECS
-	EC2 *ec2.EC2
-	ELB     *elbv2.ELBV2
-	CW *cloudwatchlogs.CloudWatchLogs
-	IAM *iam.IAM
+	ECS ecsiface.ECSAPI
+	EC2 ec2iface.EC2API
+	ELB elbv2iface.ELBV2API
+	CW cloudwatchlogsiface.CloudWatchLogsAPI
+	IAM iamiface.IAMAPI
+	CF cloudformationiface.CloudFormationAPI
 }
 
 var _ compose.API = &client{}

+ 1 - 0
ecs/pkg/amazon/cloudformation.go

@@ -0,0 +1 @@
+package amazon