Browse Source

Fix recommendations from go-lint

Alberto Llamas 3 years ago
parent
commit
c3335907ac
1 changed files with 13 additions and 19 deletions
  1. 13 19
      pkg/provider/aws/auth/auth.go

+ 13 - 19
pkg/provider/aws/auth/auth.go

@@ -242,11 +242,9 @@ func DefaultSTSProvider(sess *session.Session) stsiface.STSAPI {
 // getAWSSession check if an AWS session should be reused
 // getAWSSession check if an AWS session should be reused
 // it returns the aws session or an error.
 // it returns the aws session or an error.
 func getAWSSession(config *aws.Config, prov *esv1beta1.AWSProvider, store esv1beta1.GenericStore, namespace string) (*session.Session, error) {
 func getAWSSession(config *aws.Config, prov *esv1beta1.AWSProvider, store esv1beta1.GenericStore, namespace string) (*session.Session, error) {
-
 	sessionCache := prov.SessionCache
 	sessionCache := prov.SessionCache
 
 
 	if sessionCache {
 	if sessionCache {
-
 		tmpSession := SessionCache{
 		tmpSession := SessionCache{
 			Name:            store.GetObjectMeta().Name,
 			Name:            store.GetObjectMeta().Name,
 			Namespace:       namespace,
 			Namespace:       namespace,
@@ -258,24 +256,9 @@ func getAWSSession(config *aws.Config, prov *esv1beta1.AWSProvider, store esv1be
 
 
 		if ok {
 		if ok {
 			log.Info("reusing aws session", "SecretStore", tmpSession.Name, "namespace", tmpSession.Namespace, "kind", tmpSession.Kind, "resourceversion", tmpSession.ResourceVersion)
 			log.Info("reusing aws session", "SecretStore", tmpSession.Name, "namespace", tmpSession.Namespace, "kind", tmpSession.Kind, "resourceversion", tmpSession.ResourceVersion)
-			return sessions[tmpSession], nil
-		} else {
-			handlers := defaults.Handlers()
-			handlers.Build.PushBack(request.WithAppendUserAgent("external-secrets"))
-			sess, err := session.NewSessionWithOptions(session.Options{
-				Config:            *config,
-				Handlers:          handlers,
-				SharedConfigState: session.SharedConfigDisable,
-			})
-
-			if err != nil {
-				return nil, err
-			}
-			sessions[tmpSession] = sess
+			sess := sessions[tmpSession]
 			return sess, nil
 			return sess, nil
 		}
 		}
-
-	} else {
 		handlers := defaults.Handlers()
 		handlers := defaults.Handlers()
 		handlers.Build.PushBack(request.WithAppendUserAgent("external-secrets"))
 		handlers.Build.PushBack(request.WithAppendUserAgent("external-secrets"))
 		sess, err := session.NewSessionWithOptions(session.Options{
 		sess, err := session.NewSessionWithOptions(session.Options{
@@ -283,10 +266,21 @@ func getAWSSession(config *aws.Config, prov *esv1beta1.AWSProvider, store esv1be
 			Handlers:          handlers,
 			Handlers:          handlers,
 			SharedConfigState: session.SharedConfigDisable,
 			SharedConfigState: session.SharedConfigDisable,
 		})
 		})
-
 		if err != nil {
 		if err != nil {
 			return nil, err
 			return nil, err
 		}
 		}
+		sessions[tmpSession] = sess
 		return sess, nil
 		return sess, nil
 	}
 	}
+	handlers := defaults.Handlers()
+	handlers.Build.PushBack(request.WithAppendUserAgent("external-secrets"))
+	sess, err := session.NewSessionWithOptions(session.Options{
+		Config:            *config,
+		Handlers:          handlers,
+		SharedConfigState: session.SharedConfigDisable,
+	})
+	if err != nil {
+		return nil, err
+	}
+	return sess, nil
 }
 }