Merge pull request #1238 from brendandburns/service

Add an earlier check and error for names that won't work for services.
pull/6/head
bgrant0607 2014-09-10 11:41:57 -07:00
commit fb4199cba7
1 changed files with 4 additions and 0 deletions

View File

@ -29,6 +29,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/wait"
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
"github.com/golang/glog"
@ -174,6 +175,9 @@ func portsFromString(spec string) []api.Port {
// RunController creates a new replication controller named 'name' which creates 'replicas' pods running 'image'.
func RunController(image, name string, replicas int, client client.Interface, portSpec string, servicePort int) error {
if servicePort > 0 && !util.IsDNSLabel(name) {
return fmt.Errorf("Service creation requested, but an invalid name for a service was provided (%s). Service names must be valid DNS labels.", name)
}
controller := &api.ReplicationController{
JSONBase: api.JSONBase{
ID: name,