Prefer AWS API interface over actual implementation

This will help introduce mock-based tests

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2020-04-20 13:47:38 +02:00
parent dd48cc4599
commit 4e72d1892a
2 changed files with 15 additions and 5 deletions

View File

@ -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{}

View File

@ -0,0 +1 @@
package amazon