mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-06 01:26:59 +02:00
uprade golangci-lint and add megacheck & interface linters
This commit is contained in:
parent
432d0696a3
commit
394f46cd64
@ -19,4 +19,5 @@ linters:
|
||||
- goimports
|
||||
- misspell
|
||||
- unconvert
|
||||
- staticcheck
|
||||
- megacheck
|
||||
- interfacer
|
||||
|
@ -14,7 +14,7 @@ matrix:
|
||||
- go: tip
|
||||
|
||||
env:
|
||||
- GOLANGCI_RELEASE="v1.22.2"
|
||||
- GOLANGCI_RELEASE="v1.23.1"
|
||||
|
||||
before_install:
|
||||
- GO111MODULE=off go get github.com/mattn/goveralls
|
||||
|
@ -31,7 +31,6 @@ type LabelsSuite struct {
|
||||
barText string
|
||||
barTextAsMap Labels
|
||||
noHeritageText string
|
||||
noHeritageAsMap Labels
|
||||
wrongHeritageText string
|
||||
multipleHeritageText string //considered invalid
|
||||
}
|
||||
|
@ -289,16 +289,6 @@ func (p *AkamaiProvider) newAkamaiRecord(dnsName, recordType string, targets ...
|
||||
}
|
||||
}
|
||||
|
||||
func (p *AkamaiProvider) newAkamaiRecordsets(dnsName, recordType string, targets ...string) *akamaiRecordsets {
|
||||
akamaiRecords := make([]akamaiRecord, 0)
|
||||
akamaiRecord := p.newAkamaiRecord(dnsName, recordType, targets...)
|
||||
akamaiRecords = append(akamaiRecords, *akamaiRecord)
|
||||
|
||||
return &akamaiRecordsets{
|
||||
Recordsets: akamaiRecords,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *AkamaiProvider) createRecords(zoneNameIDMapper zoneIDName, endpoints []*endpoint.Endpoint) (created []*endpoint.Endpoint, failed []*endpoint.Endpoint) {
|
||||
for _, endpoint := range endpoints {
|
||||
|
||||
|
@ -62,10 +62,7 @@ func (m *mockAkamaiClient) Do(config edgegrid.Config, req *http.Request) (*http.
|
||||
handler := func(w http.ResponseWriter, r *http.Request) (isError bool) {
|
||||
b, _ := ioutil.ReadAll(r.Body)
|
||||
io.WriteString(w, string(b))
|
||||
if string(b) == "{\"status\": 404 }" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return string(b) == "{\"status\": 404 }"
|
||||
}
|
||||
w := httptest.NewRecorder()
|
||||
err := handler(w, req)
|
||||
|
@ -68,7 +68,6 @@ type AlibabaCloudPrivateZoneAPI interface {
|
||||
type AlibabaCloudProvider struct {
|
||||
domainFilter DomainFilter
|
||||
zoneIDFilter ZoneIDFilter // Private Zone only
|
||||
zoneTypeFilter ZoneTypeFilter
|
||||
MaxChangeCount int
|
||||
EvaluateTargetHealth bool
|
||||
AssumeRole string
|
||||
|
@ -591,7 +591,7 @@ func batchChangeSet(cs []*route53.Change, batchSize int) [][]*route53.Change {
|
||||
|
||||
batchChanges := make([][]*route53.Change, 0)
|
||||
|
||||
changesByName := make(map[string][]*route53.Change, 0)
|
||||
changesByName := make(map[string][]*route53.Change)
|
||||
for _, v := range cs {
|
||||
changesByName[*v.ResourceRecordSet.Name] = append(changesByName[*v.ResourceRecordSet.Name], v)
|
||||
}
|
||||
|
@ -82,9 +82,7 @@ func (r *Route53APIStub) ListResourceRecordSetsPagesWithContext(ctx context.Cont
|
||||
output.ResourceRecordSets = []*route53.ResourceRecordSet{}
|
||||
} else {
|
||||
for _, rrsets := range r.recordSets[aws.StringValue(input.HostedZoneId)] {
|
||||
for _, rrset := range rrsets {
|
||||
output.ResourceRecordSets = append(output.ResourceRecordSets, rrset)
|
||||
}
|
||||
output.ResourceRecordSets = append(output.ResourceRecordSets, rrsets...)
|
||||
}
|
||||
}
|
||||
lastPage := true
|
||||
@ -1131,9 +1129,7 @@ func listAWSRecords(t *testing.T, client Route53API, zone string) []*route53.Res
|
||||
require.NoError(t, client.ListResourceRecordSetsPagesWithContext(context.Background(), &route53.ListResourceRecordSetsInput{
|
||||
HostedZoneId: aws.String(zone),
|
||||
}, func(resp *route53.ListResourceRecordSetsOutput, _ bool) bool {
|
||||
for _, recordSet := range resp.ResourceRecordSets {
|
||||
recordSets = append(recordSets, recordSet)
|
||||
}
|
||||
recordSets = append(recordSets, resp.ResourceRecordSets...)
|
||||
return true
|
||||
}))
|
||||
|
||||
|
@ -21,23 +21,16 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/Azure/go-autorest/autorest"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/profiles/latest/privatedns/mgmt/privatedns"
|
||||
"github.com/Azure/go-autorest/autorest"
|
||||
"github.com/Azure/go-autorest/autorest/azure/auth"
|
||||
"github.com/Azure/go-autorest/autorest/to"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"sigs.k8s.io/external-dns/endpoint"
|
||||
"sigs.k8s.io/external-dns/plan"
|
||||
)
|
||||
|
||||
type azurePrivateDNSConfig struct {
|
||||
SubscriptionID string `json:"subscriptionId" yaml:"subscriptionId"`
|
||||
ResourceGroup string `json:"resourceGroup" yaml:"resourceGroup"`
|
||||
}
|
||||
|
||||
// PrivateZonesClient is an interface of privatedns.PrivateZoneClient that can be stubbed for testing.
|
||||
type PrivateZonesClient interface {
|
||||
ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, top *int32) (result privatedns.PrivateZoneListResultIterator, err error)
|
||||
|
@ -78,70 +78,6 @@ func (m *mockCloudFlareClient) ListZonesContext(ctx context.Context, opts ...clo
|
||||
}, nil
|
||||
}
|
||||
|
||||
type mockCloudFlareUserDetailsFail struct{}
|
||||
|
||||
func (m *mockCloudFlareUserDetailsFail) CreateDNSRecord(zoneID string, rr cloudflare.DNSRecord) (*cloudflare.DNSRecordResponse, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareUserDetailsFail) DNSRecords(zoneID string, rr cloudflare.DNSRecord) ([]cloudflare.DNSRecord, error) {
|
||||
return []cloudflare.DNSRecord{}, nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareUserDetailsFail) UpdateDNSRecord(zoneID, recordID string, rr cloudflare.DNSRecord) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareUserDetailsFail) DeleteDNSRecord(zoneID, recordID string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareUserDetailsFail) UserDetails() (cloudflare.User, error) {
|
||||
return cloudflare.User{}, fmt.Errorf("could not get ID from zone name")
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareUserDetailsFail) ZoneIDByName(zoneName string) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareUserDetailsFail) ListZones(zoneID ...string) ([]cloudflare.Zone, error) {
|
||||
return []cloudflare.Zone{{Name: "ext-dns-test.zalando.to."}}, nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareUserDetailsFail) ListZonesContext(ctx context.Context, opts ...cloudflare.ReqOption) (cloudflare.ZonesResponse, error) {
|
||||
return cloudflare.ZonesResponse{}, nil
|
||||
}
|
||||
|
||||
type mockCloudFlareCreateZoneFail struct{}
|
||||
|
||||
func (m *mockCloudFlareCreateZoneFail) CreateDNSRecord(zoneID string, rr cloudflare.DNSRecord) (*cloudflare.DNSRecordResponse, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareCreateZoneFail) DNSRecords(zoneID string, rr cloudflare.DNSRecord) ([]cloudflare.DNSRecord, error) {
|
||||
return []cloudflare.DNSRecord{}, nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareCreateZoneFail) UpdateDNSRecord(zoneID, recordID string, rr cloudflare.DNSRecord) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareCreateZoneFail) DeleteDNSRecord(zoneID, recordID string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareCreateZoneFail) UserDetails() (cloudflare.User, error) {
|
||||
return cloudflare.User{ID: "xxxxxxxxxxxxxxxxxxx"}, nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareCreateZoneFail) ZoneIDByName(zoneName string) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareCreateZoneFail) ListZones(zoneID ...string) ([]cloudflare.Zone, error) {
|
||||
return []cloudflare.Zone{{Name: "ext-dns-test.zalando.to."}}, nil
|
||||
}
|
||||
|
||||
type mockCloudFlareDNSRecordsFail struct{}
|
||||
|
||||
func (m *mockCloudFlareDNSRecordsFail) CreateDNSRecord(zoneID string, rr cloudflare.DNSRecord) (*cloudflare.DNSRecordResponse, error) {
|
||||
@ -182,66 +118,6 @@ func (m *mockCloudFlareDNSRecordsFail) ListZonesContext(ctx context.Context, opt
|
||||
}, nil
|
||||
}
|
||||
|
||||
type mockCloudFlareZoneIDByNameFail struct{}
|
||||
|
||||
func (m *mockCloudFlareZoneIDByNameFail) CreateDNSRecord(zoneID string, rr cloudflare.DNSRecord) (*cloudflare.DNSRecordResponse, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareZoneIDByNameFail) DNSRecords(zoneID string, rr cloudflare.DNSRecord) ([]cloudflare.DNSRecord, error) {
|
||||
return []cloudflare.DNSRecord{}, nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareZoneIDByNameFail) UpdateDNSRecord(zoneID, recordID string, rr cloudflare.DNSRecord) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareZoneIDByNameFail) DeleteDNSRecord(zoneID, recordID string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareZoneIDByNameFail) UserDetails() (cloudflare.User, error) {
|
||||
return cloudflare.User{}, nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareZoneIDByNameFail) ZoneIDByName(zoneName string) (string, error) {
|
||||
return "", fmt.Errorf("no ID for zone found")
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareZoneIDByNameFail) ListZones(zoneID ...string) ([]cloudflare.Zone, error) {
|
||||
return []cloudflare.Zone{{Name: "ext-dns-test.zalando.to."}}, nil
|
||||
}
|
||||
|
||||
type mockCloudFlareDeleteZoneFail struct{}
|
||||
|
||||
func (m *mockCloudFlareDeleteZoneFail) CreateDNSRecord(zoneID string, rr cloudflare.DNSRecord) (*cloudflare.DNSRecordResponse, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareDeleteZoneFail) DNSRecords(zoneID string, rr cloudflare.DNSRecord) ([]cloudflare.DNSRecord, error) {
|
||||
return []cloudflare.DNSRecord{}, nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareDeleteZoneFail) UpdateDNSRecord(zoneID, recordID string, rr cloudflare.DNSRecord) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareDeleteZoneFail) DeleteDNSRecord(zoneID, recordID string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareDeleteZoneFail) UserDetails() (cloudflare.User, error) {
|
||||
return cloudflare.User{}, nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareDeleteZoneFail) ZoneIDByName(zoneName string) (string, error) {
|
||||
return "1234567890", nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareDeleteZoneFail) ListZones(zoneID ...string) ([]cloudflare.Zone, error) {
|
||||
return []cloudflare.Zone{{Name: "ext-dns-test.zalando.to."}}, nil
|
||||
}
|
||||
|
||||
type mockCloudFlareListZonesFail struct{}
|
||||
|
||||
func (m *mockCloudFlareListZonesFail) CreateDNSRecord(zoneID string, rr cloudflare.DNSRecord) (*cloudflare.DNSRecordResponse, error) {
|
||||
@ -276,108 +152,6 @@ func (m *mockCloudFlareListZonesFail) ListZonesContext(ctx context.Context, opts
|
||||
return cloudflare.ZonesResponse{}, fmt.Errorf("no zones available")
|
||||
}
|
||||
|
||||
type mockCloudFlareCreateRecordsFail struct{}
|
||||
|
||||
func (m *mockCloudFlareCreateRecordsFail) CreateDNSRecord(zoneID string, rr cloudflare.DNSRecord) (*cloudflare.DNSRecordResponse, error) {
|
||||
return nil, fmt.Errorf("could not create record")
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareCreateRecordsFail) DNSRecords(zoneID string, rr cloudflare.DNSRecord) ([]cloudflare.DNSRecord, error) {
|
||||
return []cloudflare.DNSRecord{{ID: "1234567890", Name: "foobar.ext-dns-test.zalando.to."}}, nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareCreateRecordsFail) UpdateDNSRecord(zoneID, recordID string, rr cloudflare.DNSRecord) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareCreateRecordsFail) DeleteDNSRecord(zoneID, recordID string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareCreateRecordsFail) UserDetails() (cloudflare.User, error) {
|
||||
return cloudflare.User{ID: "xxxxxxxxxxxxxxxxxxx"}, nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareCreateRecordsFail) ZoneIDByName(zoneName string) (string, error) {
|
||||
return "1234567890", nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareCreateRecordsFail) ListZones(zoneID ...string) ([]cloudflare.Zone, error) {
|
||||
return []cloudflare.Zone{{}}, fmt.Errorf("no zones available")
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareCreateRecordsFail) ListZonesContext(ctx context.Context, opts ...cloudflare.ReqOption) (cloudflare.ZonesResponse, error) {
|
||||
return cloudflare.ZonesResponse{}, nil
|
||||
}
|
||||
|
||||
type mockCloudFlareDeleteRecordsFail struct{}
|
||||
|
||||
func (m *mockCloudFlareDeleteRecordsFail) CreateDNSRecord(zoneID string, rr cloudflare.DNSRecord) (*cloudflare.DNSRecordResponse, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareDeleteRecordsFail) DNSRecords(zoneID string, rr cloudflare.DNSRecord) ([]cloudflare.DNSRecord, error) {
|
||||
return []cloudflare.DNSRecord{{ID: "1234567890", Name: "foobar.ext-dns-test.zalando.to."}}, nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareDeleteRecordsFail) UpdateDNSRecord(zoneID, recordID string, rr cloudflare.DNSRecord) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareDeleteRecordsFail) DeleteDNSRecord(zoneID, recordID string) error {
|
||||
return fmt.Errorf("could not delete record")
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareDeleteRecordsFail) UserDetails() (cloudflare.User, error) {
|
||||
return cloudflare.User{ID: "xxxxxxxxxxxxxxxxxxx"}, nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareDeleteRecordsFail) ZoneIDByName(zoneName string) (string, error) {
|
||||
return "1234567890", nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareDeleteRecordsFail) ListZones(zoneID ...string) ([]cloudflare.Zone, error) {
|
||||
return []cloudflare.Zone{{Name: "ext-dns-test.zalando.to."}}, nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareDeleteRecordsFail) ListZonesContext(ctx context.Context, opts ...cloudflare.ReqOption) (cloudflare.ZonesResponse, error) {
|
||||
return cloudflare.ZonesResponse{}, nil
|
||||
}
|
||||
|
||||
type mockCloudFlareUpdateRecordsFail struct{}
|
||||
|
||||
func (m *mockCloudFlareUpdateRecordsFail) CreateDNSRecord(zoneID string, rr cloudflare.DNSRecord) (*cloudflare.DNSRecordResponse, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareUpdateRecordsFail) DNSRecords(zoneID string, rr cloudflare.DNSRecord) ([]cloudflare.DNSRecord, error) {
|
||||
return []cloudflare.DNSRecord{{ID: "1234567890", Name: "foobar.ext-dns-test.zalando.to."}}, nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareUpdateRecordsFail) UpdateDNSRecord(zoneID, recordID string, rr cloudflare.DNSRecord) error {
|
||||
return fmt.Errorf("could not update record")
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareUpdateRecordsFail) DeleteDNSRecord(zoneID, recordID string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareUpdateRecordsFail) UserDetails() (cloudflare.User, error) {
|
||||
return cloudflare.User{ID: "xxxxxxxxxxxxxxxxxxx"}, nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareUpdateRecordsFail) ZoneIDByName(zoneName string) (string, error) {
|
||||
return "1234567890", nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareUpdateRecordsFail) ListZones(zoneID ...string) ([]cloudflare.Zone, error) {
|
||||
return []cloudflare.Zone{{Name: "ext-dns-test.zalando.to."}}, nil
|
||||
}
|
||||
|
||||
func (m *mockCloudFlareUpdateRecordsFail) ListZonesContext(ctx context.Context, opts ...cloudflare.ReqOption) (cloudflare.ZonesResponse, error) {
|
||||
return cloudflare.ZonesResponse{}, nil
|
||||
}
|
||||
|
||||
func TestNewCloudFlareChanges(t *testing.T) {
|
||||
expect := []struct {
|
||||
Name string
|
||||
|
@ -30,12 +30,6 @@ import (
|
||||
"sigs.k8s.io/external-dns/plan"
|
||||
)
|
||||
|
||||
type mockDigitalOceanInterface interface {
|
||||
List(context.Context, *godo.ListOptions) ([]godo.Domain, *godo.Response, error)
|
||||
Create(context.Context, *godo.DomainCreateRequest) (*godo.Domain, *godo.Response, error)
|
||||
Delete(context.Context, string) (*godo.Response, error)
|
||||
}
|
||||
|
||||
type mockDigitalOceanClient struct{}
|
||||
|
||||
func (m *mockDigitalOceanClient) List(ctx context.Context, opt *godo.ListOptions) ([]godo.Domain, *godo.Response, error) {
|
||||
@ -113,150 +107,6 @@ func (m *mockDigitalOceanClient) Records(ctx context.Context, domain string, opt
|
||||
}
|
||||
}
|
||||
|
||||
type mockDigitalOceanListFail struct{}
|
||||
|
||||
func (m *mockDigitalOceanListFail) List(context.Context, *godo.ListOptions) ([]godo.Domain, *godo.Response, error) {
|
||||
return []godo.Domain{}, nil, fmt.Errorf("Fail to get domains")
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanListFail) Create(context.Context, *godo.DomainCreateRequest) (*godo.Domain, *godo.Response, error) {
|
||||
return &godo.Domain{Name: "example.com"}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanListFail) CreateRecord(context.Context, string, *godo.DomainRecordEditRequest) (*godo.DomainRecord, *godo.Response, error) {
|
||||
return &godo.DomainRecord{ID: 1}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanListFail) Delete(context.Context, string) (*godo.Response, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (m *mockDigitalOceanListFail) DeleteRecord(ctx context.Context, domain string, id int) (*godo.Response, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (m *mockDigitalOceanListFail) EditRecord(ctx context.Context, domain string, id int, editRequest *godo.DomainRecordEditRequest) (*godo.DomainRecord, *godo.Response, error) {
|
||||
return &godo.DomainRecord{ID: 1}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanListFail) Get(ctx context.Context, name string) (*godo.Domain, *godo.Response, error) {
|
||||
return &godo.Domain{Name: "example.com"}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanListFail) Record(ctx context.Context, domain string, id int) (*godo.DomainRecord, *godo.Response, error) {
|
||||
return &godo.DomainRecord{ID: 1}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanListFail) Records(ctx context.Context, domain string, opt *godo.ListOptions) ([]godo.DomainRecord, *godo.Response, error) {
|
||||
return []godo.DomainRecord{{ID: 1}, {ID: 2}}, nil, nil
|
||||
}
|
||||
|
||||
type mockDigitalOceanGetFail struct{}
|
||||
|
||||
func (m *mockDigitalOceanGetFail) List(context.Context, *godo.ListOptions) ([]godo.Domain, *godo.Response, error) {
|
||||
return []godo.Domain{{Name: "foo.com"}, {Name: "bar.com"}}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanGetFail) Create(context.Context, *godo.DomainCreateRequest) (*godo.Domain, *godo.Response, error) {
|
||||
return &godo.Domain{Name: "example.com"}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanGetFail) CreateRecord(context.Context, string, *godo.DomainRecordEditRequest) (*godo.DomainRecord, *godo.Response, error) {
|
||||
return &godo.DomainRecord{ID: 1}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanGetFail) Delete(context.Context, string) (*godo.Response, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (m *mockDigitalOceanGetFail) DeleteRecord(ctx context.Context, domain string, id int) (*godo.Response, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (m *mockDigitalOceanGetFail) EditRecord(ctx context.Context, domain string, id int, editRequest *godo.DomainRecordEditRequest) (*godo.DomainRecord, *godo.Response, error) {
|
||||
return &godo.DomainRecord{ID: 1}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanGetFail) Get(ctx context.Context, name string) (*godo.Domain, *godo.Response, error) {
|
||||
return nil, nil, fmt.Errorf("Failed to get domain")
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanGetFail) Record(ctx context.Context, domain string, id int) (*godo.DomainRecord, *godo.Response, error) {
|
||||
return &godo.DomainRecord{ID: 1}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanGetFail) Records(ctx context.Context, domain string, opt *godo.ListOptions) ([]godo.DomainRecord, *godo.Response, error) {
|
||||
return []godo.DomainRecord{{ID: 1}, {ID: 2}}, nil, nil
|
||||
}
|
||||
|
||||
type mockDigitalOceanCreateFail struct{}
|
||||
|
||||
func (m *mockDigitalOceanCreateFail) List(context.Context, *godo.ListOptions) ([]godo.Domain, *godo.Response, error) {
|
||||
return []godo.Domain{{Name: "foo.com"}, {Name: "bar.com"}}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanCreateFail) Create(context.Context, *godo.DomainCreateRequest) (*godo.Domain, *godo.Response, error) {
|
||||
return nil, nil, fmt.Errorf("Failed to create domain")
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanCreateFail) CreateRecord(context.Context, string, *godo.DomainRecordEditRequest) (*godo.DomainRecord, *godo.Response, error) {
|
||||
return &godo.DomainRecord{ID: 1}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanCreateFail) Delete(context.Context, string) (*godo.Response, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (m *mockDigitalOceanCreateFail) DeleteRecord(ctx context.Context, domain string, id int) (*godo.Response, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (m *mockDigitalOceanCreateFail) EditRecord(ctx context.Context, domain string, id int, editRequest *godo.DomainRecordEditRequest) (*godo.DomainRecord, *godo.Response, error) {
|
||||
return &godo.DomainRecord{ID: 1}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanCreateFail) Get(ctx context.Context, name string) (*godo.Domain, *godo.Response, error) {
|
||||
return &godo.Domain{Name: "example.com"}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanCreateFail) Record(ctx context.Context, domain string, id int) (*godo.DomainRecord, *godo.Response, error) {
|
||||
return &godo.DomainRecord{ID: 1}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanCreateFail) Records(ctx context.Context, domain string, opt *godo.ListOptions) ([]godo.DomainRecord, *godo.Response, error) {
|
||||
return []godo.DomainRecord{{ID: 1}, {ID: 2}}, nil, nil
|
||||
}
|
||||
|
||||
type mockDigitalOceanDeleteFail struct{}
|
||||
|
||||
func (m *mockDigitalOceanDeleteFail) List(context.Context, *godo.ListOptions) ([]godo.Domain, *godo.Response, error) {
|
||||
return []godo.Domain{{Name: "foo.com"}, {Name: "bar.com"}}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanDeleteFail) Create(context.Context, *godo.DomainCreateRequest) (*godo.Domain, *godo.Response, error) {
|
||||
return &godo.Domain{Name: "example.com"}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanDeleteFail) CreateRecord(context.Context, string, *godo.DomainRecordEditRequest) (*godo.DomainRecord, *godo.Response, error) {
|
||||
return &godo.DomainRecord{ID: 1}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanDeleteFail) Delete(context.Context, string) (*godo.Response, error) {
|
||||
return nil, fmt.Errorf("Failed to delete domain")
|
||||
}
|
||||
func (m *mockDigitalOceanDeleteFail) DeleteRecord(ctx context.Context, domain string, id int) (*godo.Response, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (m *mockDigitalOceanDeleteFail) EditRecord(ctx context.Context, domain string, id int, editRequest *godo.DomainRecordEditRequest) (*godo.DomainRecord, *godo.Response, error) {
|
||||
return &godo.DomainRecord{ID: 1}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanDeleteFail) Get(ctx context.Context, name string) (*godo.Domain, *godo.Response, error) {
|
||||
return &godo.Domain{Name: "example.com"}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanDeleteFail) Record(ctx context.Context, domain string, id int) (*godo.DomainRecord, *godo.Response, error) {
|
||||
return &godo.DomainRecord{ID: 1}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanDeleteFail) Records(ctx context.Context, domain string, opt *godo.ListOptions) ([]godo.DomainRecord, *godo.Response, error) {
|
||||
return []godo.DomainRecord{{ID: 1}, {ID: 2}}, nil, nil
|
||||
}
|
||||
|
||||
type mockDigitalOceanRecordsFail struct{}
|
||||
|
||||
func (m *mockDigitalOceanRecordsFail) List(context.Context, *godo.ListOptions) ([]godo.Domain, *godo.Response, error) {
|
||||
@ -293,114 +143,6 @@ func (m *mockDigitalOceanRecordsFail) Records(ctx context.Context, domain string
|
||||
return []godo.DomainRecord{}, nil, fmt.Errorf("Failed to get records")
|
||||
}
|
||||
|
||||
type mockDigitalOceanUpdateRecordsFail struct{}
|
||||
|
||||
func (m *mockDigitalOceanUpdateRecordsFail) List(context.Context, *godo.ListOptions) ([]godo.Domain, *godo.Response, error) {
|
||||
return []godo.Domain{{Name: "foo.com"}, {Name: "bar.com"}}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanUpdateRecordsFail) Create(context.Context, *godo.DomainCreateRequest) (*godo.Domain, *godo.Response, error) {
|
||||
return &godo.Domain{Name: "example.com"}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanUpdateRecordsFail) CreateRecord(context.Context, string, *godo.DomainRecordEditRequest) (*godo.DomainRecord, *godo.Response, error) {
|
||||
return &godo.DomainRecord{ID: 1}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanUpdateRecordsFail) Delete(context.Context, string) (*godo.Response, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (m *mockDigitalOceanUpdateRecordsFail) DeleteRecord(ctx context.Context, domain string, id int) (*godo.Response, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (m *mockDigitalOceanUpdateRecordsFail) EditRecord(ctx context.Context, domain string, id int, editRequest *godo.DomainRecordEditRequest) (*godo.DomainRecord, *godo.Response, error) {
|
||||
return nil, nil, fmt.Errorf("Failed to update record")
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanUpdateRecordsFail) Get(ctx context.Context, name string) (*godo.Domain, *godo.Response, error) {
|
||||
return &godo.Domain{Name: "example.com"}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanUpdateRecordsFail) Record(ctx context.Context, domain string, id int) (*godo.DomainRecord, *godo.Response, error) {
|
||||
return &godo.DomainRecord{ID: 1}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanUpdateRecordsFail) Records(ctx context.Context, domain string, opt *godo.ListOptions) ([]godo.DomainRecord, *godo.Response, error) {
|
||||
return []godo.DomainRecord{{ID: 1}, {ID: 2}}, nil, nil
|
||||
}
|
||||
|
||||
type mockDigitalOceanDeleteRecordsFail struct{}
|
||||
|
||||
func (m *mockDigitalOceanDeleteRecordsFail) List(context.Context, *godo.ListOptions) ([]godo.Domain, *godo.Response, error) {
|
||||
return []godo.Domain{{Name: "foo.com"}, {Name: "bar.com"}}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanDeleteRecordsFail) Create(context.Context, *godo.DomainCreateRequest) (*godo.Domain, *godo.Response, error) {
|
||||
return &godo.Domain{Name: "example.com"}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanDeleteRecordsFail) CreateRecord(context.Context, string, *godo.DomainRecordEditRequest) (*godo.DomainRecord, *godo.Response, error) {
|
||||
return &godo.DomainRecord{ID: 1}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanDeleteRecordsFail) Delete(context.Context, string) (*godo.Response, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (m *mockDigitalOceanDeleteRecordsFail) DeleteRecord(ctx context.Context, domain string, id int) (*godo.Response, error) {
|
||||
return nil, fmt.Errorf("Failed to delete record")
|
||||
}
|
||||
func (m *mockDigitalOceanDeleteRecordsFail) EditRecord(ctx context.Context, domain string, id int, editRequest *godo.DomainRecordEditRequest) (*godo.DomainRecord, *godo.Response, error) {
|
||||
return &godo.DomainRecord{ID: 1}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanDeleteRecordsFail) Get(ctx context.Context, name string) (*godo.Domain, *godo.Response, error) {
|
||||
return &godo.Domain{Name: "example.com"}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanDeleteRecordsFail) Record(ctx context.Context, domain string, id int) (*godo.DomainRecord, *godo.Response, error) {
|
||||
return &godo.DomainRecord{ID: 1}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanDeleteRecordsFail) Records(ctx context.Context, domain string, opt *godo.ListOptions) ([]godo.DomainRecord, *godo.Response, error) {
|
||||
return []godo.DomainRecord{{ID: 1, Name: "foobar.ext-dns-test.zalando.to."}, {ID: 2}}, nil, nil
|
||||
}
|
||||
|
||||
type mockDigitalOceanCreateRecordsFail struct{}
|
||||
|
||||
func (m *mockDigitalOceanCreateRecordsFail) List(context.Context, *godo.ListOptions) ([]godo.Domain, *godo.Response, error) {
|
||||
return []godo.Domain{{Name: "foo.com"}, {Name: "bar.com"}}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanCreateRecordsFail) Create(context.Context, *godo.DomainCreateRequest) (*godo.Domain, *godo.Response, error) {
|
||||
return &godo.Domain{Name: "example.com"}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanCreateRecordsFail) CreateRecord(context.Context, string, *godo.DomainRecordEditRequest) (*godo.DomainRecord, *godo.Response, error) {
|
||||
return nil, nil, fmt.Errorf("Failed to create record")
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanCreateRecordsFail) Delete(context.Context, string) (*godo.Response, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (m *mockDigitalOceanCreateRecordsFail) DeleteRecord(ctx context.Context, domain string, id int) (*godo.Response, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (m *mockDigitalOceanCreateRecordsFail) EditRecord(ctx context.Context, domain string, id int, editRequest *godo.DomainRecordEditRequest) (*godo.DomainRecord, *godo.Response, error) {
|
||||
return &godo.DomainRecord{ID: 1}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanCreateRecordsFail) Get(ctx context.Context, name string) (*godo.Domain, *godo.Response, error) {
|
||||
return &godo.Domain{Name: "example.com"}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanCreateRecordsFail) Record(ctx context.Context, domain string, id int) (*godo.DomainRecord, *godo.Response, error) {
|
||||
return &godo.DomainRecord{ID: 1}, nil, nil
|
||||
}
|
||||
|
||||
func (m *mockDigitalOceanCreateRecordsFail) Records(ctx context.Context, domain string, opt *godo.ListOptions) ([]godo.DomainRecord, *godo.Response, error) {
|
||||
return []godo.DomainRecord{{ID: 1, Name: "foobar.ext-dns-test.zalando.to."}, {ID: 2}}, nil, nil
|
||||
}
|
||||
|
||||
func TestNewDigitalOceanChanges(t *testing.T) {
|
||||
action := DigitalOceanCreate
|
||||
endpoints := []*endpoint.Endpoint{{DNSName: "new", Targets: endpoint.Targets{"target"}}}
|
||||
|
@ -37,8 +37,6 @@ var mockProvider dnsimpleProvider
|
||||
var dnsimpleListRecordsResponse dnsimple.ZoneRecordsResponse
|
||||
var dnsimpleListZonesResponse dnsimple.ZonesResponse
|
||||
|
||||
type mockDnsimpleZonesService struct{}
|
||||
|
||||
func TestDnsimpleServices(t *testing.T) {
|
||||
// Setup example responses
|
||||
firstZone := dnsimple.Zone{
|
||||
|
@ -395,19 +395,6 @@ func (d *dynProviderState) fetchAllRecordsInZone(zone string) (*dynectsoap.GetAl
|
||||
|
||||
}
|
||||
|
||||
// fetchAllRecordLinksInZone list all records in a zone with a single call. Records not matched by the
|
||||
// DomainFilter are ignored. The response is a list of links that can be fed to dynect.Client.Do()
|
||||
// directly
|
||||
func (d *dynProviderState) fetchAllRecordLinksInZone(client *dynect.Client, zone string) ([]string, error) {
|
||||
var allRecords dynect.AllRecordsResponse
|
||||
err := client.Do("GET", fmt.Sprintf("AllRecord/%s/", zone), nil, &allRecords)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return filterAndFixLinks(allRecords.Data, d.DomainFilter), nil
|
||||
}
|
||||
|
||||
// buildLinkToRecord build a resource link. The symmetry of the dyn API is used to save
|
||||
// switch-case boilerplate.
|
||||
// Empty response means the endpoint is not mappable to a records link: either because the fqdn
|
||||
@ -604,7 +591,7 @@ func (d *dynProviderState) Records(ctx context.Context) ([]*endpoint.Endpoint, e
|
||||
for _, zone := range zones {
|
||||
serial, err := d.fetchZoneSerial(client, zone)
|
||||
if err != nil {
|
||||
if strings.Index(err.Error(), "404 Not Found") >= 0 {
|
||||
if strings.Contains(err.Error(), "404 Not Found") {
|
||||
log.Infof("Ignore zone %s as it does not exist", zone)
|
||||
continue
|
||||
}
|
||||
|
@ -578,7 +578,6 @@ func TestGoogleBatchChangeSetExceeding(t *testing.T) {
|
||||
const testCount = 50
|
||||
const testLimit = 11
|
||||
const expectedBatchCount = 5
|
||||
const expectedChangesCount = 10
|
||||
|
||||
for i := 1; i <= testCount; i += 2 {
|
||||
cs.Additions = append(cs.Additions, &dns.ResourceRecordSet{
|
||||
@ -612,7 +611,6 @@ func TestGoogleBatchChangeSetExceeding(t *testing.T) {
|
||||
|
||||
func TestGoogleBatchChangeSetExceedingNameChange(t *testing.T) {
|
||||
cs := &dns.Change{}
|
||||
const testCount = 10
|
||||
const testLimit = 1
|
||||
|
||||
cs.Additions = append(cs.Additions, &dns.ResourceRecordSet{
|
||||
|
@ -115,7 +115,7 @@ func newNS1ProviderWithHTTPClient(config NS1Config, client *http.Client) (*NS1Pr
|
||||
clientArgs = append(clientArgs, api.SetEndpoint(config.NS1Endpoint))
|
||||
}
|
||||
|
||||
if config.NS1IgnoreSSL == true {
|
||||
if config.NS1IgnoreSSL {
|
||||
log.Info("ns1-ignoressl flag is True, skipping SSL verification")
|
||||
defaultTransport := http.DefaultTransport.(*http.Transport)
|
||||
tr := &http.Transport{
|
||||
|
@ -47,20 +47,11 @@ type mockRRSetService struct {
|
||||
TestErrorReturned bool
|
||||
}
|
||||
|
||||
func (m *mockRcodeZeroClient) resetMockServices() {
|
||||
m.Zones = &mockZoneManagementService{}
|
||||
m.RRSet = &mockRRSetService{}
|
||||
}
|
||||
|
||||
func (m *mockZoneManagementService) resetTestConditions() {
|
||||
m.TestNilZonesReturned = false
|
||||
m.TestErrorReturned = false
|
||||
}
|
||||
|
||||
func (m *mockRRSetService) resetTestConditions() {
|
||||
m.TestErrorReturned = false
|
||||
}
|
||||
|
||||
func TestRcodeZeroProvider_Records(t *testing.T) {
|
||||
|
||||
mockRRSetService := &mockRRSetService{}
|
||||
|
@ -26,7 +26,6 @@ import (
|
||||
|
||||
type cloudfoundrySource struct {
|
||||
client *cfclient.Client
|
||||
config Config
|
||||
}
|
||||
|
||||
// NewCloudFoundrySource creates a new cloudfoundrySource with the given config
|
||||
|
@ -52,7 +52,7 @@ func defaultHeader() http.Header {
|
||||
return header
|
||||
}
|
||||
|
||||
func objBody(codec runtime.Codec, obj runtime.Object) io.ReadCloser {
|
||||
func objBody(codec runtime.Encoder, obj runtime.Object) io.ReadCloser {
|
||||
return ioutil.NopCloser(bytes.NewReader([]byte(runtime.EncodeOrDie(codec, obj))))
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ func NewIstioGatewaySource(
|
||||
|
||||
// wait for the local cache to be populated.
|
||||
err = wait.Poll(time.Second, 60*time.Second, func() (bool, error) {
|
||||
return serviceInformer.Informer().HasSynced() == true, nil
|
||||
return serviceInformer.Informer().HasSynced(), nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to sync cache: %v", err)
|
||||
@ -327,14 +327,3 @@ func (sc *gatewaySource) endpointsFromGatewayConfig(config istiomodel.Config) ([
|
||||
|
||||
return endpoints, nil
|
||||
}
|
||||
|
||||
func parseIngressGateway(ingressGateway string) (namespace, name string, err error) {
|
||||
parts := strings.Split(ingressGateway, "/")
|
||||
if len(parts) != 2 {
|
||||
err = fmt.Errorf("invalid ingress gateway service (namespace/name) found '%v'", ingressGateway)
|
||||
} else {
|
||||
namespace, name = parts[0], parts[1]
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ func NewIngressSource(kubeClient kubernetes.Interface, namespace, annotationFilt
|
||||
|
||||
// wait for the local cache to be populated.
|
||||
err = wait.Poll(time.Second, 60*time.Second, func() (bool, error) {
|
||||
return ingressInformer.Informer().HasSynced() == true, nil
|
||||
return ingressInformer.Informer().HasSynced(), nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to sync cache: %v", err)
|
||||
|
@ -104,7 +104,7 @@ func NewContourIngressRouteSource(
|
||||
|
||||
// wait for the local cache to be populated.
|
||||
err = wait.Poll(time.Second, 60*time.Second, func() (bool, error) {
|
||||
return ingressRouteInformer.Informer().HasSynced() == true, nil
|
||||
return ingressRouteInformer.Informer().HasSynced(), nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to sync cache: %v", err)
|
||||
|
@ -78,7 +78,7 @@ func NewNodeSource(kubeClient kubernetes.Interface, annotationFilter, fqdnTempla
|
||||
|
||||
// wait for the local cache to be populated.
|
||||
err = wait.Poll(time.Second, 60*time.Second, func() (bool, error) {
|
||||
return nodeInformer.Informer().HasSynced() == true, nil
|
||||
return nodeInformer.Informer().HasSynced(), nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to sync cache: %v", err)
|
||||
|
@ -113,7 +113,7 @@ func NewServiceSource(kubeClient kubernetes.Interface, namespace, annotationFilt
|
||||
|
||||
// wait for the local cache to be populated.
|
||||
err = wait.Poll(time.Second, 60*time.Second, func() (bool, error) {
|
||||
return serviceInformer.Informer().HasSynced() == true, nil
|
||||
return serviceInformer.Informer().HasSynced(), nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to sync cache: %v", err)
|
||||
@ -234,9 +234,9 @@ func (sc *serviceSource) extractHeadlessEndpoints(svc *v1.Service, hostname stri
|
||||
headlessDomains = append(headlessDomains, fmt.Sprintf("%s.%s", v.Spec.Hostname, hostname))
|
||||
}
|
||||
for _, headlessDomain := range headlessDomains {
|
||||
if sc.publishHostIP == true {
|
||||
if sc.publishHostIP {
|
||||
log.Debugf("Generating matching endpoint %s with HostIP %s", headlessDomain, v.Status.HostIP)
|
||||
// To reduce traffice on the DNS API only add record for running Pods. Good Idea?
|
||||
// To reduce traffic on the DNS API only add record for running Pods. Good Idea?
|
||||
if v.Status.Phase == v1.PodRunning {
|
||||
targetsByHeadlessDomain[headlessDomain] = append(targetsByHeadlessDomain[headlessDomain], v.Status.HostIP)
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user