use of org.eclipse.che.workspace.infrastructure.kubernetes.server.secure.SecureServerExposer in project che-server by eclipse-che.
the class WsMasterModule method installDefaultSecureServerExposer.
private void installDefaultSecureServerExposer(String infrastructure) {
if (KubernetesInfrastructure.NAME.equals(infrastructure)) {
MapBinder<String, SecureServerExposerFactory<KubernetesEnvironment>> secureServerExposerFactories = MapBinder.newMapBinder(binder(), new TypeLiteral<>() {
}, new TypeLiteral<>() {
});
install(new FactoryModuleBuilder().implement(new TypeLiteral<SecureServerExposer<KubernetesEnvironment>>() {
}, new TypeLiteral<PassThroughProxySecureServerExposer<KubernetesEnvironment>>() {
}).build(new TypeLiteral<PassThroughProxySecureServerExposerFactory<KubernetesEnvironment>>() {
}));
secureServerExposerFactories.addBinding("default").to(new TypeLiteral<PassThroughProxySecureServerExposerFactory<KubernetesEnvironment>>() {
});
} else {
MapBinder<String, SecureServerExposerFactory<OpenShiftEnvironment>> secureServerExposerFactories = MapBinder.newMapBinder(binder(), new TypeLiteral<>() {
}, new TypeLiteral<>() {
});
install(new FactoryModuleBuilder().implement(new TypeLiteral<SecureServerExposer<OpenShiftEnvironment>>() {
}, new TypeLiteral<PassThroughProxySecureServerExposer<OpenShiftEnvironment>>() {
}).build(new TypeLiteral<PassThroughProxySecureServerExposerFactory<OpenShiftEnvironment>>() {
}));
secureServerExposerFactories.addBinding("default").to(new TypeLiteral<PassThroughProxySecureServerExposerFactory<OpenShiftEnvironment>>() {
});
}
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.server.secure.SecureServerExposer in project devspaces-images by redhat-developer.
the class WsMasterModule method installDefaultSecureServerExposer.
private void installDefaultSecureServerExposer(String infrastructure) {
if (KubernetesInfrastructure.NAME.equals(infrastructure)) {
MapBinder<String, SecureServerExposerFactory<KubernetesEnvironment>> secureServerExposerFactories = MapBinder.newMapBinder(binder(), new TypeLiteral<>() {
}, new TypeLiteral<>() {
});
install(new FactoryModuleBuilder().implement(new TypeLiteral<SecureServerExposer<KubernetesEnvironment>>() {
}, new TypeLiteral<PassThroughProxySecureServerExposer<KubernetesEnvironment>>() {
}).build(new TypeLiteral<PassThroughProxySecureServerExposerFactory<KubernetesEnvironment>>() {
}));
secureServerExposerFactories.addBinding("default").to(new TypeLiteral<PassThroughProxySecureServerExposerFactory<KubernetesEnvironment>>() {
});
} else {
MapBinder<String, SecureServerExposerFactory<OpenShiftEnvironment>> secureServerExposerFactories = MapBinder.newMapBinder(binder(), new TypeLiteral<>() {
}, new TypeLiteral<>() {
});
install(new FactoryModuleBuilder().implement(new TypeLiteral<SecureServerExposer<OpenShiftEnvironment>>() {
}, new TypeLiteral<PassThroughProxySecureServerExposer<OpenShiftEnvironment>>() {
}).build(new TypeLiteral<PassThroughProxySecureServerExposerFactory<OpenShiftEnvironment>>() {
}));
secureServerExposerFactories.addBinding("default").to(new TypeLiteral<PassThroughProxySecureServerExposerFactory<OpenShiftEnvironment>>() {
});
}
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.server.secure.SecureServerExposer in project che-server by eclipse-che.
the class KubernetesServerExposerTest method assertThatSecureServerIsExposed.
@SuppressWarnings("SameParameterValue")
private void assertThatSecureServerIsExposed(String machineName, String portProtocol, Integer port, String serverName, ServerConfig serverConfig) throws Exception {
// then
assertThatContainerPortIsExposed(portProtocol, port);
// ensure that service is created
Service service = findContainerRelatedService();
assertNotNull(service);
// ensure that no service port is exposed
assertTrue(service.getSpec().getPorts().stream().noneMatch(p -> p.getTargetPort().getIntVal().equals(port)));
ServicePort servicePort = new ServicePortBuilder().withName("server-" + port).withPort(port).withProtocol(portProtocol.toUpperCase()).withNewTargetPort(port).build();
verify(secureServerExposer).expose(eq(kubernetesEnvironment), any(), eq(machineName), // no service exists for the backed server
isNull(), // a non-unique server
isNull(), eq(servicePort), eq(ImmutableMap.of(serverName, serverConfig)));
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.server.secure.SecureServerExposer in project devspaces-images by redhat-developer.
the class KubernetesServerExposerTest method assertThatSecureServerIsExposed.
@SuppressWarnings("SameParameterValue")
private void assertThatSecureServerIsExposed(String machineName, String portProtocol, Integer port, String serverName, ServerConfig serverConfig) throws Exception {
// then
assertThatContainerPortIsExposed(portProtocol, port);
// ensure that service is created
Service service = findContainerRelatedService();
assertNotNull(service);
// ensure that no service port is exposed
assertTrue(service.getSpec().getPorts().stream().noneMatch(p -> p.getTargetPort().getIntVal().equals(port)));
ServicePort servicePort = new ServicePortBuilder().withName("server-" + port).withPort(port).withProtocol(portProtocol.toUpperCase()).withNewTargetPort(port).build();
verify(secureServerExposer).expose(eq(kubernetesEnvironment), any(), eq(machineName), // no service exists for the backed server
isNull(), // a non-unique server
isNull(), eq(servicePort), eq(ImmutableMap.of(serverName, serverConfig)));
}
Aggregations