mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-06 01:26:59 +02:00
Remove DomainFilterInterface
This commit is contained in:
parent
8623a2afc3
commit
e9be5887bd
@ -215,12 +215,13 @@ func (c *Controller) RunOnce(ctx context.Context) error {
|
||||
verifiedARecords.Set(float64(vARecords))
|
||||
verifiedAAAARecords.Set(float64(vAAAARecords))
|
||||
endpoints = c.Registry.AdjustEndpoints(endpoints)
|
||||
registryFilter := c.Registry.GetDomainFilter()
|
||||
|
||||
plan := &plan.Plan{
|
||||
Policies: []plan.Policy{c.Policy},
|
||||
Current: records,
|
||||
Desired: endpoints,
|
||||
DomainFilter: endpoint.MatchAllDomainFilters{c.DomainFilter, c.Registry.GetDomainFilter()},
|
||||
DomainFilter: endpoint.MatchAllDomainFilters{&c.DomainFilter, ®istryFilter},
|
||||
ManagedRecords: c.ManagedRecordTypes,
|
||||
}
|
||||
|
||||
|
@ -25,12 +25,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// DomainFilterInterface defines the interface to select matching domains for a specific provider or runtime
|
||||
type DomainFilterInterface interface {
|
||||
Match(domain string) bool
|
||||
}
|
||||
|
||||
type MatchAllDomainFilters []DomainFilterInterface
|
||||
type MatchAllDomainFilters []*DomainFilter
|
||||
|
||||
func (f MatchAllDomainFilters) Match(domain string) bool {
|
||||
for _, filter := range f {
|
||||
|
@ -43,7 +43,7 @@ type Plan struct {
|
||||
// Populated after calling Calculate()
|
||||
Changes *Changes
|
||||
// DomainFilter matches DNS names
|
||||
DomainFilter endpoint.DomainFilterInterface
|
||||
DomainFilter endpoint.MatchAllDomainFilters
|
||||
// DNS record types that will be considered for management
|
||||
ManagedRecords []string
|
||||
}
|
||||
@ -232,7 +232,7 @@ func (p *Plan) shouldUpdateProviderSpecific(desired, current *endpoint.Endpoint)
|
||||
// Per RFC 1034, CNAME records conflict with all other records - it is the
|
||||
// only record with this property. The behavior of the planner may need to be
|
||||
// made more sophisticated to codify this.
|
||||
func filterRecordsForPlan(records []*endpoint.Endpoint, domainFilter endpoint.DomainFilterInterface, managedRecords []string) []*endpoint.Endpoint {
|
||||
func filterRecordsForPlan(records []*endpoint.Endpoint, domainFilter endpoint.MatchAllDomainFilters, managedRecords []string) []*endpoint.Endpoint {
|
||||
filtered := []*endpoint.Endpoint{}
|
||||
|
||||
for _, record := range records {
|
||||
|
@ -601,11 +601,12 @@ func (suite *PlanTestSuite) TestDomainFiltersInitial() {
|
||||
expectedUpdateNew := []*endpoint.Endpoint{}
|
||||
expectedDelete := []*endpoint.Endpoint{}
|
||||
|
||||
domainFilter := endpoint.NewDomainFilterWithExclusions([]string{"domain.tld"}, []string{"ex.domain.tld"})
|
||||
p := &Plan{
|
||||
Policies: []Policy{&SyncPolicy{}},
|
||||
Current: current,
|
||||
Desired: desired,
|
||||
DomainFilter: endpoint.NewDomainFilterWithExclusions([]string{"domain.tld"}, []string{"ex.domain.tld"}),
|
||||
DomainFilter: endpoint.MatchAllDomainFilters{&domainFilter},
|
||||
ManagedRecords: []string{endpoint.RecordTypeA, endpoint.RecordTypeCNAME},
|
||||
}
|
||||
|
||||
@ -624,11 +625,12 @@ func (suite *PlanTestSuite) TestDomainFiltersUpdate() {
|
||||
expectedUpdateNew := []*endpoint.Endpoint{}
|
||||
expectedDelete := []*endpoint.Endpoint{}
|
||||
|
||||
domainFilter := endpoint.NewDomainFilterWithExclusions([]string{"domain.tld"}, []string{"ex.domain.tld"})
|
||||
p := &Plan{
|
||||
Policies: []Policy{&SyncPolicy{}},
|
||||
Current: current,
|
||||
Desired: desired,
|
||||
DomainFilter: endpoint.NewDomainFilterWithExclusions([]string{"domain.tld"}, []string{"ex.domain.tld"}),
|
||||
DomainFilter: endpoint.MatchAllDomainFilters{&domainFilter},
|
||||
ManagedRecords: []string{endpoint.RecordTypeA, endpoint.RecordTypeCNAME},
|
||||
}
|
||||
|
||||
|
@ -303,11 +303,11 @@ func AssertActions(t *testing.T, provider *CloudFlareProvider, endpoints []*endp
|
||||
}
|
||||
|
||||
endpoints = provider.AdjustEndpoints(endpoints)
|
||||
|
||||
domainFilter := endpoint.NewDomainFilter([]string{"bar.com"})
|
||||
plan := &plan.Plan{
|
||||
Current: records,
|
||||
Desired: endpoints,
|
||||
DomainFilter: endpoint.NewDomainFilter([]string{"bar.com"}),
|
||||
DomainFilter: endpoint.MatchAllDomainFilters{&domainFilter},
|
||||
ManagedRecords: managedRecords,
|
||||
}
|
||||
|
||||
@ -1189,6 +1189,7 @@ func TestCloudflareComplexUpdate(t *testing.T) {
|
||||
t.Errorf("should not fail, %s", err)
|
||||
}
|
||||
|
||||
domainFilter := endpoint.NewDomainFilter([]string{"bar.com"})
|
||||
plan := &plan.Plan{
|
||||
Current: records,
|
||||
Desired: provider.AdjustEndpoints([]*endpoint.Endpoint{
|
||||
@ -1206,7 +1207,7 @@ func TestCloudflareComplexUpdate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}),
|
||||
DomainFilter: endpoint.NewDomainFilter([]string{"bar.com"}),
|
||||
DomainFilter: endpoint.MatchAllDomainFilters{&domainFilter},
|
||||
ManagedRecords: []string{endpoint.RecordTypeA, endpoint.RecordTypeCNAME},
|
||||
}
|
||||
|
||||
@ -1292,10 +1293,11 @@ func TestCustomTTLWithEnabledProxyNotChanged(t *testing.T) {
|
||||
|
||||
provider.AdjustEndpoints(endpoints)
|
||||
|
||||
domainFilter := endpoint.NewDomainFilter([]string{"bar.com"})
|
||||
plan := &plan.Plan{
|
||||
Current: records,
|
||||
Desired: endpoints,
|
||||
DomainFilter: endpoint.NewDomainFilter([]string{"bar.com"}),
|
||||
DomainFilter: endpoint.MatchAllDomainFilters{&domainFilter},
|
||||
ManagedRecords: []string{endpoint.RecordTypeA, endpoint.RecordTypeCNAME},
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user