mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-01-11 03:11:50 +00:00
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)
This commit is contained in:
18
s3/public.go
18
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user