Search in sources :

Example 11 with OpenShiftEnvironment

use of org.eclipse.che.workspace.infrastructure.openshift.environment.OpenShiftEnvironment in project devspaces-images by redhat-developer.

the class OpenShiftPreviewUrlExposerTest method shouldDoNothingWhenNoCommandWithPreviewUrlDefined.

@Test
public void shouldDoNothingWhenNoCommandWithPreviewUrlDefined() throws InternalInfrastructureException {
    CommandImpl command = new CommandImpl("a", "a", "a");
    OpenShiftEnvironment env = OpenShiftEnvironment.builder().setCommands(singletonList(new CommandImpl(command))).build();
    previewUrlEndpointsProvisioner.expose(env);
    assertEquals(env.getCommands().get(0), command);
    assertTrue(env.getServices().isEmpty());
    assertTrue(env.getRoutes().isEmpty());
}
Also used : CommandImpl(org.eclipse.che.api.workspace.server.model.impl.CommandImpl) OpenShiftEnvironment(org.eclipse.che.workspace.infrastructure.openshift.environment.OpenShiftEnvironment) Test(org.testng.annotations.Test)

Example 12 with OpenShiftEnvironment

use of org.eclipse.che.workspace.infrastructure.openshift.environment.OpenShiftEnvironment in project devspaces-images by redhat-developer.

the class OpenShiftInternalRuntime method startMachines.

@Override
@Traced
protected void startMachines() throws InfrastructureException {
    OpenShiftEnvironment osEnv = getContext().getEnvironment();
    String workspaceId = getContext().getIdentity().getWorkspaceId();
    createSecrets(osEnv, workspaceId);
    List<ConfigMap> createdConfigMaps = createConfigMaps(osEnv, getContext().getIdentity());
    List<Service> createdServices = createServices(osEnv, workspaceId);
    List<Route> createdRoutes = createRoutes(osEnv, workspaceId);
    listenEvents();
    doStartMachine(serverResolverFactory.create(createdServices, createdRoutes, createdConfigMaps));
}
Also used : OpenShiftEnvironment(org.eclipse.che.workspace.infrastructure.openshift.environment.OpenShiftEnvironment) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) Service(io.fabric8.kubernetes.api.model.Service) Route(io.fabric8.openshift.api.model.Route) Traced(org.eclipse.che.commons.annotation.Traced)

Example 13 with OpenShiftEnvironment

use of org.eclipse.che.workspace.infrastructure.openshift.environment.OpenShiftEnvironment 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>>() {
        });
    }
}
Also used : PassThroughProxySecureServerExposer(org.eclipse.che.workspace.infrastructure.kubernetes.server.secure.jwtproxy.PassThroughProxySecureServerExposer) SecureServerExposer(org.eclipse.che.workspace.infrastructure.kubernetes.server.secure.SecureServerExposer) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) PassThroughProxySecureServerExposerFactory(org.eclipse.che.workspace.infrastructure.kubernetes.server.secure.jwtproxy.factory.PassThroughProxySecureServerExposerFactory) OpenShiftEnvironment(org.eclipse.che.workspace.infrastructure.openshift.environment.OpenShiftEnvironment) TypeLiteral(com.google.inject.TypeLiteral) JwtProxySecureServerExposerFactory(org.eclipse.che.workspace.infrastructure.kubernetes.server.secure.jwtproxy.factory.JwtProxySecureServerExposerFactory) PassThroughProxySecureServerExposerFactory(org.eclipse.che.workspace.infrastructure.kubernetes.server.secure.jwtproxy.factory.PassThroughProxySecureServerExposerFactory) SecureServerExposerFactory(org.eclipse.che.workspace.infrastructure.kubernetes.server.secure.SecureServerExposerFactory) PassThroughProxySecureServerExposer(org.eclipse.che.workspace.infrastructure.kubernetes.server.secure.jwtproxy.PassThroughProxySecureServerExposer) KubernetesEnvironment(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment)

Example 14 with OpenShiftEnvironment

use of org.eclipse.che.workspace.infrastructure.openshift.environment.OpenShiftEnvironment in project che-server by eclipse-che.

the class OpenShiftPreviewUrlCommandProvisionerTest method shouldUpdateCommandWhenServiceAndIngressFound.

