mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	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.
This commit is contained in:
		@@ -45,7 +45,7 @@ type Zone interface {
 | 
				
			|||||||
	Name() string
 | 
						Name() string
 | 
				
			||||||
	// ID returns the unique provider identifier for the zone
 | 
						// ID returns the unique provider identifier for the zone
 | 
				
			||||||
	ID() string
 | 
						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)
 | 
						ResourceRecordSets() (ResourceRecordSets, bool)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -70,6 +70,8 @@ type ResourceRecordChangeset interface {
 | 
				
			|||||||
	Remove(ResourceRecordSet) ResourceRecordChangeset
 | 
						Remove(ResourceRecordSet) ResourceRecordChangeset
 | 
				
			||||||
	// Apply applies the accumulated operations to the Zone.
 | 
						// Apply applies the accumulated operations to the Zone.
 | 
				
			||||||
	Apply() error
 | 
						Apply() error
 | 
				
			||||||
 | 
						// IsEmpty returns true if there are no accumulated operations.
 | 
				
			||||||
 | 
						IsEmpty() bool
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type ResourceRecordSet interface {
 | 
					type ResourceRecordSet interface {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -99,3 +99,7 @@ func (c *ResourceRecordChangeset) Apply() error {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (c *ResourceRecordChangeset) IsEmpty() bool {
 | 
				
			||||||
 | 
						return len(c.removals) == 0 && len(c.additions) == 0
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -58,6 +58,10 @@ func (c *ResourceRecordChangeset) Remove(rrset dnsprovider.ResourceRecordSet) dn
 | 
				
			|||||||
	return c
 | 
						return c
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (c *ResourceRecordChangeset) IsEmpty() bool {
 | 
				
			||||||
 | 
						return len(c.changeset) == 0
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *ResourceRecordChangeset) Apply() error {
 | 
					func (c *ResourceRecordChangeset) Apply() error {
 | 
				
			||||||
	ctx := context.Background()
 | 
						ctx := context.Background()
 | 
				
			||||||
	etcdPathPrefix := c.zone.zones.intf.etcdPathPrefix
 | 
						etcdPathPrefix := c.zone.zones.intf.etcdPathPrefix
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -72,3 +72,7 @@ func (c *ResourceRecordChangeset) Apply() error {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (c *ResourceRecordChangeset) IsEmpty() bool {
 | 
				
			||||||
 | 
						return len(c.additions) == 0 && len(c.removals) == 0
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user