Skip to content

Commit

Permalink
updates after review
Browse files Browse the repository at this point in the history
  • Loading branch information
maleck13 committed Mar 12, 2024
1 parent 9214e66 commit 56f1ea9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
13 changes: 2 additions & 11 deletions api/v1alpha1/dnsrecord_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,7 @@ const (
DefaultGeo string = "default"
)

const wildcardPrefix = "*."

func (s *DNSRecord) isWildCardRoot() bool {
if s.Spec.RootHost != nil {
return strings.HasPrefix(*s.Spec.RootHost, wildcardPrefix)
}
return false
}
const WildcardPrefix = "*."

func (s *DNSRecord) Validate() error {
if s.Spec.RootHost != nil {
Expand All @@ -125,9 +118,7 @@ func (s *DNSRecord) Validate() error {
return fmt.Errorf("no endpoints defined for DNSRecord. Nothing to do.")
}

if s.isWildCardRoot() {
root = strings.Replace(root, wildcardPrefix, "", 1)
}
root, _ = strings.CutPrefix(root, WildcardPrefix)

rootEndpointFound := false
for _, ep := range s.Spec.Endpoints {
Expand Down
7 changes: 5 additions & 2 deletions internal/controller/dnsrecord_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,11 @@ func setDNSRecordCondition(dnsRecord *v1alpha1.DNSRecord, conditionType string,

func (r *DNSRecordReconciler) applyChanges(ctx context.Context, dnsRecord *v1alpha1.DNSRecord, managedZone *v1alpha1.ManagedZone, isDelete bool) error {
logger := log.FromContext(ctx)

rootDomainFilter := externaldnsendpoint.NewDomainFilter([]string{managedZone.Spec.DomainName})
filterDomain, _ := strings.CutPrefix(*dnsRecord.Spec.RootHost, v1alpha1.WildcardPrefix)
if dnsRecord.Spec.RootHost != nil {
filterDomain = *dnsRecord.Spec.RootHost
}
rootDomainFilter := externaldnsendpoint.NewDomainFilter([]string{filterDomain})

providerConfig := provider.Config{
DomainFilter: externaldnsendpoint.NewDomainFilter([]string{managedZone.Spec.DomainName}),
Expand Down

0 comments on commit 56f1ea9

Please sign in to comment.