forked from LaconicNetwork/kompose
implement expose service, add tests, fix #140
Implements a kompose specific docker compose label "kompose.service.expose" which can be used to expose the specified services externally. The accepted values are of type string. If the value is set to "true", the provider sets the endpoint automatically, and for any other value, the value is set as the hostname. If multiple ports are defined in a service, the first one is chosen to be the exposed. Unit tests, functional tests, glide updates and docs have also been added in this commit for the related feature.
This commit is contained in:
@@ -61,3 +61,34 @@ func TestInitDeploymentConfig(t *testing.T) {
|
||||
t.Errorf("Expected myfoobarname for name, actual %s", spec.Spec.Triggers[1].ImageChangeParams.ContainerNames[0])
|
||||
}
|
||||
}
|
||||
|
||||
func TestKomposeConvertRoute(t *testing.T) {
|
||||
|
||||
o := OpenShift{}
|
||||
name := "app"
|
||||
sc := newServiceConfig()
|
||||
sc.ExposeService = "true"
|
||||
var port int32 = 5555
|
||||
route := o.initRoute(name, sc, port)
|
||||
|
||||
if route.ObjectMeta.Name != name {
|
||||
t.Errorf("Expected %s for name, actual %s", name, route.ObjectMeta.Name)
|
||||
}
|
||||
if route.Spec.To.Name != name {
|
||||
t.Errorf("Expected %s for name, actual %s", name, route.Spec.To.Name)
|
||||
}
|
||||
if route.Spec.Port.TargetPort.IntVal != port {
|
||||
t.Errorf("Expected %d for port, actual %d", port, route.Spec.Port.TargetPort.IntVal)
|
||||
}
|
||||
if route.Spec.Host != "" {
|
||||
t.Errorf("Expected Spec.Host to not be set, got %s instead", route.Spec.Host)
|
||||
}
|
||||
|
||||
sc.ExposeService = "example.com"
|
||||
route = o.initRoute(name, sc, port)
|
||||
|
||||
if route.Spec.Host != sc.ExposeService {
|
||||
t.Errorf("Expected %s for Spec.Host, actual %s", sc.ExposeService, route.Spec.Host)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user