move the logging to registry (#157)

This commit is contained in:
Yerken 2017-04-13 14:59:07 +02:00 committed by GitHub
parent afa4cff158
commit cbf54d904c
4 changed files with 15 additions and 11 deletions

View File

@ -63,16 +63,6 @@ func (c *Controller) RunOnce() error {
plan = plan.Calculate()
for _, change := range plan.Changes.Create {
log.Infof("Creating %s %s -> %s ..", change.RecordType, change.DNSName, change.Target)
}
for _, change := range plan.Changes.UpdateNew {
log.Infof("Updating %s %s -> %s ..", change.RecordType, change.DNSName, change.Target)
}
for _, change := range plan.Changes.Delete {
log.Infof("Deleting %s %s -> %s ..", change.RecordType, change.DNSName, change.Target)
}
return c.Registry.ApplyChanges(c.Zone, plan.Changes)
}

View File

@ -41,5 +41,6 @@ func (im *NoopRegistry) Records(zone string) ([]*endpoint.Endpoint, error) {
// ApplyChanges propagates changes to the dns provider
func (im *NoopRegistry) ApplyChanges(zone string, changes *plan.Changes) error {
logChanges(changes)
return im.provider.ApplyChanges(zone, changes)
}

View File

@ -17,6 +17,7 @@ limitations under the License.
package registry
import (
log "github.com/Sirupsen/logrus"
"github.com/kubernetes-incubator/external-dns/endpoint"
"github.com/kubernetes-incubator/external-dns/plan"
)
@ -40,3 +41,15 @@ func filterOwnedRecords(ownerID string, eps []*endpoint.Endpoint) []*endpoint.En
}
return filtered
}
func logChanges(changes *plan.Changes) {
for _, change := range changes.Create {
log.Infof("Creating %s %s -> %s ..", change.RecordType, change.DNSName, change.Target)
}
for _, change := range changes.UpdateNew {
log.Infof("Updating %s %s -> %s ..", change.RecordType, change.DNSName, change.Target)
}
for _, change := range changes.Delete {
log.Infof("Deleting %s %s -> %s ..", change.RecordType, change.DNSName, change.Target)
}
}

View File

@ -109,7 +109,7 @@ func (im *TXTRegistry) ApplyChanges(zone string, changes *plan.Changes) error {
txt := endpoint.NewEndpoint(im.mapper.toTXTName(r.DNSName), im.getTXTLabel(), "TXT")
filteredChanges.Delete = append(filteredChanges.Delete, txt)
}
logChanges(filteredChanges)
return im.provider.ApplyChanges(zone, filteredChanges)
}