Browse code

disallow empty static node names

deads2k authored on 2015/04/16 21:43:16
Showing 2 changed files
... ...
@@ -1,6 +1,7 @@
1 1
 package validation
2 2
 
3 3
 import (
4
+	"fmt"
4 5
 	"net"
5 6
 	"net/url"
6 7
 	"strings"
... ...
@@ -144,6 +145,12 @@ func ValidateKubernetesMasterConfig(config *api.KubernetesMasterConfig) fielderr
144 144
 		allErrs = append(allErrs, ValidateFile(config.SchedulerConfigFile, "schedulerConfigFile")...)
145 145
 	}
146 146
 
147
+	for i, nodeName := range config.StaticNodeNames {
148
+		if len(nodeName) == 0 {
149
+			allErrs = append(allErrs, fielderrors.NewFieldInvalid(fmt.Sprintf("staticNodeName[%d]", i), nodeName, "may not be empty"))
150
+		}
151
+	}
152
+
147 153
 	return allErrs
148 154
 }
149 155
 
... ...
@@ -338,10 +338,13 @@ func (args MasterArgs) BuildSerializeableKubeMasterConfig() (*configapi.Kubernet
338 338
 		masterIP = ip.String()
339 339
 	}
340 340
 
341
+	staticNodeList := util.NewStringSet(args.NodeList...)
342
+	staticNodeList.Delete("")
343
+
341 344
 	config := &configapi.KubernetesMasterConfig{
342 345
 		MasterIP:            masterIP,
343 346
 		ServicesSubnet:      servicesSubnet.String(),
344
-		StaticNodeNames:     args.NodeList,
347
+		StaticNodeNames:     staticNodeList.List(),
345 348
 		SchedulerConfigFile: args.SchedulerConfigFile,
346 349
 	}
347 350