Search in sources :

Example 1 with ServerConfigImpl

use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.

the class GatewayTlsProvisioner method useSecureProtocolForGatewayConfigMap.

private void useSecureProtocolForGatewayConfigMap(ConfigMap configMap) throws InfrastructureException {
    Map<String, ServerConfigImpl> servers = Annotations.newDeserializer(configMap.getMetadata().getAnnotations()).servers();
    if (servers.isEmpty()) {
        return;
    }
    if (servers.size() != 1) {
        throw new InfrastructureException("Expected exactly 1 server in Gateway configuration ConfigMap '" + configMap.getMetadata().getName() + "'. This is a bug, please report.");
    }
    Entry<String, ServerConfigImpl> serverConfigEntry = servers.entrySet().iterator().next();
    ServerConfigImpl serverConfig = serverConfigEntry.getValue();
    serverConfig.setProtocol(getSecureProtocol(serverConfig.getProtocol()));
    configMap.getMetadata().getAnnotations().putAll(Annotations.newSerializer().server(serverConfigEntry.getKey(), serverConfig).annotations());
}
Also used : ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) InfrastructureException(org.eclipse.che.api.workspace.server.spi.InfrastructureException)

Example 2 with ServerConfigImpl

use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.

the class RouteServerResolverTest method testResolvingServersWhenThereIsMatchedRouteForMachineAndServerPathIsNull.

@Test
public void testResolvingServersWhenThereIsMatchedRouteForMachineAndServerPathIsNull() {
    Route route = createRoute("matched", "machine", singletonMap("http-server", new ServerConfigImpl("3054", "http", null, ATTRIBUTES_MAP)));
    RouteServerResolver serverResolver = new RouteServerResolver(emptyList(), singletonList(route));
    Map<String, ServerImpl> resolved = serverResolver.resolve("machine");
    assertEquals(resolved.size(), 1);
    assertEquals(resolved.get("http-server"), new ServerImpl().withUrl("http://localhost").withStatus(UNKNOWN).withAttributes(defaultAttributeAnd(Constants.SERVER_PORT_ATTRIBUTE, "3054", ServerConfig.ENDPOINT_ORIGIN, "/")));
}
Also used : ServerImpl(org.eclipse.che.api.workspace.server.model.impl.ServerImpl) RouteServerResolver(org.eclipse.che.workspace.infrastructure.openshift.server.RouteServerResolver) ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) Route(io.fabric8.openshift.api.model.Route) Test(org.testng.annotations.Test)

Example 3 with ServerConfigImpl

use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.

the class RouteServerResolverTest method testResolvingInternalServersWithPortWithTransportProtocol.

@Test
public void testResolvingInternalServersWithPortWithTransportProtocol() {
    Service service = createService("service11", "machine", CONTAINER_PORT, singletonMap("http-server", new ServerConfigImpl("3054/udp", "xxx", "api", ATTRIBUTES_MAP)));
    Route route = createRoute("matched", "machine", null);
    RouteServerResolver serverResolver = new RouteServerResolver(singletonList(service), singletonList(route));
    Map<String, ServerImpl> resolved = serverResolver.resolve("machine");
    assertEquals(resolved.size(), 1);
    assertEquals(resolved.get("http-server"), new ServerImpl().withUrl("xxx://service11:3054/api").withStatus(UNKNOWN).withAttributes(defaultAttributeAnd(Constants.SERVER_PORT_ATTRIBUTE, "3054", ServerConfig.ENDPOINT_ORIGIN, "/")));
}
Also used : ServerImpl(org.eclipse.che.api.workspace.server.model.impl.ServerImpl) RouteServerResolver(org.eclipse.che.workspace.infrastructure.openshift.server.RouteServerResolver) Service(io.fabric8.kubernetes.api.model.Service) ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) Route(io.fabric8.openshift.api.model.Route) Test(org.testng.annotations.Test)

Example 4 with ServerConfigImpl

use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.