@Test
public void shouldUpdateCommandWhenServiceAndIngressFound() throws InfrastructureException {
    int port = 8080;
    List<CommandImpl> commands = Collections.singletonList(new CommandImpl("a", "a", "a", new PreviewUrlImpl(port, null), Collections.emptyMap()));
    OpenShiftEnvironment env = OpenShiftEnvironment.builder().setCommands(new ArrayList<>(commands)).build();
    Mockito.when(mockProject.services()).thenReturn(mockServices);
    Service service = new Service();
    ObjectMeta metadata = new ObjectMeta();
    metadata.setName("servicename");
    service.setMetadata(metadata);
    ServiceSpec spec = new ServiceSpec();
    spec.setPorts(Collections.singletonList(new ServicePort(null, "8080", null, port, "TCP", new IntOrString(port))));
    service.setSpec(spec);
    Mockito.when(mockServices.get()).thenReturn(Collections.singletonList(service));
    Route route = new Route();
    RouteSpec routeSpec = new RouteSpec();
    routeSpec.setPort(new RoutePort(new IntOrString("8080")));
    routeSpec.setTo(new RouteTargetReference("a", "servicename", 1));
    routeSpec.setHost("testhost");
    route.setSpec(routeSpec);
    Mockito.when(mockProject.routes()).thenReturn(mockRoutes);
    Mockito.when(mockRoutes.get()).thenReturn(Collections.singletonList(route));
    previewUrlCommandProvisioner.provision(env, mockProject);
    assertTrue(env.getCommands().get(0).getAttributes().containsKey("previewUrl"));
    assertEquals(env.getCommands().get(0).getAttributes().get("previewUrl"), "testhost");
    assertTrue(env.getWarnings().isEmpty());
}
Also used : CommandImpl(org.eclipse.che.api.workspace.server.model.impl.CommandImpl) ObjectMeta(io.fabric8.kubernetes.api.model.ObjectMeta) ServicePort(io.fabric8.kubernetes.api.model.ServicePort) RouteTargetReference(io.fabric8.openshift.api.model.RouteTargetReference) RoutePort(io.fabric8.openshift.api.model.RoutePort) PreviewUrlImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.PreviewUrlImpl) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) ArrayList(java.util.ArrayList) ServiceSpec(io.fabric8.kubernetes.api.model.ServiceSpec) Service(io.fabric8.kubernetes.api.model.Service) RouteSpec(io.fabric8.openshift.api.model.RouteSpec) OpenShiftEnvironment(org.eclipse.che.workspace.infrastructure.openshift.environment.OpenShiftEnvironment) Route(io.fabric8.openshift.api.model.Route) Test(org.testng.annotations.Test)

Example 15 with OpenShiftEnvironment

use of org.eclipse.che.workspace.infrastructure.openshift.environment.OpenShiftEnvironment in project che-server by eclipse-che.

the class OpenShiftPreviewUrlCommandProvisionerTest method shouldDoNothingWhenCommandsWithoutPreviewUrlDefined.

@Test
public void shouldDoNothingWhenCommandsWithoutPreviewUrlDefined() throws InfrastructureException {
    List<CommandImpl> commands = Arrays.asList(new CommandImpl("a", "a", "a"), new CommandImpl("b", "b", "b"));
    OpenShiftEnvironment env = OpenShiftEnvironment.builder().setCommands(new ArrayList<>(commands)).build();
    Mockito.when(mockProject.routes()).thenReturn(mockRoutes);
    Mockito.when(mockProject.services()).thenReturn(mockServices);
    previewUrlCommandProvisioner.provision(env, mockProject);
    assertTrue(commands.containsAll(env.getCommands()));
    assertTrue(env.getCommands().containsAll(commands));
    assertTrue(env.getWarnings().isEmpty());
}
Also used : CommandImpl(org.eclipse.che.api.workspace.server.model.impl.CommandImpl) OpenShiftEnvironment(org.eclipse.che.workspace.infrastructure.openshift.environment.OpenShiftEnvironment) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test)

Aggregations

OpenShiftEnvironment (org.eclipse.che.workspace.infrastructure.openshift.environment.OpenShiftEnvironment)28 Test (org.testng.annotations.Test)22 CommandImpl (org.eclipse.che.api.workspace.server.model.impl.CommandImpl)16 ServicePort (io.fabric8.kubernetes.api.model.ServicePort)14 Route (io.fabric8.openshift.api.model.Route)14 Service (io.fabric8.kubernetes.api.model.Service)12 PreviewUrlImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.PreviewUrlImpl)12 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)10 HashMap (java.util.HashMap)10 ServiceSpec (io.fabric8.kubernetes.api.model.ServiceSpec)8 ArrayList (java.util.ArrayList)8 ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)6 TypeLiteral (com.google.inject.TypeLiteral)4 FactoryModuleBuilder (com.google.inject.assistedinject.FactoryModuleBuilder)4 RoutePort (io.fabric8.openshift.api.model.RoutePort)4 RouteSpec (io.fabric8.openshift.api.model.RouteSpec)4 RouteTargetReference (io.fabric8.openshift.api.model.RouteTargetReference)4 ServerConfig (org.eclipse.che.api.core.model.workspace.config.ServerConfig)4 ServerConfigImpl (org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl)4 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)2