Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

Cloudfront implementation #40

Merged
merged 12 commits into from
May 5, 2021
1 change: 1 addition & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ var allRegions = []string{

type Services struct {
Autoscaling AutoscalingClient
Cloudfront CloudfrontClient
Cloudtrail CloudtrailClient
Cloudwatch CloudwatchClient
CloudwatchLogs CloudwatchLogsClient
Expand Down
42 changes: 23 additions & 19 deletions client/mocks/builders_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package mocks_test

import (
"github.com/aws/aws-sdk-go-v2/service/cloudfront"
cloudfrontTypes "github.com/aws/aws-sdk-go-v2/service/cloudfront/types"
"testing"

"github.com/aws/aws-sdk-go-v2/service/autoscaling"
Expand Down Expand Up @@ -28,8 +30,6 @@ import (
elbv2Types "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/types"
"github.com/aws/aws-sdk-go-v2/service/emr"
emrTypes "github.com/aws/aws-sdk-go-v2/service/emr/types"
"github.com/aws/aws-sdk-go-v2/service/fsx"
fsxTypes "github.com/aws/aws-sdk-go-v2/service/fsx/types"
"github.com/aws/aws-sdk-go-v2/service/iam"
iamTypes "github.com/aws/aws-sdk-go-v2/service/iam/types"
"github.com/aws/aws-sdk-go-v2/service/kms"
Expand Down Expand Up @@ -88,6 +88,27 @@ func buildEcsClusterMock(t *testing.T, ctrl *gomock.Controller) client.Services
return services
}

func buildCloudfrontDistributionsMock(t *testing.T, ctrl *gomock.Controller) client.Services {
m := mocks.NewMockCloudfrontClient(ctrl)
services := client.Services{
Cloudfront: m,
}
ds := cloudfrontTypes.DistributionSummary{}
if err := faker.FakeData(&ds); err != nil {
t.Fatal(err)
}
cloudfrontOutput := &cloudfront.ListDistributionsOutput{
DistributionList: &cloudfrontTypes.DistributionList{
Items: []cloudfrontTypes.DistributionSummary{ds},
},
}
m.EXPECT().ListDistributions(gomock.Any(), gomock.Any(), gomock.Any()).Return(
cloudfrontOutput,
nil,
)
return services
}

func buildCloudtrailTrailsMock(t *testing.T, ctrl *gomock.Controller) client.Services {
m := mocks.NewMockCloudtrailClient(ctrl)
services := client.Services{
Expand Down Expand Up @@ -674,23 +695,6 @@ func buildEksClusters(t *testing.T, ctrl *gomock.Controller) client.Services {
}
}

func buildFsxBackups(t *testing.T, ctrl *gomock.Controller) client.Services {
m := mocks.NewMockFsxClient(ctrl)
l := fsxTypes.Backup{}
err := faker.FakeData(&l)
if err != nil {
t.Fatal(err)
}

m.EXPECT().DescribeBackups(gomock.Any(), gomock.Any(), gomock.Any()).Return(
&fsx.DescribeBackupsOutput{
Backups: []fsxTypes.Backup{l},
}, nil)
return client.Services{
FSX: m,
}
}

func buildSnsTopics(t *testing.T, ctrl *gomock.Controller) client.Services {
m := mocks.NewMockSnsClient(ctrl)
topic := snsTypes.Topic{}
Expand Down
Loading