Skip to content

Commit 05ef3fc

Browse files
committed
refactor(endpoint): add GetBoolProviderSpecificProperty method and update consumers
Signed-off-by: u-kai <76635578+u-kai@users.noreply.github.com>
1 parent ce469e6 commit 05ef3fc

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

provider/aws/aws.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -922,8 +922,8 @@ func (p *AWSProvider) newChange(action route53types.ChangeAction, ep *endpoint.E
922922
change.ResourceRecordSet.Type = route53types.RRType(ep.RecordType)
923923
if targetHostedZone := isAWSAlias(ep); targetHostedZone != "" {
924924
evalTargetHealth := p.evaluateTargetHealth
925-
if prop, ok := ep.GetProviderSpecificProperty(providerSpecificEvaluateTargetHealth); ok {
926-
evalTargetHealth = prop == "true"
925+
if prop, exists := ep.GetBoolProviderSpecificProperty(providerSpecificEvaluateTargetHealth); exists {
926+
evalTargetHealth = prop
927927
}
928928
change.ResourceRecordSet.AliasTarget = &route53types.AliasTarget{
929929
DNSName: aws.String(ep.Targets[0]),
@@ -1346,8 +1346,8 @@ func useAlias(ep *endpoint.Endpoint, preferCNAME bool) bool {
13461346
// isAWSAlias determines if a given endpoint is supposed to create an AWS Alias record
13471347
// and (if so) returns the target hosted zone ID
13481348
func isAWSAlias(ep *endpoint.Endpoint) string {
1349-
isAlias, exists := ep.GetProviderSpecificProperty(providerSpecificAlias)
1350-
if exists && isAlias == "true" && slices.Contains([]string{endpoint.RecordTypeA, endpoint.RecordTypeAAAA}, ep.RecordType) && len(ep.Targets) > 0 {
1349+
isAlias, _ := ep.GetBoolProviderSpecificProperty(providerSpecificAlias)
1350+
if isAlias && slices.Contains([]string{endpoint.RecordTypeA, endpoint.RecordTypeAAAA}, ep.RecordType) && len(ep.Targets) > 0 {
13511351
// alias records can only point to canonical hosted zones (e.g. to ELBs) or other records in the same zone
13521352

13531353
if hostedZoneID, ok := ep.GetProviderSpecificProperty(providerSpecificTargetHostedZone); ok {

registry/txt/registry.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ func (im *TXTRegistry) Records(ctx context.Context) ([]*endpoint.Endpoint, error
244244
}
245245

246246
// AWS Alias records have "new" format encoded as type "cname"
247-
if isAlias, found := ep.GetProviderSpecificProperty("alias"); found && isAlias == "true" && ep.RecordType == endpoint.RecordTypeA {
247+
if isAlias, found := ep.GetBoolProviderSpecificProperty("alias"); found && isAlias && ep.RecordType == endpoint.RecordTypeA {
248248
key.RecordType = endpoint.RecordTypeCNAME
249249
}
250250

@@ -299,7 +299,7 @@ func (im *TXTRegistry) generateTXTRecordWithFilter(r *endpoint.Endpoint, filter
299299
// Always create new format record
300300
recordType := r.RecordType
301301
// AWS Alias records are encoded as type "cname"
302-
if isAlias, found := r.GetProviderSpecificProperty("alias"); found && isAlias == "true" && recordType == endpoint.RecordTypeA {
302+
if isAlias, found := r.GetBoolProviderSpecificProperty("alias"); found && isAlias && recordType == endpoint.RecordTypeA {
303303
recordType = endpoint.RecordTypeCNAME
304304
}
305305

0 commit comments

Comments
 (0)