Skip to content

Commit

Permalink
move the logging to registry
Browse files Browse the repository at this point in the history
  • Loading branch information
ideahitme committed Apr 13, 2017
1 parent afa4cff commit beb9f10
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
10 changes: 0 additions & 10 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
1 change: 1 addition & 0 deletions registry/noop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
13 changes: 13 additions & 0 deletions registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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)
}
}
2 changes: 1 addition & 1 deletion registry/txt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit beb9f10

Please sign in to comment.