Merge pull request #39956 from justinsb/dnsprovider_isempty

Automatic merge from submit-queue

dnsprovider: Add IsEmpty method

When batching changes, it is often handy to know whether a changeset
IsEmpty, and thus does not need to be Apply-ed.

```release-note
NONE
```
pull/6/head
Kubernetes Submit Queue 2017-01-25 15:07:32 -08:00 committed by GitHub
commit dd4de1e7d4
4 changed files with 15 additions and 1 deletions

View File

@ -45,7 +45,7 @@ type Zone interface {
Name() string
// ID returns the unique provider identifier for the zone
ID() string
// ResourceRecordsets returns the provider's ResourceRecordSets interface, or false if not supported.
// ResourceRecordSets returns the provider's ResourceRecordSets interface, or false if not supported.
ResourceRecordSets() (ResourceRecordSets, bool)
}
@ -70,6 +70,8 @@ type ResourceRecordChangeset interface {
Remove(ResourceRecordSet) ResourceRecordChangeset
// Apply applies the accumulated operations to the Zone.
Apply() error
// IsEmpty returns true if there are no accumulated operations.
IsEmpty() bool
}
type ResourceRecordSet interface {

View File

@ -99,3 +99,7 @@ func (c *ResourceRecordChangeset) Apply() error {
}
return nil
}
func (c *ResourceRecordChangeset) IsEmpty() bool {
return len(c.removals) == 0 && len(c.additions) == 0
}

View File

@ -59,6 +59,10 @@ func (c *ResourceRecordChangeset) Remove(rrset dnsprovider.ResourceRecordSet) dn
return c
}
func (c *ResourceRecordChangeset) IsEmpty() bool {
return len(c.changeset) == 0
}
func (c *ResourceRecordChangeset) Apply() error {
ctx := context.Background()
etcdPathPrefix := c.zone.zones.intf.etcdPathPrefix

View File

@ -72,3 +72,7 @@ func (c *ResourceRecordChangeset) Apply() error {
return nil
}
func (c *ResourceRecordChangeset) IsEmpty() bool {
return len(c.additions) == 0 && len(c.removals) == 0
}