From 674f4f784bd9cf3852cc218b66176b449e7d3d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Roth?= Date: Thu, 1 Aug 2024 21:31:02 +0200 Subject: [PATCH] s3: use new Endpoint API lint: s3/public.go#L136 SA1019: config.WithEndpointResolverWithOptions is deprecated: The global endpoint resolution interface is deprecated. See deprecation docs on [WithEndpointResolver]. (staticcheck) lint: s3/public.go#L137 SA1019: aws.Endpoint is deprecated: This structure was used with the global [EndpointResolver] interface, which has been deprecated in favor of service-specific endpoint resolution. See the deprecation docs on that interface for more information. (staticcheck) lint: s3/public.go#L138 SA1019: aws.Endpoint is deprecated: This structure was used with the global [EndpointResolver] interface, which has been deprecated in favor of service-specific endpoint resolution. See the deprecation docs on that interface for more information. (staticcheck) --- s3/public.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/s3/public.go b/s3/public.go index 1b275417..07cfae2a 100644 --- a/s3/public.go +++ b/s3/public.go @@ -67,7 +67,7 @@ var ( func NewPublishedStorageRaw( bucket, defaultACL, prefix, storageClass, encryptionMethod string, plusWorkaround, disabledMultiDel, forceVirtualHostedStyle bool, - config *aws.Config, + config *aws.Config, endpoint string, ) (*PublishedStorage, error) { var acl types.ObjectCannedACL if defaultACL == "" || defaultACL == "private" { @@ -82,10 +82,16 @@ func NewPublishedStorageRaw( storageClass = "" } + var baseEndpoint *string + if endpoint != "" { + baseEndpoint = aws.String(endpoint) + } + result := &PublishedStorage{ s3: s3.NewFromConfig(*config, func(o *s3.Options) { o.UsePathStyle = !forceVirtualHostedStyle o.HTTPSignerV4 = v4.NewSigner() + o.BaseEndpoint = baseEndpoint }), bucket: bucket, config: config, @@ -132,21 +138,13 @@ func NewPublishedStorage( opts = append(opts, config.WithLogger(&logger{})) } - if endpoint != "" { - opts = append(opts, config.WithEndpointResolverWithOptions(aws.EndpointResolverWithOptionsFunc( - func(_, _ string, _ ...interface{}) (aws.Endpoint, error) { - return aws.Endpoint{URL: endpoint}, nil - }, - ))) - } - config, err := config.LoadDefaultConfig(context.TODO(), opts...) if err != nil { return nil, err } result, err := NewPublishedStorageRaw(bucket, defaultACL, prefix, storageClass, - encryptionMethod, plusWorkaround, disableMultiDel, forceVirtualHostedStyle, &config) + encryptionMethod, plusWorkaround, disableMultiDel, forceVirtualHostedStyle, &config, endpoint) return result, err }