Validate Node IPs; clean up validation code

This commit is contained in:
Deyuan Deng
2015-04-22 13:55:05 -04:00
committed by Deyuan Deng
parent 7505bed054
commit c73ce1db34
6 changed files with 147 additions and 46 deletions

View File

@@ -113,3 +113,20 @@ var standardFinalizers = util.NewStringSet(
func IsStandardFinalizerName(str string) bool {
return standardFinalizers.Has(str)
}
// AddToNodeAddresses appends the NodeAddresses to the passed-by-pointer slice,
// only if they do not already exist
func AddToNodeAddresses(addresses *[]NodeAddress, addAddresses ...NodeAddress) {
for _, add := range addAddresses {
exists := false
for _, existing := range *addresses {
if existing.Address == add.Address && existing.Type == add.Type {
exists = true
break
}
}
if !exists {
*addresses = append(*addresses, add)
}
}
}