diff --git a/.changelog/ee24d721edd94d88826eac19451093c6.json b/.changelog/ee24d721edd94d88826eac19451093c6.json new file mode 100644 index 00000000000..a9c8061168b --- /dev/null +++ b/.changelog/ee24d721edd94d88826eac19451093c6.json @@ -0,0 +1,8 @@ +{ + "id": "ee24d721-edd9-4d88-826e-ac19451093c6", + "type": "bugfix", + "description": "Fixed a bug that prevented aws.EndpointResolverWithOptionsFunc from satisfying the aws.EndpointResolverWithOptions interface.", + "modules": [ + "." + ] +} \ No newline at end of file diff --git a/aws/endpoints.go b/aws/endpoints.go index 43e14bca63b..706f13d2f1d 100644 --- a/aws/endpoints.go +++ b/aws/endpoints.go @@ -183,11 +183,11 @@ type EndpointResolverWithOptions interface { } // EndpointResolverWithOptionsFunc wraps a function to satisfy the EndpointResolverWithOptions interface. -type EndpointResolverWithOptionsFunc func(service, region string, options interface{}) (Endpoint, error) +type EndpointResolverWithOptionsFunc func(service, region string, options ...interface{}) (Endpoint, error) // ResolveEndpoint calls the wrapped function and returns the results. -func (e EndpointResolverWithOptionsFunc) ResolveEndpoint(service, region string, options interface{}) (Endpoint, error) { - return e(service, region, options) +func (e EndpointResolverWithOptionsFunc) ResolveEndpoint(service, region string, options ...interface{}) (Endpoint, error) { + return e(service, region, options...) } // GetDisableHTTPS takes a service's EndpointResolverOptions and returns the DisableHTTPS value. diff --git a/aws/endpoints_test.go b/aws/endpoints_test.go index 6e3913cf4ba..382bdbf0c54 100644 --- a/aws/endpoints_test.go +++ b/aws/endpoints_test.go @@ -187,3 +187,31 @@ func TestGetUseFIPSEndpoint(t *testing.T) { }) } } + +var _ EndpointResolverWithOptions = EndpointResolverWithOptionsFunc(nil) + +func TestEndpointResolverWithOptionsFunc_ResolveEndpoint(t *testing.T) { + var er EndpointResolverWithOptions = EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (Endpoint, error) { + if e, a := "foo", service; e != a { + t.Errorf("expect %v, got %v", e, a) + } + if e, a := "bar", region; e != a { + t.Errorf("expect %v, got %v", e, a) + } + if e, a := 2, len(options); e != a { + t.Errorf("expect %v, got %v", e, a) + } + return Endpoint{ + URL: "https://foo.amazonaws.com", + }, nil + }) + + e, err := er.ResolveEndpoint("foo", "bar", 1, 2) + if err != nil { + t.Errorf("expect no error, got %v", err) + } + + if e,a := "https://foo.amazonaws.com", e.URL; e != a { + t.Errorf("expect %v, got %v", e, a) + } +}