Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AUTOPR] Remove type alias to reduce duplication detection. #247

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions pkg/s3/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ import (

"github.com/Vonage/gosrvlib/pkg/awsopt"
"github.com/aws/aws-sdk-go-v2/aws"
awssrv "github.com/aws/aws-sdk-go-v2/service/s3"
smithyendpoints "github.com/aws/smithy-go/endpoints"
"github.com/aws/aws-sdk-go-v2/service/s3"
sep "github.com/aws/smithy-go/endpoints"
)

// SrvOption is an alias for this service option type.
type SrvOption = awssrv.Options

// SrvOptionFunc is an alias for this service option function.
type SrvOptionFunc = func(*SrvOption)
type SrvOptionFunc = func(*s3.Options)

// Option is a type to allow setting custom client options.
type Option func(*cfg)
Expand All @@ -36,7 +33,7 @@ func WithSrvOptionFuncs(opt ...SrvOptionFunc) Option {
// WithEndpointMutable sets a mutable endpoint.
func WithEndpointMutable(url string) Option {
return WithSrvOptionFuncs(
func(o *SrvOption) {
func(o *s3.Options) {
o.BaseEndpoint = aws.String(url)
},
)
Expand All @@ -45,7 +42,7 @@ func WithEndpointMutable(url string) Option {
// WithEndpointImmutable sets an immutable endpoint.
func WithEndpointImmutable(url string) Option {
return WithSrvOptionFuncs(
func(o *SrvOption) {
func(o *s3.Options) {
o.EndpointResolverV2 = &endpointResolver{url: url}
},
)
Expand All @@ -55,14 +52,14 @@ type endpointResolver struct {
url string
}

func (r *endpointResolver) ResolveEndpoint(_ context.Context, _ awssrv.EndpointParameters) (
smithyendpoints.Endpoint,
func (r *endpointResolver) ResolveEndpoint(_ context.Context, _ s3.EndpointParameters) (
sep.Endpoint,
error,
) {
u, err := url.Parse(r.url)
if err != nil {
return smithyendpoints.Endpoint{}, err //nolint:wrapcheck
return sep.Endpoint{}, err //nolint:wrapcheck
}

return smithyendpoints.Endpoint{URI: *u}, nil
return sep.Endpoint{URI: *u}, nil
}
21 changes: 9 additions & 12 deletions pkg/sqs/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ import (

"github.com/Vonage/gosrvlib/pkg/awsopt"
"github.com/aws/aws-sdk-go-v2/aws"
awssrv "github.com/aws/aws-sdk-go-v2/service/sqs"
smithyendpoints "github.com/aws/smithy-go/endpoints"
"github.com/aws/aws-sdk-go-v2/service/sqs"
sep "github.com/aws/smithy-go/endpoints"
)

// SrvOption is an alias for this service option type.
type SrvOption = awssrv.Options

// SrvOptionFunc is an alias for this service option function.
type SrvOptionFunc = func(*SrvOption)
type SrvOptionFunc = func(*sqs.Options)

// Option is a type to allow setting custom client options.
type Option func(*cfg)
Expand All @@ -36,7 +33,7 @@ func WithSrvOptionFuncs(opt ...SrvOptionFunc) Option {
// WithEndpointMutable sets a mutable endpoint.
func WithEndpointMutable(url string) Option {
return WithSrvOptionFuncs(
func(o *SrvOption) {
func(o *sqs.Options) {
o.BaseEndpoint = aws.String(url)
},
)
Expand All @@ -45,7 +42,7 @@ func WithEndpointMutable(url string) Option {
// WithEndpointImmutable sets an immutable endpoint.
func WithEndpointImmutable(url string) Option {
return WithSrvOptionFuncs(
func(o *SrvOption) {
func(o *sqs.Options) {
o.EndpointResolverV2 = &endpointResolver{url: url}
},
)
Expand All @@ -55,16 +52,16 @@ type endpointResolver struct {
url string
}

func (r *endpointResolver) ResolveEndpoint(_ context.Context, _ awssrv.EndpointParameters) (
smithyendpoints.Endpoint,
func (r *endpointResolver) ResolveEndpoint(_ context.Context, _ sqs.EndpointParameters) (
sep.Endpoint,
error,
) {
u, err := url.Parse(r.url)
if err != nil {
return smithyendpoints.Endpoint{}, err //nolint:wrapcheck
return sep.Endpoint{}, err //nolint:wrapcheck
}

return smithyendpoints.Endpoint{URI: *u}, nil
return sep.Endpoint{URI: *u}, nil
}

// WithWaitTimeSeconds overrides the default duration (in seconds) for which the call waits for a message to arrive in the queue before returning.
Expand Down