mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-21 00:41:00 +02:00
Merge pull request #1960 from robselway/fix-1906
Prevent plan reporting endpoint target casing differences as a change
This commit is contained in:
commit
aafb4bf569
@ -71,7 +71,7 @@ func (t Targets) Swap(i, j int) {
|
||||
t[i], t[j] = t[j], t[i]
|
||||
}
|
||||
|
||||
// Same compares to Targets and returns true if they are completely identical
|
||||
// Same compares to Targets and returns true if they are identical (case-insensitive)
|
||||
func (t Targets) Same(o Targets) bool {
|
||||
if len(t) != len(o) {
|
||||
return false
|
||||
@ -80,7 +80,7 @@ func (t Targets) Same(o Targets) bool {
|
||||
sort.Stable(o)
|
||||
|
||||
for i, e := range t {
|
||||
if e != o[i] {
|
||||
if !strings.EqualFold(e, o[i]) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ func TestTargetsSame(t *testing.T) {
|
||||
{""},
|
||||
{"1.2.3.4"},
|
||||
{"8.8.8.8", "8.8.4.4"},
|
||||
{"example.org", "EXAMPLE.ORG"},
|
||||
}
|
||||
|
||||
for _, d := range tests {
|
||||
|
@ -30,6 +30,7 @@ type PlanTestSuite struct {
|
||||
suite.Suite
|
||||
fooV1Cname *endpoint.Endpoint
|
||||
fooV2Cname *endpoint.Endpoint
|
||||
fooV2CnameUppercase *endpoint.Endpoint
|
||||
fooV2TXT *endpoint.Endpoint
|
||||
fooV2CnameNoLabel *endpoint.Endpoint
|
||||
fooV3CnameSameResource *endpoint.Endpoint
|
||||
@ -77,6 +78,14 @@ func (suite *PlanTestSuite) SetupTest() {
|
||||
endpoint.ResourceLabelKey: "ingress/default/foo-v2",
|
||||
},
|
||||
}
|
||||
suite.fooV2CnameUppercase = &endpoint.Endpoint{
|
||||
DNSName: "foo",
|
||||
Targets: endpoint.Targets{"V2"},
|
||||
RecordType: "CNAME",
|
||||
Labels: map[string]string{
|
||||
endpoint.ResourceLabelKey: "ingress/default/foo-v2",
|
||||
},
|
||||
}
|
||||
suite.fooV2TXT = &endpoint.Endpoint{
|
||||
DNSName: "foo",
|
||||
RecordType: "TXT",
|
||||
@ -452,6 +461,27 @@ func (suite *PlanTestSuite) TestIgnoreTXT() {
|
||||
validateEntries(suite.T(), changes.Delete, expectedDelete)
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestIgnoreTargetCase() {
|
||||
current := []*endpoint.Endpoint{suite.fooV2Cname}
|
||||
desired := []*endpoint.Endpoint{suite.fooV2CnameUppercase}
|
||||
expectedCreate := []*endpoint.Endpoint{}
|
||||
expectedUpdateOld := []*endpoint.Endpoint{}
|
||||
expectedUpdateNew := []*endpoint.Endpoint{}
|
||||
expectedDelete := []*endpoint.Endpoint{}
|
||||
|
||||
p := &Plan{
|
||||
Policies: []Policy{&SyncPolicy{}},
|
||||
Current: current,
|
||||
Desired: desired,
|
||||
}
|
||||
|
||||
changes := p.Calculate().Changes
|
||||
validateEntries(suite.T(), changes.Create, expectedCreate)
|
||||
validateEntries(suite.T(), changes.UpdateNew, expectedUpdateNew)
|
||||
validateEntries(suite.T(), changes.UpdateOld, expectedUpdateOld)
|
||||
validateEntries(suite.T(), changes.Delete, expectedDelete)
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestRemoveEndpoint() {
|
||||
current := []*endpoint.Endpoint{suite.fooV1Cname, suite.bar192A}
|
||||
desired := []*endpoint.Endpoint{suite.fooV1Cname}
|
||||
|
Loading…
x
Reference in New Issue
Block a user