Skip to content

Commit

Permalink
Migrate AWS MemoryDB clients to AWS SDK v2
Browse files Browse the repository at this point in the history
  • Loading branch information
GavinFrazar committed Jan 15, 2025
1 parent 76a9d3d commit 9b43274
Show file tree
Hide file tree
Showing 34 changed files with 385 additions and 314 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/iam v1.38.3
github.com/aws/aws-sdk-go-v2/service/identitystore v1.27.8
github.com/aws/aws-sdk-go-v2/service/kms v1.37.8
github.com/aws/aws-sdk-go-v2/service/memorydb v1.25.2
github.com/aws/aws-sdk-go-v2/service/organizations v1.37.0
github.com/aws/aws-sdk-go-v2/service/rds v1.93.2
github.com/aws/aws-sdk-go-v2/service/redshift v1.53.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,8 @@ github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.7 h1:Hi0KGbrnr57bEH
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.7/go.mod h1:wKNgWgExdjjrm4qvfbTorkvocEstaoDl4WCvGfeCy9c=
github.com/aws/aws-sdk-go-v2/service/kms v1.37.8 h1:KbLZjYqhQ9hyB4HwXiheiflTlYQa0+Fz0Ms/rh5f3mk=
github.com/aws/aws-sdk-go-v2/service/kms v1.37.8/go.mod h1:ANs9kBhK4Ghj9z1W+bsr3WsNaPF71qkgd6eE6Ekol/Y=
github.com/aws/aws-sdk-go-v2/service/memorydb v1.25.2 h1:Tfb2AAJ+GHU/RdBX7BPw6c7jTaL5SuDcCbGItCYOVeU=
github.com/aws/aws-sdk-go-v2/service/memorydb v1.25.2/go.mod h1:IIpB6tUlFZLx7n/cqlfJGAAABXxx0YQ+fR1Aa4m5Czk=
github.com/aws/aws-sdk-go-v2/service/organizations v1.37.0 h1:VlfFFYSLuS7MPNyF7wf1gANoLQLhEj+Kq7ifVzl7gog=
github.com/aws/aws-sdk-go-v2/service/organizations v1.37.0/go.mod h1:5ThtlWQYo2b4sghzFmzDelaJtsW7hOct5MnpbaG8ZeU=
github.com/aws/aws-sdk-go-v2/service/rds v1.93.2 h1:Fv2//DyCH9n6LqEOvpeIFYYRfIhvjhrLk5qhrYMjDGE=
Expand Down
1 change: 1 addition & 0 deletions integrations/event-handler/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.7 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.7 // indirect
github.com/aws/aws-sdk-go-v2/service/kms v1.37.8 // indirect
github.com/aws/aws-sdk-go-v2/service/memorydb v1.25.2 // indirect
github.com/aws/aws-sdk-go-v2/service/organizations v1.37.0 // indirect
github.com/aws/aws-sdk-go-v2/service/rds v1.93.2 // indirect
github.com/aws/aws-sdk-go-v2/service/redshift v1.53.1 // indirect
Expand Down
2 changes: 2 additions & 0 deletions integrations/event-handler/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,8 @@ github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.7 h1:Hi0KGbrnr57bEH
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.7/go.mod h1:wKNgWgExdjjrm4qvfbTorkvocEstaoDl4WCvGfeCy9c=
github.com/aws/aws-sdk-go-v2/service/kms v1.37.8 h1:KbLZjYqhQ9hyB4HwXiheiflTlYQa0+Fz0Ms/rh5f3mk=
github.com/aws/aws-sdk-go-v2/service/kms v1.37.8/go.mod h1:ANs9kBhK4Ghj9z1W+bsr3WsNaPF71qkgd6eE6Ekol/Y=
github.com/aws/aws-sdk-go-v2/service/memorydb v1.25.2 h1:Tfb2AAJ+GHU/RdBX7BPw6c7jTaL5SuDcCbGItCYOVeU=
github.com/aws/aws-sdk-go-v2/service/memorydb v1.25.2/go.mod h1:IIpB6tUlFZLx7n/cqlfJGAAABXxx0YQ+fR1Aa4m5Czk=
github.com/aws/aws-sdk-go-v2/service/organizations v1.37.0 h1:VlfFFYSLuS7MPNyF7wf1gANoLQLhEj+Kq7ifVzl7gog=
github.com/aws/aws-sdk-go-v2/service/organizations v1.37.0/go.mod h1:5ThtlWQYo2b4sghzFmzDelaJtsW7hOct5MnpbaG8ZeU=
github.com/aws/aws-sdk-go-v2/service/rds v1.93.2 h1:Fv2//DyCH9n6LqEOvpeIFYYRfIhvjhrLk5qhrYMjDGE=
Expand Down
1 change: 1 addition & 0 deletions integrations/terraform/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.7 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.7 // indirect
github.com/aws/aws-sdk-go-v2/service/kms v1.37.8 // indirect
github.com/aws/aws-sdk-go-v2/service/memorydb v1.25.2 // indirect
github.com/aws/aws-sdk-go-v2/service/organizations v1.37.0 // indirect
github.com/aws/aws-sdk-go-v2/service/rds v1.93.2 // indirect
github.com/aws/aws-sdk-go-v2/service/redshift v1.53.1 // indirect
Expand Down
2 changes: 2 additions & 0 deletions integrations/terraform/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,8 @@ github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.7 h1:Hi0KGbrnr57bEH
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.7/go.mod h1:wKNgWgExdjjrm4qvfbTorkvocEstaoDl4WCvGfeCy9c=
github.com/aws/aws-sdk-go-v2/service/kms v1.37.8 h1:KbLZjYqhQ9hyB4HwXiheiflTlYQa0+Fz0Ms/rh5f3mk=
github.com/aws/aws-sdk-go-v2/service/kms v1.37.8/go.mod h1:ANs9kBhK4Ghj9z1W+bsr3WsNaPF71qkgd6eE6Ekol/Y=
github.com/aws/aws-sdk-go-v2/service/memorydb v1.25.2 h1:Tfb2AAJ+GHU/RdBX7BPw6c7jTaL5SuDcCbGItCYOVeU=
github.com/aws/aws-sdk-go-v2/service/memorydb v1.25.2/go.mod h1:IIpB6tUlFZLx7n/cqlfJGAAABXxx0YQ+fR1Aa4m5Czk=
github.com/aws/aws-sdk-go-v2/service/organizations v1.37.0 h1:VlfFFYSLuS7MPNyF7wf1gANoLQLhEj+Kq7ifVzl7gog=
github.com/aws/aws-sdk-go-v2/service/organizations v1.37.0/go.mod h1:5ThtlWQYo2b4sghzFmzDelaJtsW7hOct5MnpbaG8ZeU=
github.com/aws/aws-sdk-go-v2/service/rds v1.93.2 h1:Fv2//DyCH9n6LqEOvpeIFYYRfIhvjhrLk5qhrYMjDGE=
Expand Down
6 changes: 3 additions & 3 deletions lib/cloud/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (

"github.com/aws/aws-sdk-go-v2/aws"
ectypes "github.com/aws/aws-sdk-go-v2/service/elasticache/types"
memorydbtypes "github.com/aws/aws-sdk-go-v2/service/memorydb/types"
rdstypes "github.com/aws/aws-sdk-go-v2/service/rds/types"
redshifttypes "github.com/aws/aws-sdk-go-v2/service/redshift/types"
"github.com/aws/aws-sdk-go/service/memorydb"
"github.com/aws/aws-sdk-go/service/opensearchservice"
"github.com/coreos/go-semver/semver"

Expand Down Expand Up @@ -64,7 +64,7 @@ func IsElastiCacheClusterAvailable(cluster *ectypes.ReplicationGroup) bool {
}

// IsMemoryDBClusterAvailable checks if the MemoryDB cluster is available.
func IsMemoryDBClusterAvailable(cluster *memorydb.Cluster) bool {
func IsMemoryDBClusterAvailable(cluster *memorydbtypes.Cluster) bool {
return IsResourceAvailable(cluster, cluster.Status)
}

Expand Down Expand Up @@ -204,7 +204,7 @@ func IsElastiCacheClusterSupported(cluster *ectypes.ReplicationGroup) bool {
}

// IsMemoryDBClusterSupported checks whether the MemoryDB cluster is supported.
func IsMemoryDBClusterSupported(cluster *memorydb.Cluster) bool {
func IsMemoryDBClusterSupported(cluster *memorydbtypes.Cluster) bool {
return aws.ToBool(cluster.TLSEnabled)
}

Expand Down
6 changes: 3 additions & 3 deletions lib/cloud/aws/tags_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
"github.com/aws/aws-sdk-go-v2/aws"
ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
ectypes "github.com/aws/aws-sdk-go-v2/service/elasticache/types"
memorydbtypes "github.com/aws/aws-sdk-go-v2/service/memorydb/types"
rdstypes "github.com/aws/aws-sdk-go-v2/service/rds/types"
redshifttypes "github.com/aws/aws-sdk-go-v2/service/redshift/types"
rsstypes "github.com/aws/aws-sdk-go-v2/service/redshiftserverless/types"
"github.com/aws/aws-sdk-go/service/memorydb"
"github.com/aws/aws-sdk-go/service/opensearchservice"
"github.com/aws/aws-sdk-go/service/secretsmanager"

Expand All @@ -43,7 +43,7 @@ type ResourceTag interface {
ec2types.Tag |
redshifttypes.Tag |
ectypes.Tag |
*memorydb.Tag |
memorydbtypes.Tag |
rsstypes.Tag |
*opensearchservice.Tag |
*secretsmanager.Tag
Expand Down Expand Up @@ -72,7 +72,7 @@ func resourceTagToKeyValue[Tag ResourceTag](tag Tag) (string, string) {
switch v := any(tag).(type) {
case ectypes.Tag:
return aws.ToString(v.Key), aws.ToString(v.Value)
case *memorydb.Tag:
case memorydbtypes.Tag:
return aws.ToString(v.Key), aws.ToString(v.Value)
case rsstypes.Tag:
return aws.ToString(v.Key), aws.ToString(v.Value)
Expand Down
8 changes: 8 additions & 0 deletions lib/cloud/awstesthelpers/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"slices"

ectypes "github.com/aws/aws-sdk-go-v2/service/elasticache/types"
memorydbtypes "github.com/aws/aws-sdk-go-v2/service/memorydb/types"
rdstypes "github.com/aws/aws-sdk-go-v2/service/rds/types"
redshifttypes "github.com/aws/aws-sdk-go-v2/service/redshift/types"
rsstypes "github.com/aws/aws-sdk-go-v2/service/redshiftserverless/types"
Expand Down Expand Up @@ -67,3 +68,10 @@ func LabelsToElastiCacheTags(labels map[string]string) []ectypes.Tag {
return ectypes.Tag{Key: &key, Value: &value}
})
}

// LabelsToMemoryDBTags converts labels into a [memorydbtypes.Tag] list.
func LabelsToMemoryDBTags(labels map[string]string) []memorydbtypes.Tag {
return LabelsToTags(labels, func(key, value string) memorydbtypes.Tag {
return memorydbtypes.Tag{Key: &key, Value: &value}
})
}
23 changes: 0 additions & 23 deletions lib/cloud/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ import (
"github.com/aws/aws-sdk-go/service/iam/iamiface"
"github.com/aws/aws-sdk-go/service/kms"
"github.com/aws/aws-sdk-go/service/kms/kmsiface"
"github.com/aws/aws-sdk-go/service/memorydb"
"github.com/aws/aws-sdk-go/service/memorydb/memorydbiface"
"github.com/aws/aws-sdk-go/service/opensearchservice"
"github.com/aws/aws-sdk-go/service/opensearchservice/opensearchserviceiface"
"github.com/aws/aws-sdk-go/service/s3"
Expand Down Expand Up @@ -103,8 +101,6 @@ type GCPClients interface {
type AWSClients interface {
// GetAWSSession returns AWS session for the specified region and any role(s).
GetAWSSession(ctx context.Context, region string, opts ...AWSOptionsFn) (*awssession.Session, error)
// GetAWSMemoryDBClient returns AWS MemoryDB client for the specified region.
GetAWSMemoryDBClient(ctx context.Context, region string, opts ...AWSOptionsFn) (memorydbiface.MemoryDBAPI, error)
// GetAWSOpenSearchClient returns AWS OpenSearch client for the specified region.
GetAWSOpenSearchClient(ctx context.Context, region string, opts ...AWSOptionsFn) (opensearchserviceiface.OpenSearchServiceAPI, error)
// GetAWSSecretsManagerClient returns AWS Secrets Manager client for the specified region.
Expand Down Expand Up @@ -501,15 +497,6 @@ func (c *cloudClients) GetAWSOpenSearchClient(ctx context.Context, region string
return opensearchservice.New(session), nil
}

// GetAWSMemoryDBClient returns AWS MemoryDB client for the specified region.
func (c *cloudClients) GetAWSMemoryDBClient(ctx context.Context, region string, opts ...AWSOptionsFn) (memorydbiface.MemoryDBAPI, error) {
session, err := c.GetAWSSession(ctx, region, opts...)
if err != nil {
return nil, trace.Wrap(err)
}
return memorydb.New(session), nil
}

// GetAWSSecretsManagerClient returns AWS Secrets Manager client for the specified region.
func (c *cloudClients) GetAWSSecretsManagerClient(ctx context.Context, region string, opts ...AWSOptionsFn) (secretsmanageriface.SecretsManagerAPI, error) {
session, err := c.GetAWSSession(ctx, region, opts...)
Expand Down Expand Up @@ -981,7 +968,6 @@ var _ Clients = (*TestCloudClients)(nil)
// TestCloudClients are used in tests.
type TestCloudClients struct {
OpenSearch opensearchserviceiface.OpenSearchServiceAPI
MemoryDB memorydbiface.MemoryDBAPI
SecretsManager secretsmanageriface.SecretsManagerAPI
IAM iamiface.IAMAPI
STS stsiface.STSAPI
Expand Down Expand Up @@ -1057,15 +1043,6 @@ func (c *TestCloudClients) GetAWSOpenSearchClient(ctx context.Context, region st
return c.OpenSearch, nil
}

// GetAWSMemoryDBClient returns AWS MemoryDB client for the specified region.
func (c *TestCloudClients) GetAWSMemoryDBClient(ctx context.Context, region string, opts ...AWSOptionsFn) (memorydbiface.MemoryDBAPI, error) {
_, err := c.GetAWSSession(ctx, region, opts...)
if err != nil {
return nil, trace.Wrap(err)
}
return c.MemoryDB, nil
}

// GetAWSSecretsManagerClient returns AWS Secrets Manager client for the specified region.
func (c *TestCloudClients) GetAWSSecretsManagerClient(ctx context.Context, region string, opts ...AWSOptionsFn) (secretsmanageriface.SecretsManagerAPI, error) {
_, err := c.GetAWSSession(ctx, region, opts...)
Expand Down
78 changes: 41 additions & 37 deletions lib/cloud/mocks/aws_memorydb.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,78 +19,76 @@
package mocks

import (
"context"
"fmt"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/memorydb"
"github.com/aws/aws-sdk-go/service/memorydb/memorydbiface"
"github.com/aws/aws-sdk-go-v2/aws"
memorydb "github.com/aws/aws-sdk-go-v2/service/memorydb"
memorydbtypes "github.com/aws/aws-sdk-go-v2/service/memorydb/types"
"github.com/gravitational/trace"
)

// MemoryDBMock mocks AWS MemoryDB API.
type MemoryDBMock struct {
memorydbiface.MemoryDBAPI

// MemoryDBClient mocks AWS MemoryDB API.
type MemoryDBClient struct {
Unauth bool
Clusters []*memorydb.Cluster
Users []*memorydb.User
TagsByARN map[string][]*memorydb.Tag
Clusters []memorydbtypes.Cluster
Users []memorydbtypes.User
TagsByARN map[string][]memorydbtypes.Tag
}

func (m *MemoryDBMock) AddMockUser(user *memorydb.User, tagsMap map[string]string) {
func (m *MemoryDBClient) AddMockUser(user memorydbtypes.User, tagsMap map[string]string) {
m.Users = append(m.Users, user)
m.addTags(aws.StringValue(user.ARN), tagsMap)
m.addTags(aws.ToString(user.ARN), tagsMap)
}

func (m *MemoryDBMock) addTags(arn string, tagsMap map[string]string) {
func (m *MemoryDBClient) addTags(arn string, tagsMap map[string]string) {
if m.TagsByARN == nil {
m.TagsByARN = make(map[string][]*memorydb.Tag)
m.TagsByARN = make(map[string][]memorydbtypes.Tag)
}

var tags []*memorydb.Tag
var tags []memorydbtypes.Tag
for key, value := range tagsMap {
tags = append(tags, &memorydb.Tag{
tags = append(tags, memorydbtypes.Tag{
Key: aws.String(key),
Value: aws.String(value),
})
}
m.TagsByARN[arn] = tags
}

func (m *MemoryDBMock) DescribeSubnetGroupsWithContext(aws.Context, *memorydb.DescribeSubnetGroupsInput, ...request.Option) (*memorydb.DescribeSubnetGroupsOutput, error) {
func (m *MemoryDBClient) DescribeSubnetGroups(context.Context, *memorydb.DescribeSubnetGroupsInput, ...func(*memorydb.Options)) (*memorydb.DescribeSubnetGroupsOutput, error) {
return nil, trace.AccessDenied("unauthorized")
}

func (m *MemoryDBMock) DescribeClustersWithContext(_ aws.Context, input *memorydb.DescribeClustersInput, _ ...request.Option) (*memorydb.DescribeClustersOutput, error) {
func (m *MemoryDBClient) DescribeClusters(_ context.Context, input *memorydb.DescribeClustersInput, _ ...func(*memorydb.Options)) (*memorydb.DescribeClustersOutput, error) {
if m.Unauth {
return nil, trace.AccessDenied("unauthorized")
}
if aws.StringValue(input.ClusterName) == "" {
if aws.ToString(input.ClusterName) == "" {
return &memorydb.DescribeClustersOutput{
Clusters: m.Clusters,
}, nil
}

for _, cluster := range m.Clusters {
if aws.StringValue(input.ClusterName) == aws.StringValue(cluster.Name) {
if aws.ToString(input.ClusterName) == aws.ToString(cluster.Name) {
return &memorydb.DescribeClustersOutput{
Clusters: []*memorydb.Cluster{cluster},
Clusters: []memorydbtypes.Cluster{cluster},
}, nil
}
}
return nil, trace.NotFound("cluster %v not found", aws.StringValue(input.ClusterName))
return nil, trace.NotFound("MemoryDB cluster %q not found", aws.ToString(input.ClusterName))
}

func (m *MemoryDBMock) ListTagsWithContext(_ aws.Context, input *memorydb.ListTagsInput, _ ...request.Option) (*memorydb.ListTagsOutput, error) {
func (m *MemoryDBClient) ListTags(_ context.Context, input *memorydb.ListTagsInput, _ ...func(*memorydb.Options)) (*memorydb.ListTagsOutput, error) {
if m.Unauth {
return nil, trace.AccessDenied("unauthorized")
}
if m.TagsByARN == nil {
return nil, trace.NotFound("no tags")
}

tags, ok := m.TagsByARN[aws.StringValue(input.ResourceArn)]
tags, ok := m.TagsByARN[aws.ToString(input.ResourceArn)]
if !ok {
return nil, trace.NotFound("no tags")
}
Expand All @@ -100,37 +98,43 @@ func (m *MemoryDBMock) ListTagsWithContext(_ aws.Context, input *memorydb.ListTa
}, nil
}

func (m *MemoryDBMock) DescribeUsersWithContext(aws.Context, *memorydb.DescribeUsersInput, ...request.Option) (*memorydb.DescribeUsersOutput, error) {
func (m *MemoryDBClient) DescribeUsers(_ context.Context, input *memorydb.DescribeUsersInput, _ ...func(*memorydb.Options)) (*memorydb.DescribeUsersOutput, error) {
if m.Unauth {
return nil, trace.AccessDenied("unauthorized")
}
return &memorydb.DescribeUsersOutput{
Users: m.Users,
}, nil
if aws.ToString(input.UserName) == "" {
return &memorydb.DescribeUsersOutput{Users: m.Users}, nil
}
for _, u := range m.Users {
if aws.ToString(u.Name) == aws.ToString(input.UserName) {
return &memorydb.DescribeUsersOutput{Users: []memorydbtypes.User{u}}, nil
}
}
return nil, trace.NotFound("MemoryDB UserName %q not found", aws.ToString(input.UserName))
}

func (m *MemoryDBMock) UpdateUserWithContext(_ aws.Context, input *memorydb.UpdateUserInput, opts ...request.Option) (*memorydb.UpdateUserOutput, error) {
func (m *MemoryDBClient) UpdateUser(_ context.Context, input *memorydb.UpdateUserInput, opts ...func(*memorydb.Options)) (*memorydb.UpdateUserOutput, error) {
if m.Unauth {
return nil, trace.AccessDenied("unauthorized")
}
for _, user := range m.Users {
if aws.StringValue(user.Name) == aws.StringValue(input.UserName) {
if aws.ToString(user.Name) == aws.ToString(input.UserName) {
return &memorydb.UpdateUserOutput{}, nil
}
}
return nil, trace.NotFound("user %s not found", aws.StringValue(input.UserName))
return nil, trace.NotFound("MemoryDB user %q not found", aws.ToString(input.UserName))
}

// MemoryDBCluster returns a sample memorydb.Cluster.
func MemoryDBCluster(name, region string, opts ...func(*memorydb.Cluster)) *memorydb.Cluster {
cluster := &memorydb.Cluster{
// MemoryDBCluster returns a sample memorydbtypes.Cluster.
func MemoryDBCluster(name, region string, opts ...func(*memorydbtypes.Cluster)) *memorydbtypes.Cluster {
cluster := &memorydbtypes.Cluster{
ARN: aws.String(fmt.Sprintf("arn:aws:memorydb:%s:123456789012:cluster:%s", region, name)),
Name: aws.String(name),
Status: aws.String("available"),
TLSEnabled: aws.Bool(true),
ClusterEndpoint: &memorydb.Endpoint{
ClusterEndpoint: &memorydbtypes.Endpoint{
Address: aws.String(fmt.Sprintf("clustercfg.%s.xxxxxx.memorydb.%s.amazonaws.com", name, region)),
Port: aws.Int64(6379),
Port: 6379,
},
}

Expand Down
6 changes: 0 additions & 6 deletions lib/srv/db/access_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2439,8 +2439,6 @@ type agentParams struct {
NoStart bool
// GCPSQL defines the GCP Cloud SQL mock to use for GCP API calls.
GCPSQL *mocks.GCPSQLAdminClientMock
// MemoryDB defines the AWS MemoryDB mock to use for MemoryDB API calls.
MemoryDB *mocks.MemoryDBMock
// OnHeartbeat defines a heartbeat function that generates heartbeat events.
OnHeartbeat func(error)
// CADownloader defines the CA downloader.
Expand Down Expand Up @@ -2477,9 +2475,6 @@ func (p *agentParams) setDefaults(c *testContext) {
},
}
}
if p.MemoryDB == nil {
p.MemoryDB = &mocks.MemoryDBMock{}
}
if p.CADownloader == nil {
p.CADownloader = &fakeDownloader{
cert: []byte(fixtures.TLSCACertPEM),
Expand All @@ -2489,7 +2484,6 @@ func (p *agentParams) setDefaults(c *testContext) {
if p.CloudClients == nil {
p.CloudClients = &clients.TestCloudClients{
STS: &mocks.STSClientV1{},
MemoryDB: p.MemoryDB,
SecretsManager: secrets.NewMockSecretsManagerClient(secrets.MockSecretsManagerClientConfig{}),
IAM: &mocks.IAMMock{},
GCPSQL: p.GCPSQL,
Expand Down
Loading

0 comments on commit 9b43274

Please sign in to comment.