Skip to content

Commit

Permalink
[AUTOPR] Remove type alias to reduce duplication detection. (#247)
Browse files Browse the repository at this point in the history
* Remove type aliases to avoid duplicate code detection.

---------

Co-authored-by: nicolaasuni-vonage <[email protected]>
  • Loading branch information
github-actions[bot] and nicolaasuni-vonage authored Jun 18, 2024
1 parent 8e23346 commit 0943191
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
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

0 comments on commit 0943191

Please sign in to comment.