From 5990156dfc9b803c3f9bc6360371cd1b70f6a163 Mon Sep 17 00:00:00 2001 From: Jason Del Ponte <961963+jasdel@users.noreply.github.com> Date: Fri, 10 Sep 2021 12:37:32 -0700 Subject: [PATCH] Fixup golint for s3 signer --- .../internal/customizations/process_arn_resource.go | 8 ++++---- .../s3/internal/customizations/signer_wrapper.go | 13 +++++++------ service/s3/internal/v4a/credentials.go | 2 ++ service/s3/internal/v4a/middleware.go | 6 +++--- service/s3/internal/v4a/v4a_test.go | 4 ++-- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/service/s3/internal/customizations/process_arn_resource.go b/service/s3/internal/customizations/process_arn_resource.go index 5fc9cb3032e..f210032d702 100644 --- a/service/s3/internal/customizations/process_arn_resource.go +++ b/service/s3/internal/customizations/process_arn_resource.go @@ -413,8 +413,8 @@ func buildS3ObjectLambdaAccessPointRequest(ctx context.Context, options accesspo } func buildMultiRegionAccessPointsRequest(ctx context.Context, options accesspointOptions) (context.Context, error) { - const s3_global_label = "s3-global." - const accesspoint_label = "accesspoint." + const s3GlobalLabel = "s3-global." + const accesspointLabel = "accesspoint." tv := options.resource req := options.request @@ -456,7 +456,7 @@ func buildMultiRegionAccessPointsRequest(ctx context.Context, options accesspoin return ctx, fmt.Errorf("Error determining dns suffix from arn partition, %w", err) } // set url as per partition - endpoint.URL = scheme[0] + "://" + s3_global_label + dnsSuffix + endpoint.URL = scheme[0] + "://" + s3GlobalLabel + dnsSuffix // assign resolved endpoint url to request url req.URL, err = url.Parse(endpoint.URL) @@ -465,7 +465,7 @@ func buildMultiRegionAccessPointsRequest(ctx context.Context, options accesspoin } // build access point host prefix - accessPointHostPrefix := tv.AccessPointName + "." + accesspoint_label + accessPointHostPrefix := tv.AccessPointName + "." + accesspointLabel // add host prefix to url req.URL.Host = accessPointHostPrefix + req.URL.Host diff --git a/service/s3/internal/customizations/signer_wrapper.go b/service/s3/internal/customizations/signer_wrapper.go index 8044e8c11f1..40d668264c6 100644 --- a/service/s3/internal/customizations/signer_wrapper.go +++ b/service/s3/internal/customizations/signer_wrapper.go @@ -3,6 +3,7 @@ package customizations import ( "context" "fmt" + "github.com/aws/aws-sdk-go-v2/aws" v4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" "github.com/aws/aws-sdk-go-v2/service/s3/internal/v4a" @@ -110,10 +111,10 @@ func (s *SignHTTPRequestMiddleware) HandleFinalize(ctx context.Context, in middl // present, this provided middleware will be swapped. Otherwise the middleware will be added at the tail of the // finalize step. func RegisterSigningMiddleware(stack *middleware.Stack, signingMiddleware *SignHTTPRequestMiddleware) (err error) { - const signingId = "Signing" - _, present := stack.Finalize.Get(signingId) + const signedID = "Signing" + _, present := stack.Finalize.Get(signedID) if present { - _, err = stack.Finalize.Swap(signingId, signingMiddleware) + _, err = stack.Finalize.Swap(signedID, signingMiddleware) } else { err = stack.Finalize.Add(signingMiddleware, middleware.After) } @@ -201,10 +202,10 @@ func (p *PresignHTTPRequestMiddleware) HandleFinalize( // present, this provided middleware will be swapped. Otherwise the middleware will be added at the tail of the // finalize step. func RegisterPreSigningMiddleware(stack *middleware.Stack, signingMiddleware *PresignHTTPRequestMiddleware) (err error) { - const signingId = "PresignHTTPRequest" - _, present := stack.Finalize.Get(signingId) + const signedID = "PresignHTTPRequest" + _, present := stack.Finalize.Get(signedID) if present { - _, err = stack.Finalize.Swap(signingId, signingMiddleware) + _, err = stack.Finalize.Swap(signedID, signingMiddleware) } else { err = stack.Finalize.Add(signingMiddleware, middleware.After) } diff --git a/service/s3/internal/v4a/credentials.go b/service/s3/internal/v4a/credentials.go index ac92b64f6cb..856dcd62d4e 100644 --- a/service/s3/internal/v4a/credentials.go +++ b/service/s3/internal/v4a/credentials.go @@ -134,6 +134,8 @@ func (s *SymmetricCredentialAdaptor) retrieveFromSymmetricProvider(ctx context.C return credentials, nil } +// CredentialsProvider is the interface for a provider to retrieve credentials +// to sign requests with. type CredentialsProvider interface { RetrievePrivateKey(context.Context) (Credentials, error) } diff --git a/service/s3/internal/v4a/middleware.go b/service/s3/internal/v4a/middleware.go index c885cabe0fe..55d5e8abd6d 100644 --- a/service/s3/internal/v4a/middleware.go +++ b/service/s3/internal/v4a/middleware.go @@ -94,10 +94,10 @@ func hasCredentialProvider(p CredentialsProvider) bool { // present, this provided middleware will be swapped. Otherwise the middleware will be added at the tail of the // finalize step. func RegisterSigningMiddleware(stack *middleware.Stack, signingMiddleware *SignHTTPRequestMiddleware) (err error) { - const signingId = "Signing" - _, present := stack.Finalize.Get(signingId) + const signedID = "Signing" + _, present := stack.Finalize.Get(signedID) if present { - _, err = stack.Finalize.Swap(signingId, signingMiddleware) + _, err = stack.Finalize.Swap(signedID, signingMiddleware) } else { err = stack.Finalize.Add(signingMiddleware, middleware.After) } diff --git a/service/s3/internal/v4a/v4a_test.go b/service/s3/internal/v4a/v4a_test.go index 1293f400514..03bad1f6bc2 100644 --- a/service/s3/internal/v4a/v4a_test.go +++ b/service/s3/internal/v4a/v4a_test.go @@ -122,7 +122,7 @@ func TestPresignHTTP(t *testing.T) { query.Set("X-Amz-Expires", "18000") req.URL.RawQuery = query.Encode() - signedUrl, _, err := signer.PresignHTTP(context.Background(), key, req, EmptyStringSHA256, "dynamodb", []string{"us-east-1"}, time.Unix(0, 0)) + signedURL, _, err := signer.PresignHTTP(context.Background(), key, req, EmptyStringSHA256, "dynamodb", []string{"us-east-1"}, time.Unix(0, 0)) if err != nil { t.Fatalf("expected no error, got %v", err) } @@ -134,7 +134,7 @@ func TestPresignHTTP(t *testing.T) { expectedStrToSignHash := "d7ffbd2fab644384c056957e6ac38de4ae68246764b5f5df171b3824153b6397" expectedTarget := "prefix.Operation" - signedReq, err := url.Parse(signedUrl) + signedReq, err := url.Parse(signedURL) if err != nil { t.Fatalf("expected no error, got %v", err) }