Commit 6e3eab49 authored by Justin Santa Barbara's avatar Justin Santa Barbara

dnsprovider: Expose route53 constructor

This enables testing when the dnsprovider is used externally (with a mock Route53 API, as we do in kops), and also might be useful for constructing with a particular client instance with extra options.
parent 4474263a
...@@ -28,9 +28,9 @@ type Interface struct { ...@@ -28,9 +28,9 @@ type Interface struct {
service stubs.Route53API service stubs.Route53API
} }
// newInterfaceWithStub facilitates stubbing out the underlying AWS Route53 // New builds an Interface, with a specified Route53API implementation.
// library for testing purposes. It returns an provider-independent interface. // This is useful for testing purposes, but also if we want an instance with with custom AWS options.
func newInterfaceWithStub(service stubs.Route53API) *Interface { func New(service stubs.Route53API) *Interface {
return &Interface{service} return &Interface{service}
} }
......
...@@ -40,5 +40,5 @@ func init() { ...@@ -40,5 +40,5 @@ func init() {
func newRoute53(config io.Reader) (*Interface, error) { func newRoute53(config io.Reader) (*Interface, error) {
// Connect to AWS Route53 - TODO: Do more sophisticated auth // Connect to AWS Route53 - TODO: Do more sophisticated auth
svc := route53.New(session.New()) svc := route53.New(session.New())
return newInterfaceWithStub(svc), nil return New(svc), nil
} }
...@@ -40,7 +40,7 @@ func newTestInterface() (dnsprovider.Interface, error) { ...@@ -40,7 +40,7 @@ func newTestInterface() (dnsprovider.Interface, error) {
func newFakeInterface() (dnsprovider.Interface, error) { func newFakeInterface() (dnsprovider.Interface, error) {
var service route53testing.Route53API var service route53testing.Route53API
service = route53testing.NewRoute53APIStub() service = route53testing.NewRoute53APIStub()
iface := newInterfaceWithStub(service) iface := New(service)
// Add a fake zone to test against. // Add a fake zone to test against.
params := &route53.CreateHostedZoneInput{ params := &route53.CreateHostedZoneInput{
CallerReference: aws.String("Nonce"), // Required CallerReference: aws.String("Nonce"), // Required
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment