Skip to content

Commit

Permalink
Converting magic string same-zone to constant
Browse files Browse the repository at this point in the history
  • Loading branch information
spohner committed May 11, 2020
1 parent c0cb715 commit 8d63ec6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions provider/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const (
providerSpecificGeolocationCountryCode = "aws/geolocation-country-code"
providerSpecificGeolocationSubdivisionCode = "aws/geolocation-subdivision-code"
providerSpecificMultiValueAnswer = "aws/multi-value-answer"
sameZoneAlias = "same-zone"
)

var (
Expand Down Expand Up @@ -689,7 +690,7 @@ func changesByZone(zones map[string]*route53.HostedZone, changeSet []*route53.Ch
continue
}
for _, z := range zones {
if c.ResourceRecordSet.AliasTarget != nil && aws.StringValue(c.ResourceRecordSet.AliasTarget.HostedZoneId) == "same-zone" {
if c.ResourceRecordSet.AliasTarget != nil && aws.StringValue(c.ResourceRecordSet.AliasTarget.HostedZoneId) == sameZoneAlias {
// alias record is to be created; target needs to be in the same zone as endpoint
// if it's not, this will fail
rrset := *c.ResourceRecordSet
Expand Down Expand Up @@ -773,7 +774,7 @@ func isAWSAlias(ep *endpoint.Endpoint) string {
}

// if not, target needs to be in the same zone
return "same-zone"
return sameZoneAlias
}
return ""
}
Expand Down
2 changes: 1 addition & 1 deletion provider/aws/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ func TestAWSisAWSAlias(t *testing.T) {
{"foo.example.org", endpoint.RecordTypeCNAME, false, ""}, // normal CNAME
{"bar.eu-central-1.elb.amazonaws.com", endpoint.RecordTypeCNAME, true, "Z215JYRZR1TBD5"}, // pointing to ELB DNS name
{"foobar.example.org", endpoint.RecordTypeCNAME, true, "Z1234567890ABC"}, // HZID retrieved by Route53
{"baz.example.org", endpoint.RecordTypeCNAME, true, "same-zone"}, // record to be created
{"baz.example.org", endpoint.RecordTypeCNAME, true, sameZoneAlias}, // record to be created
} {
ep := &endpoint.Endpoint{
Targets: endpoint.Targets{tc.target},
Expand Down

0 comments on commit 8d63ec6

Please sign in to comment.