Skip to content

Commit 613f9c9

Browse files
authored
Fix EndpointResolverWithOptionsFunc Bug (#1501)
1 parent fafd921 commit 613f9c9

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"id": "ee24d721-edd9-4d88-826e-ac19451093c6",
3+
"type": "bugfix",
4+
"description": "Fixed a bug that prevented aws.EndpointResolverWithOptionsFunc from satisfying the aws.EndpointResolverWithOptions interface.",
5+
"modules": [
6+
"."
7+
]
8+
}

aws/endpoints.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,11 @@ type EndpointResolverWithOptions interface {
183183
}
184184

185185
// EndpointResolverWithOptionsFunc wraps a function to satisfy the EndpointResolverWithOptions interface.
186-
type EndpointResolverWithOptionsFunc func(service, region string, options interface{}) (Endpoint, error)
186+
type EndpointResolverWithOptionsFunc func(service, region string, options ...interface{}) (Endpoint, error)
187187

188188
// ResolveEndpoint calls the wrapped function and returns the results.
189-
func (e EndpointResolverWithOptionsFunc) ResolveEndpoint(service, region string, options interface{}) (Endpoint, error) {
190-
return e(service, region, options)
189+
func (e EndpointResolverWithOptionsFunc) ResolveEndpoint(service, region string, options ...interface{}) (Endpoint, error) {
190+
return e(service, region, options...)
191191
}
192192

193193
// GetDisableHTTPS takes a service's EndpointResolverOptions and returns the DisableHTTPS value.

aws/endpoints_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,31 @@ func TestGetUseFIPSEndpoint(t *testing.T) {
187187
})
188188
}
189189
}
190+
191+
var _ EndpointResolverWithOptions = EndpointResolverWithOptionsFunc(nil)
192+
193+
func TestEndpointResolverWithOptionsFunc_ResolveEndpoint(t *testing.T) {
194+
var er EndpointResolverWithOptions = EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (Endpoint, error) {
195+
if e, a := "foo", service; e != a {
196+
t.Errorf("expect %v, got %v", e, a)
197+
}
198+
if e, a := "bar", region; e != a {
199+
t.Errorf("expect %v, got %v", e, a)
200+
}
201+
if e, a := 2, len(options); e != a {
202+
t.Errorf("expect %v, got %v", e, a)
203+
}
204+
return Endpoint{
205+
URL: "https://foo.amazonaws.com",
206+
}, nil
207+
})
208+
209+
e, err := er.ResolveEndpoint("foo", "bar", 1, 2)
210+
if err != nil {
211+
t.Errorf("expect no error, got %v", err)
212+
}
213+
214+
if e,a := "https://foo.amazonaws.com", e.URL; e != a {
215+
t.Errorf("expect %v, got %v", e, a)
216+
}
217+
}

0 commit comments

Comments
 (0)