forked from LaconicNetwork/kompose
Fix invalid port name with uppercase characters (#1029)
* Fix invalid port name with uppercase characters Signed-off-by: Li Yi <denverdino@gmail.com>
This commit is contained in:
parent
fa706f2f1c
commit
6eb1aed7ab
@ -367,7 +367,7 @@ func (k *Kubernetes) ConfigServicePorts(name string, service kobject.ServiceConf
|
||||
if service.ServiceType == string(api.ServiceTypeLoadBalancer) {
|
||||
log.Fatalf("Service %s of type LoadBalancer cannot use TCP and UDP for the same port", name)
|
||||
}
|
||||
name = fmt.Sprintf("%s-%s", name, port.Protocol)
|
||||
name = fmt.Sprintf("%s-%s", name, strings.ToLower(string(port.Protocol)))
|
||||
}
|
||||
|
||||
servicePort = api.ServicePort{
|
||||
|
||||
@ -29,6 +29,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func newServiceConfig() kobject.ServiceConfig {
|
||||
@ -36,7 +37,7 @@ func newServiceConfig() kobject.ServiceConfig {
|
||||
ContainerName: "name",
|
||||
Image: "image",
|
||||
Environment: []kobject.EnvVar{kobject.EnvVar{Name: "env", Value: "value"}},
|
||||
Port: []kobject.Ports{kobject.Ports{HostPort: 123, ContainerPort: 456}},
|
||||
Port: []kobject.Ports{kobject.Ports{HostPort: 123, ContainerPort: 456}, kobject.Ports{HostPort: 123, ContainerPort: 456, Protocol: api.ProtocolUDP}},
|
||||
Command: []string{"cmd"},
|
||||
WorkingDir: "dir",
|
||||
Args: []string{"arg1", "arg2"},
|
||||
@ -189,6 +190,13 @@ func checkService(config kobject.ServiceConfig, svc *api.Service, expectedLabels
|
||||
if !equalStringMaps(expectedLabels, svc.Spec.Selector) {
|
||||
return fmt.Errorf("Found unexpected selector: %#v vs. %#v", expectedLabels, svc.Spec.Selector)
|
||||
}
|
||||
for _, port := range svc.Spec.Ports {
|
||||
name := port.Name
|
||||
expectedName := strings.ToLower(name)
|
||||
if expectedName != name {
|
||||
return fmt.Errorf("Found unexpected port name: %#v vs. %#v", expectedName, name)
|
||||
}
|
||||
}
|
||||
// TODO: finish this
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
"targetPort": 9001
|
||||
},
|
||||
{
|
||||
"name": "80-TCP",
|
||||
"name": "80-tcp",
|
||||
"port": 80,
|
||||
"targetPort": 9001
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
"targetPort": 9001
|
||||
},
|
||||
{
|
||||
"name": "80-TCP",
|
||||
"name": "80-tcp",
|
||||
"port": 80,
|
||||
"targetPort": 9001
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
"targetPort": 6379
|
||||
},
|
||||
{
|
||||
"name": "6379-UDP",
|
||||
"name": "6379-udp",
|
||||
"protocol": "UDP",
|
||||
"port": 6379,
|
||||
"targetPort": 6379
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
"targetPort": 6379
|
||||
},
|
||||
{
|
||||
"name": "6379-UDP",
|
||||
"name": "6379-udp",
|
||||
"protocol": "UDP",
|
||||
"port": 6379,
|
||||
"targetPort": 6379
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
"targetPort": 3000
|
||||
},
|
||||
{
|
||||
"name": "3000-TCP",
|
||||
"name": "3000-tcp",
|
||||
"port": 3000,
|
||||
"targetPort": 3000
|
||||
},
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
"targetPort": 3000
|
||||
},
|
||||
{
|
||||
"name": "3000-TCP",
|
||||
"name": "3000-tcp",
|
||||
"port": 3000,
|
||||
"targetPort": 3000
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user