From 6f8f12081baf5b7ae3c9ad171b932d4ac78f8fcd Mon Sep 17 00:00:00 2001 From: Ed Smith Date: Thu, 10 Oct 2024 11:54:18 +0100 Subject: [PATCH] feat: create EC2Client interface --- internal/app.go | 5 +++++ internal/internal.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/app.go b/internal/app.go index bac4a48..46ad4aa 100644 --- a/internal/app.go +++ b/internal/app.go @@ -9,11 +9,16 @@ import ( "strings" "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/ec2" "github.com/aws/aws-sdk-go-v2/service/ecs" ecsTypes "github.com/aws/aws-sdk-go-v2/service/ecs/types" "github.com/spf13/viper" ) +type EC2Client interface { + DescribeInstances(ctx context.Context, params *ec2.DescribeInstancesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeInstancesOutput, error) +} + type ECSClient interface { ListClusters(ctx context.Context, params *ecs.ListClustersInput, optFns ...func(*ecs.Options)) (*ecs.ListClustersOutput, error) ListServices(ctx context.Context, params *ecs.ListServicesInput, optFns ...func(*ecs.Options)) (*ecs.ListServicesOutput, error) diff --git a/internal/internal.go b/internal/internal.go index 4017dfc..d12a3ed 100644 --- a/internal/internal.go +++ b/internal/internal.go @@ -115,7 +115,7 @@ func getPlatformFamily(client ECSClient, clusterName string, task *ecsTypes.Task // getContainerInstanceOS describes the specified container instance and checks against the backing EC2 instance // to determine the platform. -func getContainerInstanceOS(ecsClient ECSClient, ec2Client *ec2.Client, cluster string, containerInstanceArn string) (string, error) { +func getContainerInstanceOS(ecsClient ECSClient, ec2Client EC2Client, cluster string, containerInstanceArn string) (string, error) { res, err := ecsClient.DescribeContainerInstances(context.TODO(), &ecs.DescribeContainerInstancesInput{ Cluster: aws.String(cluster), ContainerInstances: []string{