Validate Duplicate nodes
@@ -13,6 +13,11 @@ func (c *Cluster) ValidateCluster() error {
return err
}
+ // validate duplicate nodes
+ if err := validateDuplicateNodes(c); err != nil {
+ return err
+ }
+
// validate hosts options
if err := validateHostsOptions(c); err != nil {
return err
@@ -126,3 +131,20 @@ func ValidateHostCount(c *Cluster) error {
}
return nil
}
+
+func validateDuplicateNodes(c *Cluster) error {
+ for i := range c.Nodes {
+ for j := range c.Nodes {
+ if i == j {
+ continue
+ }
+ if c.Nodes[i].Address == c.Nodes[j].Address {
+ return fmt.Errorf("Cluster can't have duplicate node: %s", c.Nodes[i].Address)
+ }
+ if c.Nodes[i].HostnameOverride == c.Nodes[j].HostnameOverride {
+ return fmt.Errorf("Cluster can't have duplicate node: %s", c.Nodes[i].HostnameOverride)
+ }
+ }
+ }
+ return nil
+}
