Allow no ports when exposing headless service

This commit is contained in:
Michael Fraenkel
2016-09-15 14:56:49 -04:00
parent 39e3c986cc
commit a3537a02fe
4 changed files with 91 additions and 33 deletions

View File

@@ -262,6 +262,32 @@ func TestRunExposeService(t *testing.T) {
expected: "service \"foo\" exposed",
status: 200,
},
{
name: "expose-headless-service-no-port",
args: []string{"service", "baz"},
ns: "test",
calls: map[string]string{
"GET": "/namespaces/test/services/baz",
"POST": "/namespaces/test/services",
},
input: &api.Service{
ObjectMeta: api.ObjectMeta{Name: "baz", Namespace: "test", ResourceVersion: "12"},
Spec: api.ServiceSpec{
Selector: map[string]string{"app": "go"},
},
},
flags: map[string]string{"selector": "func=stream", "name": "foo", "labels": "svc=test", "cluster-ip": "None", "dry-run": "true"},
output: &api.Service{
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "", Labels: map[string]string{"svc": "test"}},
Spec: api.ServiceSpec{
Ports: []api.ServicePort{},
Selector: map[string]string{"func": "stream"},
ClusterIP: api.ClusterIPNone,
},
},
expected: "service \"foo\" exposed",
status: 200,
},
{
name: "expose-from-file",
args: []string{},