Add ServiceType = NodePort; wire everything up

This commit is contained in:
Justin Santa Barbara
2015-05-20 11:59:34 -04:00
parent 03cdc077c3
commit 7346cc8042
14 changed files with 338 additions and 38 deletions

View File

@@ -180,6 +180,67 @@ func TestGenerateService(t *testing.T) {
},
},
},
{
params: map[string]string{
"selector": "foo=bar,baz=blah",
"name": "test",
"port": "80",
"protocol": "UDP",
"container-port": "foobar",
"type": string(api.ServiceTypeNodePort),
},
expected: api.Service{
ObjectMeta: api.ObjectMeta{
Name: "test",
},
Spec: api.ServiceSpec{
Selector: map[string]string{
"foo": "bar",
"baz": "blah",
},
Ports: []api.ServicePort{
{
Name: "default",
Port: 80,
Protocol: "UDP",
TargetPort: util.NewIntOrStringFromString("foobar"),
},
},
Type: api.ServiceTypeNodePort,
},
},
},
{
params: map[string]string{
"selector": "foo=bar,baz=blah",
"name": "test",
"port": "80",
"protocol": "UDP",
"container-port": "foobar",
"create-external-load-balancer": "true", // ignored when type is present
"type": string(api.ServiceTypeNodePort),
},
expected: api.Service{
ObjectMeta: api.ObjectMeta{
Name: "test",
},
Spec: api.ServiceSpec{
Selector: map[string]string{
"foo": "bar",
"baz": "blah",
},
Ports: []api.ServicePort{
{
Name: "default",
Port: 80,
Protocol: "UDP",
TargetPort: util.NewIntOrStringFromString("foobar"),
},
},
Type: api.ServiceTypeNodePort,
},
},
},
}
generator := ServiceGenerator{}
for _, test := range tests {