external-dns/provider/provider.go
Martin Linkhorst 03d76204f9 support multiple hosted zones and automatic lookup (#152)
* feat(aws): support multiple hosted zones and automatic lookup

* chore: run gofmt with the simplified command

* fix(aws): add missing method from google provider

* fix: remove superflous parameter from google provider

* feat: make domain configurable via flag

* fix(aws): remove unused constant

* fix(aws): don't log actions that were filtered out

* feat(aws): detect best possible zone to put dns entries in

* fix(aws): log error instead of failing if a change batch fails

* chore: update changelog with support for multiple zones
2017-04-13 17:57:18 +02:00

43 lines
1.2 KiB
Go

/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package provider
import (
"net"
"github.com/kubernetes-incubator/external-dns/endpoint"
"github.com/kubernetes-incubator/external-dns/plan"
)
// Provider defines the interface DNS providers should implement.
type Provider interface {
Records(zone string) ([]*endpoint.Endpoint, error)
ApplyChanges(zone string, changes *plan.Changes) error
}
// suitableType returns the DNS resource record type suitable for the target.
// In this case type A for IPs and type CNAME for everything else.
func suitableType(ep *endpoint.Endpoint) string {
if ep.RecordType != "" {
return ep.RecordType
}
if net.ParseIP(ep.Target) != nil {
return "A"
}
return "CNAME"
}