mirror of https://github.com/k3s-io/k3s
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
commit
dd4de1e7d4
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue