From 923ee9488a98ec4a1bb45c3792e6aa8d45675762 Mon Sep 17 00:00:00 2001 From: Samantha Coyle Date: Wed, 13 Nov 2024 15:03:28 -0600 Subject: [PATCH] style: final tweaks Signed-off-by: Samantha Coyle --- common/authentication/aws/static.go | 4 +++- common/authentication/aws/x509.go | 12 +++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/common/authentication/aws/static.go b/common/authentication/aws/static.go index 8ad052f30f..43081fe57f 100644 --- a/common/authentication/aws/static.go +++ b/common/authentication/aws/static.go @@ -202,9 +202,11 @@ func (a *StaticAuth) Ses() *SesClients { } func (a *StaticAuth) getTokenClient() (*session.Session, error) { - awsConfig := a.Cfg + var awsConfig *aws.Config if a.Cfg == nil { awsConfig = aws.NewConfig() + } else { + awsConfig = a.Cfg } if a.Region != "" { diff --git a/common/authentication/aws/x509.go b/common/authentication/aws/x509.go index 01238b37c1..fbc4dd67e8 100644 --- a/common/authentication/aws/x509.go +++ b/common/authentication/aws/x509.go @@ -345,13 +345,15 @@ func (a *x509) createOrRefreshSession(ctx context.Context) (*session.Session, er }} var mySession *session.Session - awsConfig := a.Cfg - if awsConfig != nil { - awsConfig = a.Cfg.WithRegion(*a.region).WithHTTPClient(client).WithLogLevel(aws.LogOff) + var awsConfig *aws.Config + if a.Cfg == nil { + awsConfig = aws.NewConfig().WithHTTPClient(client).WithLogLevel(aws.LogOff) } else { - awsConfig = aws.NewConfig().WithRegion(*a.region).WithHTTPClient(client).WithLogLevel(aws.LogOff) + awsConfig = a.Cfg.WithHTTPClient(client).WithLogLevel(aws.LogOff) + } + if a.region != nil { + awsConfig.WithRegion(*a.region) } - // this is needed for testing purposes to mock the client, // so code never sets the client, but tests do. var rolesClient *rolesanywhere.RolesAnywhere