the class RouteServerResolverTest method testResolvingServersWhenThereIsMatchedRouteForMachineAndServerPathIsRelative.

@Test
public void testResolvingServersWhenThereIsMatchedRouteForMachineAndServerPathIsRelative() {
    Route route = createRoute("matched", "machine", singletonMap("http-server", new ServerConfigImpl("3054", "http", "api", ATTRIBUTES_MAP)));
    RouteServerResolver serverResolver = new RouteServerResolver(emptyList(), singletonList(route));
    Map<String, ServerImpl> resolved = serverResolver.resolve("machine");
    assertEquals(resolved.size(), 1);
    assertEquals(resolved.get("http-server"), new ServerImpl().withUrl("http://localhost/api").withStatus(UNKNOWN).withAttributes(defaultAttributeAnd(Constants.SERVER_PORT_ATTRIBUTE, "3054", ServerConfig.ENDPOINT_ORIGIN, "/")));
}
Also used : ServerImpl(org.eclipse.che.api.workspace.server.model.impl.ServerImpl) RouteServerResolver(org.eclipse.che.workspace.infrastructure.openshift.server.RouteServerResolver) ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) Route(io.fabric8.openshift.api.model.Route) Test(org.testng.annotations.Test)

Example 5 with ServerConfigImpl

use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.

the class RouteServerResolverTest method testResolvingServersWhenThereIsNoTheCorrespondingServiceAndRouteForTheSpecifiedMachine.

@Test
public void testResolvingServersWhenThereIsNoTheCorrespondingServiceAndRouteForTheSpecifiedMachine() {
    // given
    Service nonMatchedByPodService = createService("nonMatched", "foreignMachine", CONTAINER_PORT, null);
    Route route = createRoute("nonMatched", "foreignMachine", ImmutableMap.of("http-server", new ServerConfigImpl("3054", "http", "/api", ATTRIBUTES_MAP)));
    RouteServerResolver serverResolver = new RouteServerResolver(singletonList(nonMatchedByPodService), singletonList(route));
    // when
    Map<String, ServerImpl> resolved = serverResolver.resolve("machine");
    // then
    assertTrue(resolved.isEmpty());
}
Also used : ServerImpl(org.eclipse.che.api.workspace.server.model.impl.ServerImpl) RouteServerResolver(org.eclipse.che.workspace.infrastructure.openshift.server.RouteServerResolver) Service(io.fabric8.kubernetes.api.model.Service) ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) Route(io.fabric8.openshift.api.model.Route) Test(org.testng.annotations.Test)

Aggregations

ServerConfigImpl (org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl)159 Test (org.testng.annotations.Test)130 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)58 ServerConfig (org.eclipse.che.api.core.model.workspace.config.ServerConfig)38 ServicePort (io.fabric8.kubernetes.api.model.ServicePort)34 ServerImpl (org.eclipse.che.api.workspace.server.model.impl.ServerImpl)32 Route (io.fabric8.openshift.api.model.Route)22 MachineConfigImpl (org.eclipse.che.api.workspace.server.model.impl.MachineConfigImpl)22 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)21 HashMap (java.util.HashMap)21 Annotations (org.eclipse.che.workspace.infrastructure.kubernetes.Annotations)17 Service (io.fabric8.kubernetes.api.model.Service)16 Ingress (io.fabric8.kubernetes.api.model.networking.v1.Ingress)16 RouteServerResolver (org.eclipse.che.workspace.infrastructure.openshift.server.RouteServerResolver)16 ConfigMapBuilder (io.fabric8.kubernetes.api.model.ConfigMapBuilder)14 EnvironmentImpl (org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl)14 IngressServerResolver (org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.IngressServerResolver)14 ServerResolver (org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.ServerResolver)14 RecipeImpl (org.eclipse.che.api.workspace.server.model.impl.RecipeImpl)12 ServicePortBuilder (io.fabric8.kubernetes.api.model.ServicePortBuilder)10