Skip to content

Commit

Permalink
Only show managed dns record types in status (#15)
Browse files Browse the repository at this point in the history
Signed-off-by: rasel <rasel@appscode.com>
  • Loading branch information
Superm4n97 authored Jan 12, 2023
1 parent ced78ea commit c03010f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/spf13/cobra v1.6.0
go.bytebuilders.dev/license-verifier v0.12.2
gomodules.xyz/logs v0.0.6
gomodules.xyz/sets v0.2.1
gomodules.xyz/x v0.0.14
k8s.io/api v0.25.2
k8s.io/apimachinery v0.25.2
Expand Down Expand Up @@ -176,7 +177,6 @@ require (
gomodules.xyz/clock v0.0.0-20200817085942-06523dba733f // indirect
gomodules.xyz/flags v0.1.3 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
gomodules.xyz/sets v0.2.1 // indirect
gomodules.xyz/wait v0.2.0 // indirect
google.golang.org/api v0.96.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
Expand Down
11 changes: 10 additions & 1 deletion pkg/plan/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
externaldnsv1alpha1 "kubeops.dev/external-dns-operator/apis/external/v1alpha1"

"github.com/sirupsen/logrus"
"gomodules.xyz/sets"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/klog/v2"
"sigs.k8s.io/external-dns/endpoint"
Expand Down Expand Up @@ -305,8 +306,16 @@ func createAndApplyPlan(ctx context.Context, cfg *externaldns.Config, r registry
klog.Info("all records are already up to date")
}

managedRecordsTypes := sets.NewString()

for _, dnsType := range cfg.ManagedDNSRecordTypes {
managedRecordsTypes.Insert(dnsType)
}

for _, rec := range pln.Desired {
dnsRecs = append(dnsRecs, externaldnsv1alpha1.DNSRecord{Name: rec.DNSName, Target: rec.Targets.String()})
if managedRecordsTypes.Has(rec.RecordType) {
dnsRecs = append(dnsRecs, externaldnsv1alpha1.DNSRecord{Name: rec.DNSName, Target: rec.Targets.String()})
}
}
return dnsRecs, nil
}
Expand Down

0 comments on commit c03010f

Please sign in to comment.