mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-12 06:30:35 +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:
+8
-10
@@ -67,7 +67,7 @@ var (
|
|||||||
func NewPublishedStorageRaw(
|
func NewPublishedStorageRaw(
|
||||||
bucket, defaultACL, prefix, storageClass, encryptionMethod string,
|
bucket, defaultACL, prefix, storageClass, encryptionMethod string,
|
||||||
plusWorkaround, disabledMultiDel, forceVirtualHostedStyle bool,
|
plusWorkaround, disabledMultiDel, forceVirtualHostedStyle bool,
|
||||||
config *aws.Config,
|
config *aws.Config, endpoint string,
|
||||||
) (*PublishedStorage, error) {
|
) (*PublishedStorage, error) {
|
||||||
var acl types.ObjectCannedACL
|
var acl types.ObjectCannedACL
|
||||||
if defaultACL == "" || defaultACL == "private" {
|
if defaultACL == "" || defaultACL == "private" {
|
||||||
@@ -82,10 +82,16 @@ func NewPublishedStorageRaw(
|
|||||||
storageClass = ""
|
storageClass = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var baseEndpoint *string
|
||||||
|
if endpoint != "" {
|
||||||
|
baseEndpoint = aws.String(endpoint)
|
||||||
|
}
|
||||||
|
|
||||||
result := &PublishedStorage{
|
result := &PublishedStorage{
|
||||||
s3: s3.NewFromConfig(*config, func(o *s3.Options) {
|
s3: s3.NewFromConfig(*config, func(o *s3.Options) {
|
||||||
o.UsePathStyle = !forceVirtualHostedStyle
|
o.UsePathStyle = !forceVirtualHostedStyle
|
||||||
o.HTTPSignerV4 = v4.NewSigner()
|
o.HTTPSignerV4 = v4.NewSigner()
|
||||||
|
o.BaseEndpoint = baseEndpoint
|
||||||
}),
|
}),
|
||||||
bucket: bucket,
|
bucket: bucket,
|
||||||
config: config,
|
config: config,
|
||||||
@@ -132,21 +138,13 @@ func NewPublishedStorage(
|
|||||||
opts = append(opts, config.WithLogger(&logger{}))
|
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...)
|
config, err := config.LoadDefaultConfig(context.TODO(), opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := NewPublishedStorageRaw(bucket, defaultACL, prefix, storageClass,
|
result, err := NewPublishedStorageRaw(bucket, defaultACL, prefix, storageClass,
|
||||||
encryptionMethod, plusWorkaround, disableMultiDel, forceVirtualHostedStyle, &config)
|
encryptionMethod, plusWorkaround, disableMultiDel, forceVirtualHostedStyle, &config, endpoint)
|
||||||
|
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user