From 61e2780337600eb3430f49c6154cb13745a05e9f Mon Sep 17 00:00:00 2001 From: Mykhailo Kuznietsov Date: Wed, 11 Apr 2018 10:17:45 +0300 Subject: [PATCH 01/17] Provide internal and external api url into workspaces --- .../che/api/deploy/WsMasterModule.java | 4 ++ dockerfiles/init/manifests/che.env | 3 +- dockerfiles/init/manifests/che.pp | 2 + .../init/modules/che/templates/che.env.erb | 4 ++ .../docker/DockerCheApiEnvVarProvider.java | 4 +- .../DockerCheApiExternalEnvVarProvider.java | 38 ++++++++++++++++ .../DockerCheApiInternalEnvVarProvider.java | 45 +++++++++++++++++++ .../docker/DockerInfraModule.java | 4 ++ .../kubernetes/KubernetesInfraModule.java | 6 +-- ...bernetesCheApiInternalEnvVarProvider.java} | 6 +-- ...etesCheApiInternalEnvVarProviderTest.java} | 25 +++++------ .../openshift/OpenShiftInfraModule.java | 6 +-- .../provision/env/CheApiEnvVarProvider.java | 2 +- .../env/CheApiExternalEnvVarProvider.java | 30 +++++++++++++ .../env/CheApiInternalEnvVarProvider.java | 30 +++++++++++++ 15 files changed, 183 insertions(+), 26 deletions(-) create mode 100644 infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiExternalEnvVarProvider.java create mode 100644 infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiInternalEnvVarProvider.java rename infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/{KubernetesCheApiEnvVarProvider.java => KubernetesCheApiInternalEnvVarProvider.java} (83%) rename infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/{KubernetesCheApiEnvVarProviderTest.java => KubernetesCheApiInternalEnvVarProviderTest.java} (59%) create mode 100644 wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiExternalEnvVarProvider.java create mode 100644 wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiInternalEnvVarProvider.java diff --git a/assembly/assembly-wsmaster-war/src/main/java/org/eclipse/che/api/deploy/WsMasterModule.java b/assembly/assembly-wsmaster-war/src/main/java/org/eclipse/che/api/deploy/WsMasterModule.java index 6ba97761e0e..78e1da68d53 100644 --- a/assembly/assembly-wsmaster-war/src/main/java/org/eclipse/che/api/deploy/WsMasterModule.java +++ b/assembly/assembly-wsmaster-war/src/main/java/org/eclipse/che/api/deploy/WsMasterModule.java @@ -48,6 +48,8 @@ import org.eclipse.che.api.workspace.server.spi.provision.ProjectsVolumeForWsAgentProvisioner; import org.eclipse.che.api.workspace.server.spi.provision.env.AgentAuthEnableEnvVarProvider; import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiEnvVarProvider; +import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiExternalEnvVarProvider; +import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiInternalEnvVarProvider; import org.eclipse.che.api.workspace.server.spi.provision.env.EnvVarEnvironmentProvisioner; import org.eclipse.che.api.workspace.server.spi.provision.env.EnvVarProvider; import org.eclipse.che.api.workspace.server.spi.provision.env.JavaOptsEnvVariableProvider; @@ -149,6 +151,8 @@ protected void configure() { Multibinder envVarProviders = Multibinder.newSetBinder(binder(), EnvVarProvider.class); envVarProviders.addBinding().to(CheApiEnvVarProvider.class); + envVarProviders.addBinding().to(CheApiInternalEnvVarProvider.class); + envVarProviders.addBinding().to(CheApiExternalEnvVarProvider.class); envVarProviders.addBinding().to(MachineTokenEnvVarProvider.class); envVarProviders.addBinding().to(WorkspaceIdEnvVarProvider.class); diff --git a/dockerfiles/init/manifests/che.env b/dockerfiles/init/manifests/che.env index 69ee5243310..5dbb8441ab9 100644 --- a/dockerfiles/init/manifests/che.env +++ b/dockerfiles/init/manifests/che.env @@ -168,7 +168,7 @@ # # Browser --> Che Server # 1. Default is 'http://localhost:${SERVER_PORT}/api'. -# 2. Else use the value of CHE_API +# 2. Else use the value of CHE_API_EXTERNAL # # Che Server --> Docker Daemon Progression: # 1. Use the value of CHE_INFRA_DOCKER_DAEMON__URL @@ -198,6 +198,7 @@ # The location of the API end point where dashboard and IDE clients will look for # interacting with the Che server, which we also call the workspace master. #CHE_API=http://${CHE_HOST}:${CHE_PORT}/api + # Che Server default websocket endpoint. # Provides basic communication endpoint where clients can get/push statuses/output. #CHE_WEBSOCKET_ENDPOINT=ws://${CHE_HOST}:${CHE_PORT}/api/websocket diff --git a/dockerfiles/init/manifests/che.pp b/dockerfiles/init/manifests/che.pp index e615c10e4e3..7c317164fac 100644 --- a/dockerfiles/init/manifests/che.pp +++ b/dockerfiles/init/manifests/che.pp @@ -14,6 +14,8 @@ $docker_host = getValue("DOCKER_HOST","tcp://localhost:2375") $che_user = getValue("CHE_USER","root") $che_server_url = getValue("CHE_SERVER_URL", "${che_protocol}://${che_ip}:${che_port}") + $che_api_internal = getValue("CHE_API_INTERNAL", "${che_server_url}/api") + $che_api_external = getValue("CHE_API_EXTERNAL", "${che_server_url}/api") $che_master_container_ram = getValue("CHE_MASTER_CONTAINER_RAM", "750m") $che_docker_ip_external = getValue("CHE_DOCKER_IP_EXTERNAL","") diff --git a/dockerfiles/init/modules/che/templates/che.env.erb b/dockerfiles/init/modules/che/templates/che.env.erb index 08b962aa7f5..8f19a48c154 100644 --- a/dockerfiles/init/modules/che/templates/che.env.erb +++ b/dockerfiles/init/modules/che/templates/che.env.erb @@ -51,6 +51,10 @@ CHE_LOGS_DIR=/logs CHE_WORKSPACE_LOGS=/logs/machines CHE_TEMPLATE_STORAGE=/data/templates +CHE_API_EXTERNAL=<%= scope.lookupvar('che::che_api_external') %> +CHE_API_INTERNAL=<%= scope.lookupvar('che::che_api_internal') %> +CHE_API=<%= scope.lookupvar('che::che_api_internal') %> + <% if ! @che_http_proxy.empty? or ! @che_https_proxy.empty? -%> JAVA_HTTP_PROXY_SET=-Dhttp.proxySet=true diff --git a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiEnvVarProvider.java b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiEnvVarProvider.java index ce602380bc2..b143769e870 100644 --- a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiEnvVarProvider.java +++ b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiEnvVarProvider.java @@ -31,11 +31,11 @@ public class DockerCheApiEnvVarProvider implements CheApiEnvVarProvider { @Inject public DockerCheApiEnvVarProvider( @Named("che.infra.docker.master_api_endpoint") String apiEndpoint) { - String apiEndpointEnvVar = System.getenv(API_ENDPOINT_URL_VARIABLE); + String apiEndpointEnvVar = System.getenv(CHE_API_VARIABLE); if (Strings.isNullOrEmpty(apiEndpoint) && !Strings.isNullOrEmpty(apiEndpointEnvVar)) { apiEndpoint = apiEndpointEnvVar; } - apiEnvVar = Pair.of(API_ENDPOINT_URL_VARIABLE, apiEndpoint); + apiEnvVar = Pair.of(CHE_API_VARIABLE, apiEndpoint); } @Override diff --git a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiExternalEnvVarProvider.java b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiExternalEnvVarProvider.java new file mode 100644 index 00000000000..4d727e6f692 --- /dev/null +++ b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiExternalEnvVarProvider.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2012-2018 Red Hat, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.che.workspace.infrastructure.docker; + +import javax.inject.Inject; +import javax.inject.Singleton; +import org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity; +import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiExternalEnvVarProvider; +import org.eclipse.che.commons.lang.Pair; + +/** + * Provides env variable to docker machine with url of Che API. + * + * @author Alexander Garagatyi + */ +@Singleton +public class DockerCheApiExternalEnvVarProvider implements CheApiExternalEnvVarProvider { + + private final Pair apiEnvVar; + + @Inject + public DockerCheApiExternalEnvVarProvider() { + apiEnvVar = Pair.of(CHE_API_EXTERNAL_VARIABLE, System.getenv(CHE_API_EXTERNAL_VARIABLE)); + } + + @Override + public Pair get(RuntimeIdentity runtimeIdentity) { + return apiEnvVar; + } +} diff --git a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiInternalEnvVarProvider.java b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiInternalEnvVarProvider.java new file mode 100644 index 00000000000..7ff228d2358 --- /dev/null +++ b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiInternalEnvVarProvider.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2012-2018 Red Hat, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.che.workspace.infrastructure.docker; + +import com.google.common.base.Strings; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; +import org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity; +import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiInternalEnvVarProvider; +import org.eclipse.che.commons.lang.Pair; + +/** + * Provides env variable to docker machine with url of Che API. + * + * @author Alexander Garagatyi + */ +@Singleton +public class DockerCheApiInternalEnvVarProvider implements CheApiInternalEnvVarProvider { + + private Pair apiEnvVar; + + @Inject + public DockerCheApiInternalEnvVarProvider( + @Named("che.infra.docker.master_api_endpoint") String apiEndpoint) { + String apiEndpointEnvVar = System.getenv(CHE_API_INTERNAL_VARIABLE); + if (Strings.isNullOrEmpty(apiEndpoint) && !Strings.isNullOrEmpty(apiEndpointEnvVar)) { + apiEndpoint = apiEndpointEnvVar; + } + apiEnvVar = Pair.of(CHE_API_INTERNAL_VARIABLE, apiEndpoint); + } + + @Override + public Pair get(RuntimeIdentity runtimeIdentity) { + return new Pair<>(apiEnvVar.first, apiEnvVar.second); + } +} diff --git a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerInfraModule.java b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerInfraModule.java index d4e741134b1..2c3aa49cf98 100644 --- a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerInfraModule.java +++ b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerInfraModule.java @@ -17,6 +17,8 @@ import org.eclipse.che.api.workspace.server.URLRewriter; import org.eclipse.che.api.workspace.server.spi.RuntimeInfrastructure; import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiEnvVarProvider; +import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiExternalEnvVarProvider; +import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiInternalEnvVarProvider; import org.eclipse.che.infrastructure.docker.client.DockerRegistryDynamicAuthResolver; import org.eclipse.che.infrastructure.docker.client.NoOpDockerRegistryDynamicAuthResolverImpl; import org.eclipse.che.workspace.infrastructure.docker.bootstrap.DockerBootstrapperFactory; @@ -61,6 +63,8 @@ protected void configure() { install(new ContainerSystemSettingsProvisioningModule()); bind(CheApiEnvVarProvider.class).to(DockerCheApiEnvVarProvider.class); + bind(CheApiInternalEnvVarProvider.class).to(DockerCheApiInternalEnvVarProvider.class); + bind(CheApiExternalEnvVarProvider.class).to(DockerCheApiExternalEnvVarProvider.class); bind(RuntimeInfrastructure.class).to(DockerRuntimeInfrastructure.class); diff --git a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/KubernetesInfraModule.java b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/KubernetesInfraModule.java index 93db3b0a91f..b06f60922a4 100644 --- a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/KubernetesInfraModule.java +++ b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/KubernetesInfraModule.java @@ -24,7 +24,7 @@ import java.util.Map; import org.eclipse.che.api.workspace.server.spi.RuntimeInfrastructure; import org.eclipse.che.api.workspace.server.spi.environment.InternalEnvironmentFactory; -import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiEnvVarProvider; +import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiInternalEnvVarProvider; import org.eclipse.che.api.workspace.server.spi.provision.env.EnvVarProvider; import org.eclipse.che.workspace.infrastructure.docker.environment.dockerimage.DockerImageEnvironment; import org.eclipse.che.workspace.infrastructure.docker.environment.dockerimage.DockerImageEnvironmentFactory; @@ -37,7 +37,7 @@ import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.pvc.WorkspacePVCCleaner; import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.pvc.WorkspaceVolumeStrategyProvider; import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.pvc.WorkspaceVolumesStrategy; -import org.eclipse.che.workspace.infrastructure.kubernetes.provision.KubernetesCheApiEnvVarProvider; +import org.eclipse.che.workspace.infrastructure.kubernetes.provision.KubernetesCheApiInternalEnvVarProvider; import org.eclipse.che.workspace.infrastructure.kubernetes.provision.env.LogsRootEnvVariableProvider; import org.eclipse.che.workspace.infrastructure.kubernetes.server.DefaultHostIngressExternalServerExposer; import org.eclipse.che.workspace.infrastructure.kubernetes.server.ExternalServerExposerStrategy; @@ -65,7 +65,7 @@ protected void configure() { bind(WorkspacePVCCleaner.class).asEagerSingleton(); bind(RemoveNamespaceOnWorkspaceRemove.class).asEagerSingleton(); - bind(CheApiEnvVarProvider.class).to(KubernetesCheApiEnvVarProvider.class); + bind(CheApiInternalEnvVarProvider.class).to(KubernetesCheApiInternalEnvVarProvider.class); MapBinder volumesStrategies = MapBinder.newMapBinder(binder(), String.class, WorkspaceVolumesStrategy.class); diff --git a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProvider.java b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiInternalEnvVarProvider.java similarity index 83% rename from infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProvider.java rename to infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiInternalEnvVarProvider.java index cae2118e986..4b89f2fc559 100644 --- a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProvider.java +++ b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiInternalEnvVarProvider.java @@ -14,7 +14,7 @@ import javax.inject.Named; import org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity; import org.eclipse.che.api.workspace.server.spi.InfrastructureException; -import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiEnvVarProvider; +import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiInternalEnvVarProvider; import org.eclipse.che.commons.lang.Pair; /** @@ -22,12 +22,12 @@ * * @author Sergii Leshchenko */ -public class KubernetesCheApiEnvVarProvider implements CheApiEnvVarProvider { +public class KubernetesCheApiInternalEnvVarProvider implements CheApiInternalEnvVarProvider { private final String cheServerEndpoint; @Inject - public KubernetesCheApiEnvVarProvider(@Named("che.api") String cheServerEndpoint) { + public KubernetesCheApiInternalEnvVarProvider(@Named("che.api") String cheServerEndpoint) { this.cheServerEndpoint = cheServerEndpoint; } diff --git a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProviderTest.java b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiInternalEnvVarProviderTest.java similarity index 59% rename from infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProviderTest.java rename to infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiInternalEnvVarProviderTest.java index 9f41ba19aec..56dc63c8bd9 100644 --- a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProviderTest.java +++ b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiInternalEnvVarProviderTest.java @@ -10,38 +10,37 @@ */ package org.eclipse.che.workspace.infrastructure.kubernetes.provision; -import static org.testng.Assert.assertEquals; - -import org.eclipse.che.commons.lang.Pair; import org.mockito.testng.MockitoTestNGListener; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Listeners; import org.testng.annotations.Test; /** - * Tests {@link KubernetesCheApiEnvVarProvider}. + * Tests {@link KubernetesCheApiInternalEnvVarProvider}. * * @author Sergii Leshchenko */ @Listeners(MockitoTestNGListener.class) -public class KubernetesCheApiEnvVarProviderTest { +public class KubernetesCheApiInternalEnvVarProviderTest { private static final String CHE_SERVER_ENDPOINT = "localhost:8080"; - private KubernetesCheApiEnvVarProvider kubernetesCheApiEnvVarProvider; + private KubernetesCheApiInternalEnvVarProvider kubernetesCheApiEnvVarProvider; @BeforeMethod public void setUp() throws Exception { - kubernetesCheApiEnvVarProvider = new KubernetesCheApiEnvVarProvider(CHE_SERVER_ENDPOINT); + kubernetesCheApiEnvVarProvider = + new KubernetesCheApiInternalEnvVarProvider(CHE_SERVER_ENDPOINT); } @Test public void shouldReturnCheApiEnv() throws Exception { - // when - Pair cheApiEnv = kubernetesCheApiEnvVarProvider.get(null); - - // then - assertEquals(cheApiEnv.first, KubernetesCheApiEnvVarProvider.API_ENDPOINT_URL_VARIABLE); - assertEquals(cheApiEnv.second, CHE_SERVER_ENDPOINT); + // // when + // Pair cheApiEnv = kubernetesCheApiEnvVarProvider.get(null); + // + // // then + // assertEquals(cheApiEnv.first, + // KubernetesCheApiInternalEnvVarProvider.CHE_API_INTERNAL_VARIABLE); + // assertEquals(cheApiEnv.second, CHE_SERVER_ENDPOINT); } } diff --git a/infrastructures/openshift/src/main/java/org/eclipse/che/workspace/infrastructure/openshift/OpenShiftInfraModule.java b/infrastructures/openshift/src/main/java/org/eclipse/che/workspace/infrastructure/openshift/OpenShiftInfraModule.java index 7955fcc8582..2ed26d53b2a 100644 --- a/infrastructures/openshift/src/main/java/org/eclipse/che/workspace/infrastructure/openshift/OpenShiftInfraModule.java +++ b/infrastructures/openshift/src/main/java/org/eclipse/che/workspace/infrastructure/openshift/OpenShiftInfraModule.java @@ -19,7 +19,7 @@ import com.google.inject.multibindings.Multibinder; import org.eclipse.che.api.workspace.server.spi.RuntimeInfrastructure; import org.eclipse.che.api.workspace.server.spi.environment.InternalEnvironmentFactory; -import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiEnvVarProvider; +import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiInternalEnvVarProvider; import org.eclipse.che.api.workspace.server.spi.provision.env.EnvVarProvider; import org.eclipse.che.workspace.infrastructure.docker.environment.dockerimage.DockerImageEnvironment; import org.eclipse.che.workspace.infrastructure.docker.environment.dockerimage.DockerImageEnvironmentFactory; @@ -30,7 +30,7 @@ import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.pvc.WorkspacePVCCleaner; import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.pvc.WorkspaceVolumeStrategyProvider; import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.pvc.WorkspaceVolumesStrategy; -import org.eclipse.che.workspace.infrastructure.kubernetes.provision.KubernetesCheApiEnvVarProvider; +import org.eclipse.che.workspace.infrastructure.kubernetes.provision.KubernetesCheApiInternalEnvVarProvider; import org.eclipse.che.workspace.infrastructure.kubernetes.provision.env.LogsRootEnvVariableProvider; import org.eclipse.che.workspace.infrastructure.kubernetes.server.ExternalServerExposerStrategy; import org.eclipse.che.workspace.infrastructure.openshift.environment.OpenShiftEnvironment; @@ -60,7 +60,7 @@ protected void configure() { bind(WorkspacePVCCleaner.class).asEagerSingleton(); bind(RemoveProjectOnWorkspaceRemove.class).asEagerSingleton(); - bind(CheApiEnvVarProvider.class).to(KubernetesCheApiEnvVarProvider.class); + bind(CheApiInternalEnvVarProvider.class).to(KubernetesCheApiInternalEnvVarProvider.class); MapBinder volumesStrategies = MapBinder.newMapBinder(binder(), String.class, WorkspaceVolumesStrategy.class); diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiEnvVarProvider.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiEnvVarProvider.java index b0b810f71c2..7006e76bed2 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiEnvVarProvider.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiEnvVarProvider.java @@ -18,7 +18,7 @@ public interface CheApiEnvVarProvider extends EnvVarProvider { /** Env variable for machine that contains url of Che API */ - String API_ENDPOINT_URL_VARIABLE = "CHE_API"; + String CHE_API_VARIABLE = "CHE_API"; /** * Returns Che API environment variable which should be injected into machines. diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiExternalEnvVarProvider.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiExternalEnvVarProvider.java new file mode 100644 index 00000000000..fad11866311 --- /dev/null +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiExternalEnvVarProvider.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2012-2018 Red Hat, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.che.api.workspace.server.spi.provision.env; + +import org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity; +import org.eclipse.che.api.workspace.server.spi.InfrastructureException; +import org.eclipse.che.commons.lang.Pair; + +/** @author Sergii Leshchenko */ +public interface CheApiExternalEnvVarProvider extends EnvVarProvider { + + /** Env variable for machine that contains url of Che API */ + String CHE_API_EXTERNAL_VARIABLE = "CHE_API_EXTERNAL"; + + /** + * Returns Che API environment variable which should be injected into machines. + * + * @param runtimeIdentity which may be needed to evaluate environment variable value + */ + @Override + Pair get(RuntimeIdentity runtimeIdentity) throws InfrastructureException; +} diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiInternalEnvVarProvider.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiInternalEnvVarProvider.java new file mode 100644 index 00000000000..3ab10587dc5 --- /dev/null +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiInternalEnvVarProvider.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2012-2018 Red Hat, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.che.api.workspace.server.spi.provision.env; + +import org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity; +import org.eclipse.che.api.workspace.server.spi.InfrastructureException; +import org.eclipse.che.commons.lang.Pair; + +/** @author Sergii Leshchenko */ +public interface CheApiInternalEnvVarProvider extends EnvVarProvider { + + /** Env variable for machine that contains url of Che API */ + String CHE_API_INTERNAL_VARIABLE = "CHE_API_INTERNAL"; + + /** + * Returns Che API environment variable which should be injected into machines. + * + * @param runtimeIdentity which may be needed to evaluate environment variable value + */ + @Override + Pair get(RuntimeIdentity runtimeIdentity) throws InfrastructureException; +} From 4e07ca850697adb2f42dbf55ade63d6987484e95 Mon Sep 17 00:00:00 2001 From: Mykhailo Kuznietsov Date: Wed, 18 Apr 2018 09:36:04 +0300 Subject: [PATCH 02/17] fixup! Merge branch 'master' of github.com:eclipse/che into che-9323 --- dockerfiles/init/manifests/che.pp | 2 - .../init/modules/che/templates/che.env.erb | 5 +-- .../DockerCheApiExternalEnvVarProvider.java | 4 +- .../DockerCheApiInternalEnvVarProvider.java | 2 +- .../kubernetes/KubernetesInfraModule.java | 6 +++ .../KubernetesCheApiEnvVarProvider.java | 40 +++++++++++++++++++ ...ubernetesCheApiExternalEnvVarProvider.java | 38 ++++++++++++++++++ ...ubernetesCheApiInternalEnvVarProvider.java | 4 +- ...> KubernetesCheApiEnvVarProviderTest.java} | 25 ++++++------ .../openshift/OpenShiftInfraModule.java | 6 +++ .../env/EnvVarEnvironmentProvisioner.java | 1 + 11 files changed, 110 insertions(+), 23 deletions(-) create mode 100644 infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProvider.java create mode 100644 infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiExternalEnvVarProvider.java rename infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/{KubernetesCheApiInternalEnvVarProviderTest.java => KubernetesCheApiEnvVarProviderTest.java} (59%) diff --git a/dockerfiles/init/manifests/che.pp b/dockerfiles/init/manifests/che.pp index 7c317164fac..e615c10e4e3 100644 --- a/dockerfiles/init/manifests/che.pp +++ b/dockerfiles/init/manifests/che.pp @@ -14,8 +14,6 @@ $docker_host = getValue("DOCKER_HOST","tcp://localhost:2375") $che_user = getValue("CHE_USER","root") $che_server_url = getValue("CHE_SERVER_URL", "${che_protocol}://${che_ip}:${che_port}") - $che_api_internal = getValue("CHE_API_INTERNAL", "${che_server_url}/api") - $che_api_external = getValue("CHE_API_EXTERNAL", "${che_server_url}/api") $che_master_container_ram = getValue("CHE_MASTER_CONTAINER_RAM", "750m") $che_docker_ip_external = getValue("CHE_DOCKER_IP_EXTERNAL","") diff --git a/dockerfiles/init/modules/che/templates/che.env.erb b/dockerfiles/init/modules/che/templates/che.env.erb index 8f19a48c154..b43c8f3f335 100644 --- a/dockerfiles/init/modules/che/templates/che.env.erb +++ b/dockerfiles/init/modules/che/templates/che.env.erb @@ -51,10 +51,7 @@ CHE_LOGS_DIR=/logs CHE_WORKSPACE_LOGS=/logs/machines CHE_TEMPLATE_STORAGE=/data/templates -CHE_API_EXTERNAL=<%= scope.lookupvar('che::che_api_external') %> -CHE_API_INTERNAL=<%= scope.lookupvar('che::che_api_internal') %> -CHE_API=<%= scope.lookupvar('che::che_api_internal') %> - +CHE_API_EXTERNAL=<%= scope.lookupvar('che::che_server_url') %> <% if ! @che_http_proxy.empty? or ! @che_https_proxy.empty? -%> JAVA_HTTP_PROXY_SET=-Dhttp.proxySet=true diff --git a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiExternalEnvVarProvider.java b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiExternalEnvVarProvider.java index 4d727e6f692..cd97f623f46 100644 --- a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiExternalEnvVarProvider.java +++ b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiExternalEnvVarProvider.java @@ -17,9 +17,9 @@ import org.eclipse.che.commons.lang.Pair; /** - * Provides env variable to docker machine with url of Che API. + * Provides env variable to docker machine with url of Che external API. * - * @author Alexander Garagatyi + * @author Mykhailo Kuznietsov */ @Singleton public class DockerCheApiExternalEnvVarProvider implements CheApiExternalEnvVarProvider { diff --git a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiInternalEnvVarProvider.java b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiInternalEnvVarProvider.java index 7ff228d2358..d9d5052df21 100644 --- a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiInternalEnvVarProvider.java +++ b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiInternalEnvVarProvider.java @@ -21,7 +21,7 @@ /** * Provides env variable to docker machine with url of Che API. * - * @author Alexander Garagatyi + * @author Mykhailo Kuznietsov */ @Singleton public class DockerCheApiInternalEnvVarProvider implements CheApiInternalEnvVarProvider { diff --git a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/KubernetesInfraModule.java b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/KubernetesInfraModule.java index 65ea46f9261..97344b76ce7 100644 --- a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/KubernetesInfraModule.java +++ b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/KubernetesInfraModule.java @@ -24,6 +24,8 @@ import java.util.Map; import org.eclipse.che.api.workspace.server.spi.RuntimeInfrastructure; import org.eclipse.che.api.workspace.server.spi.environment.InternalEnvironmentFactory; +import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiEnvVarProvider; +import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiExternalEnvVarProvider; import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiInternalEnvVarProvider; import org.eclipse.che.api.workspace.server.spi.provision.env.EnvVarProvider; import org.eclipse.che.workspace.infrastructure.docker.environment.dockerimage.DockerImageEnvironment; @@ -41,6 +43,8 @@ import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.pvc.WorkspacePVCCleaner; import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.pvc.WorkspaceVolumeStrategyProvider; import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.pvc.WorkspaceVolumesStrategy; +import org.eclipse.che.workspace.infrastructure.kubernetes.provision.KubernetesCheApiEnvVarProvider; +import org.eclipse.che.workspace.infrastructure.kubernetes.provision.KubernetesCheApiExternalEnvVarProvider; import org.eclipse.che.workspace.infrastructure.kubernetes.provision.KubernetesCheApiInternalEnvVarProvider; import org.eclipse.che.workspace.infrastructure.kubernetes.provision.env.LogsRootEnvVariableProvider; import org.eclipse.che.workspace.infrastructure.kubernetes.server.DefaultHostIngressExternalServerExposer; @@ -69,7 +73,9 @@ protected void configure() { bind(WorkspacePVCCleaner.class).asEagerSingleton(); bind(RemoveNamespaceOnWorkspaceRemove.class).asEagerSingleton(); + bind(CheApiEnvVarProvider.class).to(KubernetesCheApiEnvVarProvider.class); bind(CheApiInternalEnvVarProvider.class).to(KubernetesCheApiInternalEnvVarProvider.class); + bind(CheApiExternalEnvVarProvider.class).to(KubernetesCheApiExternalEnvVarProvider.class); MapBinder volumesStrategies = MapBinder.newMapBinder(binder(), String.class, WorkspaceVolumesStrategy.class); diff --git a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProvider.java b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProvider.java new file mode 100644 index 00000000000..74385607d3f --- /dev/null +++ b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProvider.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2012-2018 Red Hat, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.che.workspace.infrastructure.kubernetes.provision; + +import javax.inject.Inject; +import javax.inject.Named; +import org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity; +import org.eclipse.che.api.workspace.server.spi.InfrastructureException; +import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiEnvVarProvider; +import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiExternalEnvVarProvider; +import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiInternalEnvVarProvider; +import org.eclipse.che.commons.lang.Pair; + +/** + * Provides env variable to Kubernetes machine with url of Che API. + * + * @author Sergii Leshchenko + */ +public class KubernetesCheApiEnvVarProvider implements CheApiEnvVarProvider{ + + private final String cheServerEndpoint; + + @Inject + public KubernetesCheApiEnvVarProvider(@Named("che.api") String cheServerEndpoint) { + this.cheServerEndpoint = cheServerEndpoint; + } + + @Override + public Pair get(RuntimeIdentity runtimeIdentity) throws InfrastructureException { + return Pair.of(CHE_API_VARIABLE, cheServerEndpoint); + } +} diff --git a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiExternalEnvVarProvider.java b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiExternalEnvVarProvider.java new file mode 100644 index 00000000000..7fc35694a33 --- /dev/null +++ b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiExternalEnvVarProvider.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2012-2018 Red Hat, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.che.workspace.infrastructure.kubernetes.provision; + +import javax.inject.Inject; +import javax.inject.Named; +import org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity; +import org.eclipse.che.api.workspace.server.spi.InfrastructureException; +import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiExternalEnvVarProvider; +import org.eclipse.che.commons.lang.Pair; + +/** + * Provides env variable to Kubernetes machine with url of Che API. + * + * @author Mykhailo Kuznietsov + */ +public class KubernetesCheApiExternalEnvVarProvider implements CheApiExternalEnvVarProvider { + + private final String cheServerEndpoint; + + @Inject + public KubernetesCheApiExternalEnvVarProvider(@Named("che.api") String cheServerEndpoint) { + this.cheServerEndpoint = cheServerEndpoint; + } + + @Override + public Pair get(RuntimeIdentity runtimeIdentity) throws InfrastructureException { + return Pair.of(CHE_API_EXTERNAL_VARIABLE, cheServerEndpoint); + } +} diff --git a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiInternalEnvVarProvider.java b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiInternalEnvVarProvider.java index 4b89f2fc559..ec582ecd57f 100644 --- a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiInternalEnvVarProvider.java +++ b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiInternalEnvVarProvider.java @@ -20,7 +20,7 @@ /** * Provides env variable to Kubernetes machine with url of Che API. * - * @author Sergii Leshchenko + * @author Mykhailo Kuznietsov */ public class KubernetesCheApiInternalEnvVarProvider implements CheApiInternalEnvVarProvider { @@ -33,6 +33,6 @@ public KubernetesCheApiInternalEnvVarProvider(@Named("che.api") String cheServer @Override public Pair get(RuntimeIdentity runtimeIdentity) throws InfrastructureException { - return Pair.of("CHE_API", cheServerEndpoint); + return Pair.of(CHE_API_INTERNAL_VARIABLE, cheServerEndpoint); } } diff --git a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiInternalEnvVarProviderTest.java b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProviderTest.java similarity index 59% rename from infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiInternalEnvVarProviderTest.java rename to infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProviderTest.java index 56dc63c8bd9..8424678084f 100644 --- a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiInternalEnvVarProviderTest.java +++ b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProviderTest.java @@ -10,37 +10,38 @@ */ package org.eclipse.che.workspace.infrastructure.kubernetes.provision; +import static org.testng.Assert.assertEquals; + +import org.eclipse.che.commons.lang.Pair; import org.mockito.testng.MockitoTestNGListener; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Listeners; import org.testng.annotations.Test; /** - * Tests {@link KubernetesCheApiInternalEnvVarProvider}. + * Tests {@link KubernetesCheApiEnvVarProvider}. * * @author Sergii Leshchenko */ @Listeners(MockitoTestNGListener.class) -public class KubernetesCheApiInternalEnvVarProviderTest { +public class KubernetesCheApiEnvVarProviderTest { private static final String CHE_SERVER_ENDPOINT = "localhost:8080"; - private KubernetesCheApiInternalEnvVarProvider kubernetesCheApiEnvVarProvider; + private KubernetesCheApiEnvVarProvider kubernetesCheApiEnvVarProvider; @BeforeMethod public void setUp() throws Exception { - kubernetesCheApiEnvVarProvider = - new KubernetesCheApiInternalEnvVarProvider(CHE_SERVER_ENDPOINT); + kubernetesCheApiEnvVarProvider = new KubernetesCheApiEnvVarProvider(CHE_SERVER_ENDPOINT); } @Test public void shouldReturnCheApiEnv() throws Exception { - // // when - // Pair cheApiEnv = kubernetesCheApiEnvVarProvider.get(null); - // - // // then - // assertEquals(cheApiEnv.first, - // KubernetesCheApiInternalEnvVarProvider.CHE_API_INTERNAL_VARIABLE); - // assertEquals(cheApiEnv.second, CHE_SERVER_ENDPOINT); + // when + Pair cheApiEnv = kubernetesCheApiEnvVarProvider.get(null); + + // then + assertEquals(cheApiEnv.first, KubernetesCheApiEnvVarProvider.CHE_API_VARIABLE); + assertEquals(cheApiEnv.second, CHE_SERVER_ENDPOINT); } } diff --git a/infrastructures/openshift/src/main/java/org/eclipse/che/workspace/infrastructure/openshift/OpenShiftInfraModule.java b/infrastructures/openshift/src/main/java/org/eclipse/che/workspace/infrastructure/openshift/OpenShiftInfraModule.java index b434fa41ae4..390b662bf86 100644 --- a/infrastructures/openshift/src/main/java/org/eclipse/che/workspace/infrastructure/openshift/OpenShiftInfraModule.java +++ b/infrastructures/openshift/src/main/java/org/eclipse/che/workspace/infrastructure/openshift/OpenShiftInfraModule.java @@ -20,6 +20,8 @@ import com.google.inject.multibindings.Multibinder; import org.eclipse.che.api.workspace.server.spi.RuntimeInfrastructure; import org.eclipse.che.api.workspace.server.spi.environment.InternalEnvironmentFactory; +import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiEnvVarProvider; +import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiExternalEnvVarProvider; import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiInternalEnvVarProvider; import org.eclipse.che.api.workspace.server.spi.provision.env.EnvVarProvider; import org.eclipse.che.workspace.infrastructure.docker.environment.dockerimage.DockerImageEnvironment; @@ -35,6 +37,8 @@ import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.pvc.WorkspacePVCCleaner; import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.pvc.WorkspaceVolumeStrategyProvider; import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.pvc.WorkspaceVolumesStrategy; +import org.eclipse.che.workspace.infrastructure.kubernetes.provision.KubernetesCheApiEnvVarProvider; +import org.eclipse.che.workspace.infrastructure.kubernetes.provision.KubernetesCheApiExternalEnvVarProvider; import org.eclipse.che.workspace.infrastructure.kubernetes.provision.KubernetesCheApiInternalEnvVarProvider; import org.eclipse.che.workspace.infrastructure.kubernetes.provision.env.LogsRootEnvVariableProvider; import org.eclipse.che.workspace.infrastructure.kubernetes.provision.server.ServersConverter; @@ -66,7 +70,9 @@ protected void configure() { bind(WorkspacePVCCleaner.class).asEagerSingleton(); bind(RemoveProjectOnWorkspaceRemove.class).asEagerSingleton(); + bind(CheApiEnvVarProvider.class).to(KubernetesCheApiEnvVarProvider.class); bind(CheApiInternalEnvVarProvider.class).to(KubernetesCheApiInternalEnvVarProvider.class); + bind(CheApiExternalEnvVarProvider.class).to(KubernetesCheApiExternalEnvVarProvider.class); MapBinder volumesStrategies = MapBinder.newMapBinder(binder(), String.class, WorkspaceVolumesStrategy.class); diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/EnvVarEnvironmentProvisioner.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/EnvVarEnvironmentProvisioner.java index 28a0c1e9878..249895c67ca 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/EnvVarEnvironmentProvisioner.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/EnvVarEnvironmentProvisioner.java @@ -37,6 +37,7 @@ public void provision(RuntimeIdentity id, InternalEnvironment internalEnvironmen throws InfrastructureException { for (EnvVarProvider envVarProvider : envVarProviders) { Pair envVar = envVarProvider.get(id); + internalEnvironment .getMachines() .values() From 5b2695cb8c8f2c4cbf1b530b616e42fd23b8e6b5 Mon Sep 17 00:00:00 2001 From: Mykhailo Kuznietsov Date: Wed, 18 Apr 2018 09:43:09 +0300 Subject: [PATCH 03/17] fixup! fixup! Merge branch 'master' of github.com:eclipse/che into che-9323 --- dockerfiles/init/modules/che/templates/che.env.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockerfiles/init/modules/che/templates/che.env.erb b/dockerfiles/init/modules/che/templates/che.env.erb index b43c8f3f335..0d02476c307 100644 --- a/dockerfiles/init/modules/che/templates/che.env.erb +++ b/dockerfiles/init/modules/che/templates/che.env.erb @@ -51,7 +51,7 @@ CHE_LOGS_DIR=/logs CHE_WORKSPACE_LOGS=/logs/machines CHE_TEMPLATE_STORAGE=/data/templates -CHE_API_EXTERNAL=<%= scope.lookupvar('che::che_server_url') %> +CHE_API_EXTERNAL=<%= scope.lookupvar('che::che_server_url') %>/api <% if ! @che_http_proxy.empty? or ! @che_https_proxy.empty? -%> JAVA_HTTP_PROXY_SET=-Dhttp.proxySet=true From f1c129c8aea1824187312b84fe0c899982c47102 Mon Sep 17 00:00:00 2001 From: Mykhailo Kuznietsov Date: Wed, 18 Apr 2018 11:28:00 +0300 Subject: [PATCH 04/17] fixup! fixup! fixup! Merge branch 'master' of github.com:eclipse/che into che-9323 --- .../docker/DockerCheApiEnvVarProvider.java | 10 +++------- .../docker/DockerCheApiInternalEnvVarProvider.java | 7 +------ .../provision/KubernetesCheApiEnvVarProvider.java | 10 ++++------ 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiEnvVarProvider.java b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiEnvVarProvider.java index b143769e870..5946c576017 100644 --- a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiEnvVarProvider.java +++ b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiEnvVarProvider.java @@ -10,7 +10,6 @@ */ package org.eclipse.che.workspace.infrastructure.docker; -import com.google.common.base.Strings; import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; @@ -22,24 +21,21 @@ * Provides env variable to docker machine with url of Che API. * * @author Alexander Garagatyi + * @author Mykhailo Kuznietsov */ @Singleton public class DockerCheApiEnvVarProvider implements CheApiEnvVarProvider { - private Pair apiEnvVar; + private final Pair apiEnvVar; @Inject public DockerCheApiEnvVarProvider( @Named("che.infra.docker.master_api_endpoint") String apiEndpoint) { - String apiEndpointEnvVar = System.getenv(CHE_API_VARIABLE); - if (Strings.isNullOrEmpty(apiEndpoint) && !Strings.isNullOrEmpty(apiEndpointEnvVar)) { - apiEndpoint = apiEndpointEnvVar; - } apiEnvVar = Pair.of(CHE_API_VARIABLE, apiEndpoint); } @Override public Pair get(RuntimeIdentity runtimeIdentity) { - return new Pair<>(apiEnvVar.first, apiEnvVar.second); + return apiEnvVar; } } diff --git a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiInternalEnvVarProvider.java b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiInternalEnvVarProvider.java index d9d5052df21..06fb71362bd 100644 --- a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiInternalEnvVarProvider.java +++ b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiInternalEnvVarProvider.java @@ -10,7 +10,6 @@ */ package org.eclipse.che.workspace.infrastructure.docker; -import com.google.common.base.Strings; import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; @@ -26,15 +25,11 @@ @Singleton public class DockerCheApiInternalEnvVarProvider implements CheApiInternalEnvVarProvider { - private Pair apiEnvVar; + private final Pair apiEnvVar; @Inject public DockerCheApiInternalEnvVarProvider( @Named("che.infra.docker.master_api_endpoint") String apiEndpoint) { - String apiEndpointEnvVar = System.getenv(CHE_API_INTERNAL_VARIABLE); - if (Strings.isNullOrEmpty(apiEndpoint) && !Strings.isNullOrEmpty(apiEndpointEnvVar)) { - apiEndpoint = apiEndpointEnvVar; - } apiEnvVar = Pair.of(CHE_API_INTERNAL_VARIABLE, apiEndpoint); } diff --git a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProvider.java b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProvider.java index 74385607d3f..1a1e1e7b0f1 100644 --- a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProvider.java +++ b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProvider.java @@ -15,8 +15,6 @@ import org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity; import org.eclipse.che.api.workspace.server.spi.InfrastructureException; import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiEnvVarProvider; -import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiExternalEnvVarProvider; -import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiInternalEnvVarProvider; import org.eclipse.che.commons.lang.Pair; /** @@ -24,17 +22,17 @@ * * @author Sergii Leshchenko */ -public class KubernetesCheApiEnvVarProvider implements CheApiEnvVarProvider{ +public class KubernetesCheApiEnvVarProvider implements CheApiEnvVarProvider { - private final String cheServerEndpoint; + private final Pair apiEnvVar; @Inject public KubernetesCheApiEnvVarProvider(@Named("che.api") String cheServerEndpoint) { - this.cheServerEndpoint = cheServerEndpoint; + this.apiEnvVar = Pair.of(CHE_API_VARIABLE, cheServerEndpoint); } @Override public Pair get(RuntimeIdentity runtimeIdentity) throws InfrastructureException { - return Pair.of(CHE_API_VARIABLE, cheServerEndpoint); + return apiEnvVar; } } From 25133b16762feca82ba69c428d212a76b12acc65 Mon Sep 17 00:00:00 2001 From: Mykhailo Kuznietsov Date: Wed, 18 Apr 2018 12:05:40 +0300 Subject: [PATCH 05/17] fixup! fixup! fixup! fixup! Merge branch 'master' of github.com:eclipse/che into che-9323 --- dockerfiles/init/modules/che/templates/che.env.erb | 2 -- .../docker/DockerCheApiExternalEnvVarProvider.java | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/dockerfiles/init/modules/che/templates/che.env.erb b/dockerfiles/init/modules/che/templates/che.env.erb index 0d02476c307..36424e95f5b 100644 --- a/dockerfiles/init/modules/che/templates/che.env.erb +++ b/dockerfiles/init/modules/che/templates/che.env.erb @@ -51,8 +51,6 @@ CHE_LOGS_DIR=/logs CHE_WORKSPACE_LOGS=/logs/machines CHE_TEMPLATE_STORAGE=/data/templates -CHE_API_EXTERNAL=<%= scope.lookupvar('che::che_server_url') %>/api - <% if ! @che_http_proxy.empty? or ! @che_https_proxy.empty? -%> JAVA_HTTP_PROXY_SET=-Dhttp.proxySet=true <% end -%> diff --git a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiExternalEnvVarProvider.java b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiExternalEnvVarProvider.java index cd97f623f46..ce97ce248a8 100644 --- a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiExternalEnvVarProvider.java +++ b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiExternalEnvVarProvider.java @@ -11,6 +11,7 @@ package org.eclipse.che.workspace.infrastructure.docker; import javax.inject.Inject; +import javax.inject.Named; import javax.inject.Singleton; import org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity; import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiExternalEnvVarProvider; @@ -27,8 +28,8 @@ public class DockerCheApiExternalEnvVarProvider implements CheApiExternalEnvVarP private final Pair apiEnvVar; @Inject - public DockerCheApiExternalEnvVarProvider() { - apiEnvVar = Pair.of(CHE_API_EXTERNAL_VARIABLE, System.getenv(CHE_API_EXTERNAL_VARIABLE)); + public DockerCheApiExternalEnvVarProvider(@Named("che.api") String apiEndpoint) { + apiEnvVar = Pair.of(CHE_API_EXTERNAL_VARIABLE, apiEndpoint); } @Override From f42a5a82f512ad4f3c33c1c98f773d3f9fb14e4e Mon Sep 17 00:00:00 2001 From: Mykhailo Kuznietsov Date: Wed, 18 Apr 2018 12:18:13 +0300 Subject: [PATCH 06/17] fixup! fixup! fixup! fixup! fixup! Merge branch 'master' of github.com:eclipse/che into che-9323 --- .../server/spi/provision/env/CheApiExternalEnvVarProvider.java | 2 +- .../server/spi/provision/env/CheApiInternalEnvVarProvider.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiExternalEnvVarProvider.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiExternalEnvVarProvider.java index fad11866311..2285da19675 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiExternalEnvVarProvider.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiExternalEnvVarProvider.java @@ -14,7 +14,7 @@ import org.eclipse.che.api.workspace.server.spi.InfrastructureException; import org.eclipse.che.commons.lang.Pair; -/** @author Sergii Leshchenko */ +/** @author Mykhailo Kuznietsov */ public interface CheApiExternalEnvVarProvider extends EnvVarProvider { /** Env variable for machine that contains url of Che API */ diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiInternalEnvVarProvider.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiInternalEnvVarProvider.java index 3ab10587dc5..0bbbe0ee949 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiInternalEnvVarProvider.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiInternalEnvVarProvider.java @@ -14,7 +14,7 @@ import org.eclipse.che.api.workspace.server.spi.InfrastructureException; import org.eclipse.che.commons.lang.Pair; -/** @author Sergii Leshchenko */ +/** @author Mykhailo Kuznietsov */ public interface CheApiInternalEnvVarProvider extends EnvVarProvider { /** Env variable for machine that contains url of Che API */ From 308c5a5c428c145ed2b781377332a9bcc117714a Mon Sep 17 00:00:00 2001 From: Mykhailo Kuznietsov Date: Wed, 18 Apr 2018 14:41:35 +0300 Subject: [PATCH 07/17] fixup! fixup! fixup! fixup! fixup! fixup! Merge branch 'master' of github.com:eclipse/che into che-9323 --- .../server/spi/provision/env/CheApiInternalEnvVarProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiInternalEnvVarProvider.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiInternalEnvVarProvider.java index 0bbbe0ee949..6282bc7565d 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiInternalEnvVarProvider.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiInternalEnvVarProvider.java @@ -14,7 +14,7 @@ import org.eclipse.che.api.workspace.server.spi.InfrastructureException; import org.eclipse.che.commons.lang.Pair; -/** @author Mykhailo Kuznietsov */ +/** @author Mykhailo Kuznietsov */ public interface CheApiInternalEnvVarProvider extends EnvVarProvider { /** Env variable for machine that contains url of Che API */ From 8ddeb7141abaa22c4b52a2dd3827c74aa1b240e8 Mon Sep 17 00:00:00 2001 From: Roman Iuvshyn Date: Wed, 18 Apr 2018 18:29:37 +0200 Subject: [PATCH 08/17] test --- deploy/openshift/ocp.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/deploy/openshift/ocp.sh b/deploy/openshift/ocp.sh index 0fa05a9a87a..7690dd0175d 100755 --- a/deploy/openshift/ocp.sh +++ b/deploy/openshift/ocp.sh @@ -264,6 +264,7 @@ deploy_che_to_ocp() { fi $OC_BINARY new-app -f ${BASE_DIR}/templates/che-server-template.yaml -p ROUTING_SUFFIX=${OC_PUBLIC_IP}.${DNS_PROVIDER} -p IMAGE_CHE=${CHE_IMAGE_REPO} -p CHE_VERSION=${CHE_IMAGE_TAG} ${CHE_MULTIUSER_PARAM} ${ENV} + echo "{{{ $OC_BINARY new-app -f ${BASE_DIR}/templates/che-server-template.yaml -p ROUTING_SUFFIX=${OC_PUBLIC_IP}.${DNS_PROVIDER} -p IMAGE_CHE=${CHE_IMAGE_REPO} -p CHE_VERSION=${CHE_IMAGE_TAG} ${CHE_MULTIUSER_PARAM} ${ENV} ###" $OC_BINARY set volume dc/che --add -m /data --name=che-data-volume --claim-name=che-data-volume echo "Waiting for Che to boot..." wait_for_che From d75bc4717ba02ed6f59c6c812ae7da44477859a2 Mon Sep 17 00:00:00 2001 From: Roman Iuvshyn Date: Wed, 18 Apr 2018 19:15:06 +0200 Subject: [PATCH 09/17] Update ocp.sh --- deploy/openshift/ocp.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/deploy/openshift/ocp.sh b/deploy/openshift/ocp.sh index 7690dd0175d..bec52b42b58 100755 --- a/deploy/openshift/ocp.sh +++ b/deploy/openshift/ocp.sh @@ -262,9 +262,8 @@ deploy_che_to_ocp() { if [ ${#CHE_VAR_ARRAY[@]} > 0 ]; then ENV="-e ${CHE_VAR_ARRAY}" fi - + echo "### $OC_BINARY new-app -f ${BASE_DIR}/templates/che-server-template.yaml -p ROUTING_SUFFIX=${OC_PUBLIC_IP}.${DNS_PROVIDER} -p IMAGE_CHE=${CHE_IMAGE_REPO} -p CHE_VERSION=${CHE_IMAGE_TAG} ${CHE_MULTIUSER_PARAM} ${ENV} ###" $OC_BINARY new-app -f ${BASE_DIR}/templates/che-server-template.yaml -p ROUTING_SUFFIX=${OC_PUBLIC_IP}.${DNS_PROVIDER} -p IMAGE_CHE=${CHE_IMAGE_REPO} -p CHE_VERSION=${CHE_IMAGE_TAG} ${CHE_MULTIUSER_PARAM} ${ENV} - echo "{{{ $OC_BINARY new-app -f ${BASE_DIR}/templates/che-server-template.yaml -p ROUTING_SUFFIX=${OC_PUBLIC_IP}.${DNS_PROVIDER} -p IMAGE_CHE=${CHE_IMAGE_REPO} -p CHE_VERSION=${CHE_IMAGE_TAG} ${CHE_MULTIUSER_PARAM} ${ENV} ###" $OC_BINARY set volume dc/che --add -m /data --name=che-data-volume --claim-name=che-data-volume echo "Waiting for Che to boot..." wait_for_che From 9ee2ad7be364b5a2225b3ca89b379306196f8eae Mon Sep 17 00:00:00 2001 From: Eugene Ivantsov Date: Wed, 18 Apr 2018 22:57:36 +0300 Subject: [PATCH 10/17] Tets envs --- deploy/openshift/ocp.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/openshift/ocp.sh b/deploy/openshift/ocp.sh index bec52b42b58..b712220b576 100755 --- a/deploy/openshift/ocp.sh +++ b/deploy/openshift/ocp.sh @@ -258,7 +258,7 @@ deploy_che_to_ocp() { wait_for_keycloak export CHE_MULTIUSER_PARAM="-p CHE_MULTIUSER=true" fi - CHE_VAR_ARRAY=$(env | grep "CHE_.") + CHE_VAR_ARRAY=$(env | grep -P '^\w*CHE_\w*(?==)') if [ ${#CHE_VAR_ARRAY[@]} > 0 ]; then ENV="-e ${CHE_VAR_ARRAY}" fi From aea61c2f8d26d34025a9dd7290fc1f54d16188ff Mon Sep 17 00:00:00 2001 From: Eugene Ivantsov Date: Thu, 19 Apr 2018 09:19:12 +0300 Subject: [PATCH 11/17] Remove testing echo --- deploy/openshift/ocp.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/deploy/openshift/ocp.sh b/deploy/openshift/ocp.sh index b712220b576..725000744b9 100755 --- a/deploy/openshift/ocp.sh +++ b/deploy/openshift/ocp.sh @@ -262,7 +262,6 @@ deploy_che_to_ocp() { if [ ${#CHE_VAR_ARRAY[@]} > 0 ]; then ENV="-e ${CHE_VAR_ARRAY}" fi - echo "### $OC_BINARY new-app -f ${BASE_DIR}/templates/che-server-template.yaml -p ROUTING_SUFFIX=${OC_PUBLIC_IP}.${DNS_PROVIDER} -p IMAGE_CHE=${CHE_IMAGE_REPO} -p CHE_VERSION=${CHE_IMAGE_TAG} ${CHE_MULTIUSER_PARAM} ${ENV} ###" $OC_BINARY new-app -f ${BASE_DIR}/templates/che-server-template.yaml -p ROUTING_SUFFIX=${OC_PUBLIC_IP}.${DNS_PROVIDER} -p IMAGE_CHE=${CHE_IMAGE_REPO} -p CHE_VERSION=${CHE_IMAGE_TAG} ${CHE_MULTIUSER_PARAM} ${ENV} $OC_BINARY set volume dc/che --add -m /data --name=che-data-volume --claim-name=che-data-volume echo "Waiting for Che to boot..." From 58fffc98ca8a610632661eb4405ceb730d010950 Mon Sep 17 00:00:00 2001 From: Mykhailo Kuznietsov Date: Tue, 24 Apr 2018 09:59:38 +0300 Subject: [PATCH 12/17] Remove odd classes --- .../docker/DockerCheApiEnvVarProvider.java | 41 ---------------- .../docker/DockerInfraModule.java | 1 - .../kubernetes/KubernetesInfraModule.java | 3 -- .../KubernetesCheApiEnvVarProvider.java | 38 --------------- .../KubernetesCheApiEnvVarProviderTest.java | 47 ------------------- .../openshift/OpenShiftInfraModule.java | 3 -- .../provision/env/CheApiEnvVarProvider.java | 21 +++++++-- 7 files changed, 17 insertions(+), 137 deletions(-) delete mode 100644 infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiEnvVarProvider.java delete mode 100644 infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProvider.java delete mode 100644 infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProviderTest.java diff --git a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiEnvVarProvider.java b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiEnvVarProvider.java deleted file mode 100644 index 5946c576017..00000000000 --- a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiEnvVarProvider.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2012-2018 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - */ -package org.eclipse.che.workspace.infrastructure.docker; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; -import org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity; -import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiEnvVarProvider; -import org.eclipse.che.commons.lang.Pair; - -/** - * Provides env variable to docker machine with url of Che API. - * - * @author Alexander Garagatyi - * @author Mykhailo Kuznietsov - */ -@Singleton -public class DockerCheApiEnvVarProvider implements CheApiEnvVarProvider { - - private final Pair apiEnvVar; - - @Inject - public DockerCheApiEnvVarProvider( - @Named("che.infra.docker.master_api_endpoint") String apiEndpoint) { - apiEnvVar = Pair.of(CHE_API_VARIABLE, apiEndpoint); - } - - @Override - public Pair get(RuntimeIdentity runtimeIdentity) { - return apiEnvVar; - } -} diff --git a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerInfraModule.java b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerInfraModule.java index 2c3aa49cf98..81dd9f0bfb0 100644 --- a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerInfraModule.java +++ b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerInfraModule.java @@ -62,7 +62,6 @@ protected void configure() { install(new DockerEnvironmentConvertersModule()); install(new ContainerSystemSettingsProvisioningModule()); - bind(CheApiEnvVarProvider.class).to(DockerCheApiEnvVarProvider.class); bind(CheApiInternalEnvVarProvider.class).to(DockerCheApiInternalEnvVarProvider.class); bind(CheApiExternalEnvVarProvider.class).to(DockerCheApiExternalEnvVarProvider.class); diff --git a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/KubernetesInfraModule.java b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/KubernetesInfraModule.java index d6fa1188461..3cdc4986a57 100644 --- a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/KubernetesInfraModule.java +++ b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/KubernetesInfraModule.java @@ -24,7 +24,6 @@ import java.util.Map; import org.eclipse.che.api.workspace.server.spi.RuntimeInfrastructure; import org.eclipse.che.api.workspace.server.spi.environment.InternalEnvironmentFactory; -import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiEnvVarProvider; import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiExternalEnvVarProvider; import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiInternalEnvVarProvider; import org.eclipse.che.api.workspace.server.spi.provision.env.EnvVarProvider; @@ -43,7 +42,6 @@ import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.pvc.WorkspacePVCCleaner; import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.pvc.WorkspaceVolumeStrategyProvider; import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.pvc.WorkspaceVolumesStrategy; -import org.eclipse.che.workspace.infrastructure.kubernetes.provision.KubernetesCheApiEnvVarProvider; import org.eclipse.che.workspace.infrastructure.kubernetes.provision.KubernetesCheApiExternalEnvVarProvider; import org.eclipse.che.workspace.infrastructure.kubernetes.provision.KubernetesCheApiInternalEnvVarProvider; import org.eclipse.che.workspace.infrastructure.kubernetes.provision.env.LogsRootEnvVariableProvider; @@ -74,7 +72,6 @@ protected void configure() { bind(WorkspacePVCCleaner.class).asEagerSingleton(); bind(RemoveNamespaceOnWorkspaceRemove.class).asEagerSingleton(); - bind(CheApiEnvVarProvider.class).to(KubernetesCheApiEnvVarProvider.class); bind(CheApiInternalEnvVarProvider.class).to(KubernetesCheApiInternalEnvVarProvider.class); bind(CheApiExternalEnvVarProvider.class).to(KubernetesCheApiExternalEnvVarProvider.class); diff --git a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProvider.java b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProvider.java deleted file mode 100644 index 1a1e1e7b0f1..00000000000 --- a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProvider.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2012-2018 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - */ -package org.eclipse.che.workspace.infrastructure.kubernetes.provision; - -import javax.inject.Inject; -import javax.inject.Named; -import org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity; -import org.eclipse.che.api.workspace.server.spi.InfrastructureException; -import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiEnvVarProvider; -import org.eclipse.che.commons.lang.Pair; - -/** - * Provides env variable to Kubernetes machine with url of Che API. - * - * @author Sergii Leshchenko - */ -public class KubernetesCheApiEnvVarProvider implements CheApiEnvVarProvider { - - private final Pair apiEnvVar; - - @Inject - public KubernetesCheApiEnvVarProvider(@Named("che.api") String cheServerEndpoint) { - this.apiEnvVar = Pair.of(CHE_API_VARIABLE, cheServerEndpoint); - } - - @Override - public Pair get(RuntimeIdentity runtimeIdentity) throws InfrastructureException { - return apiEnvVar; - } -} diff --git a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProviderTest.java b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProviderTest.java deleted file mode 100644 index 8424678084f..00000000000 --- a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProviderTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2012-2018 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - */ -package org.eclipse.che.workspace.infrastructure.kubernetes.provision; - -import static org.testng.Assert.assertEquals; - -import org.eclipse.che.commons.lang.Pair; -import org.mockito.testng.MockitoTestNGListener; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Listeners; -import org.testng.annotations.Test; - -/** - * Tests {@link KubernetesCheApiEnvVarProvider}. - * - * @author Sergii Leshchenko - */ -@Listeners(MockitoTestNGListener.class) -public class KubernetesCheApiEnvVarProviderTest { - - private static final String CHE_SERVER_ENDPOINT = "localhost:8080"; - - private KubernetesCheApiEnvVarProvider kubernetesCheApiEnvVarProvider; - - @BeforeMethod - public void setUp() throws Exception { - kubernetesCheApiEnvVarProvider = new KubernetesCheApiEnvVarProvider(CHE_SERVER_ENDPOINT); - } - - @Test - public void shouldReturnCheApiEnv() throws Exception { - // when - Pair cheApiEnv = kubernetesCheApiEnvVarProvider.get(null); - - // then - assertEquals(cheApiEnv.first, KubernetesCheApiEnvVarProvider.CHE_API_VARIABLE); - assertEquals(cheApiEnv.second, CHE_SERVER_ENDPOINT); - } -} diff --git a/infrastructures/openshift/src/main/java/org/eclipse/che/workspace/infrastructure/openshift/OpenShiftInfraModule.java b/infrastructures/openshift/src/main/java/org/eclipse/che/workspace/infrastructure/openshift/OpenShiftInfraModule.java index 390b662bf86..018fdfdc37a 100644 --- a/infrastructures/openshift/src/main/java/org/eclipse/che/workspace/infrastructure/openshift/OpenShiftInfraModule.java +++ b/infrastructures/openshift/src/main/java/org/eclipse/che/workspace/infrastructure/openshift/OpenShiftInfraModule.java @@ -20,7 +20,6 @@ import com.google.inject.multibindings.Multibinder; import org.eclipse.che.api.workspace.server.spi.RuntimeInfrastructure; import org.eclipse.che.api.workspace.server.spi.environment.InternalEnvironmentFactory; -import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiEnvVarProvider; import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiExternalEnvVarProvider; import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiInternalEnvVarProvider; import org.eclipse.che.api.workspace.server.spi.provision.env.EnvVarProvider; @@ -37,7 +36,6 @@ import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.pvc.WorkspacePVCCleaner; import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.pvc.WorkspaceVolumeStrategyProvider; import org.eclipse.che.workspace.infrastructure.kubernetes.namespace.pvc.WorkspaceVolumesStrategy; -import org.eclipse.che.workspace.infrastructure.kubernetes.provision.KubernetesCheApiEnvVarProvider; import org.eclipse.che.workspace.infrastructure.kubernetes.provision.KubernetesCheApiExternalEnvVarProvider; import org.eclipse.che.workspace.infrastructure.kubernetes.provision.KubernetesCheApiInternalEnvVarProvider; import org.eclipse.che.workspace.infrastructure.kubernetes.provision.env.LogsRootEnvVariableProvider; @@ -70,7 +68,6 @@ protected void configure() { bind(WorkspacePVCCleaner.class).asEagerSingleton(); bind(RemoveProjectOnWorkspaceRemove.class).asEagerSingleton(); - bind(CheApiEnvVarProvider.class).to(KubernetesCheApiEnvVarProvider.class); bind(CheApiInternalEnvVarProvider.class).to(KubernetesCheApiInternalEnvVarProvider.class); bind(CheApiExternalEnvVarProvider.class).to(KubernetesCheApiExternalEnvVarProvider.class); diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiEnvVarProvider.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiEnvVarProvider.java index 7006e76bed2..56091dedf68 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiEnvVarProvider.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiEnvVarProvider.java @@ -14,11 +14,22 @@ import org.eclipse.che.api.workspace.server.spi.InfrastructureException; import org.eclipse.che.commons.lang.Pair; -/** @author Sergii Leshchenko */ -public interface CheApiEnvVarProvider extends EnvVarProvider { +import javax.inject.Inject; + +/** + * @author Sergii Leshchenko + */ +public class CheApiEnvVarProvider implements EnvVarProvider { /** Env variable for machine that contains url of Che API */ - String CHE_API_VARIABLE = "CHE_API"; + public static final String CHE_API_VARIABLE = "CHE_API"; + + private final CheApiInternalEnvVarProvider cheApiInternalEnvVarProvider; + + @Inject + public CheApiEnvVarProvider(CheApiInternalEnvVarProvider cheApiInternalEnvVarProvider) { + this.cheApiInternalEnvVarProvider = cheApiInternalEnvVarProvider; + } /** * Returns Che API environment variable which should be injected into machines. @@ -26,5 +37,7 @@ public interface CheApiEnvVarProvider extends EnvVarProvider { * @param runtimeIdentity which may be needed to evaluate environment variable value */ @Override - Pair get(RuntimeIdentity runtimeIdentity) throws InfrastructureException; + public Pair get(RuntimeIdentity runtimeIdentity) throws InfrastructureException { + return Pair.of(CHE_API_VARIABLE, cheApiInternalEnvVarProvider.get(runtimeIdentity).second); + } } From ab94315b264dd7f338939f41660ce477e2782964 Mon Sep 17 00:00:00 2001 From: Mykhailo Kuznietsov Date: Tue, 24 Apr 2018 16:21:12 +0300 Subject: [PATCH 13/17] fixup! Remove odd classes --- dockerfiles/init/manifests/che.env | 2 ++ .../infrastructure/docker/DockerInfraModule.java | 1 - .../spi/provision/env/CheApiEnvVarProvider.java | 12 +++++++++--- .../provision/env/EnvVarEnvironmentProvisioner.java | 1 - 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/dockerfiles/init/manifests/che.env b/dockerfiles/init/manifests/che.env index 6a0c6d8aa3c..106c7d2f926 100644 --- a/dockerfiles/init/manifests/che.env +++ b/dockerfiles/init/manifests/che.env @@ -189,6 +189,8 @@ # Che Server API Endpoint # The location of the API end point where dashboard and IDE clients will look for # interacting with the Che server, which we also call the workspace master. +# +# This property is deprecated and should not be used. #CHE_API=http://${CHE_HOST}:${CHE_PORT}/api # Che Server default websocket endpoint. diff --git a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerInfraModule.java b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerInfraModule.java index 81dd9f0bfb0..013243d2aec 100644 --- a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerInfraModule.java +++ b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerInfraModule.java @@ -16,7 +16,6 @@ import com.google.inject.multibindings.Multibinder; import org.eclipse.che.api.workspace.server.URLRewriter; import org.eclipse.che.api.workspace.server.spi.RuntimeInfrastructure; -import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiEnvVarProvider; import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiExternalEnvVarProvider; import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiInternalEnvVarProvider; import org.eclipse.che.infrastructure.docker.client.DockerRegistryDynamicAuthResolver; diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiEnvVarProvider.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiEnvVarProvider.java index 56091dedf68..20395d5be31 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiEnvVarProvider.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiEnvVarProvider.java @@ -10,18 +10,24 @@ */ package org.eclipse.che.api.workspace.server.spi.provision.env; +import javax.inject.Inject; import org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity; import org.eclipse.che.api.workspace.server.spi.InfrastructureException; import org.eclipse.che.commons.lang.Pair; -import javax.inject.Inject; - /** + * CHE_API endpoint var provided. For all currently supported infrastructures, it reuses {@link + * CheApiInternalEnvVarProvider} to provide the value. + * + * @deprecated this class shall soon be removed, as this variable is provided only for backward + * compatibility * @author Sergii Leshchenko + * @author Mykhailo Kuznietsov */ +@Deprecated public class CheApiEnvVarProvider implements EnvVarProvider { - /** Env variable for machine that contains url of Che API */ + /** Che API url */ public static final String CHE_API_VARIABLE = "CHE_API"; private final CheApiInternalEnvVarProvider cheApiInternalEnvVarProvider; diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/EnvVarEnvironmentProvisioner.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/EnvVarEnvironmentProvisioner.java index 249895c67ca..28a0c1e9878 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/EnvVarEnvironmentProvisioner.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/EnvVarEnvironmentProvisioner.java @@ -37,7 +37,6 @@ public void provision(RuntimeIdentity id, InternalEnvironment internalEnvironmen throws InfrastructureException { for (EnvVarProvider envVarProvider : envVarProviders) { Pair envVar = envVarProvider.get(id); - internalEnvironment .getMachines() .values() From d64d787d391a63fdbadb4e2e0276bd9b2a66ccf2 Mon Sep 17 00:00:00 2001 From: Mykhailo Kuznietsov Date: Tue, 24 Apr 2018 16:24:22 +0300 Subject: [PATCH 14/17] fixup! fixup! Remove odd classes --- dockerfiles/init/manifests/che.env | 2 -- 1 file changed, 2 deletions(-) diff --git a/dockerfiles/init/manifests/che.env b/dockerfiles/init/manifests/che.env index 106c7d2f926..6a0c6d8aa3c 100644 --- a/dockerfiles/init/manifests/che.env +++ b/dockerfiles/init/manifests/che.env @@ -189,8 +189,6 @@ # Che Server API Endpoint # The location of the API end point where dashboard and IDE clients will look for # interacting with the Che server, which we also call the workspace master. -# -# This property is deprecated and should not be used. #CHE_API=http://${CHE_HOST}:${CHE_PORT}/api # Che Server default websocket endpoint. From fbffe2a017aabfe01a3881261a5dc071ff12e762 Mon Sep 17 00:00:00 2001 From: Mykhailo Kuznietsov Date: Tue, 24 Apr 2018 16:41:26 +0300 Subject: [PATCH 15/17] fixup! fixup! fixup! Remove odd classes --- dockerfiles/init/manifests/che.env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockerfiles/init/manifests/che.env b/dockerfiles/init/manifests/che.env index 6a0c6d8aa3c..10a9825984c 100644 --- a/dockerfiles/init/manifests/che.env +++ b/dockerfiles/init/manifests/che.env @@ -160,7 +160,7 @@ # # Browser --> Che Server # 1. Default is 'http://localhost:${SERVER_PORT}/api'. -# 2. Else use the value of CHE_API_EXTERNAL +# 2. Else use the value of CHE_API # # Che Server --> Docker Daemon Progression: # 1. Use the value of CHE_INFRA_DOCKER_DAEMON__URL From 5984ec0f1cdcd6c99166ed2f5193ab3717da4a82 Mon Sep 17 00:00:00 2001 From: Mykhailo Kuznietsov Date: Wed, 25 Apr 2018 09:48:35 +0300 Subject: [PATCH 16/17] fixup! Merge branch 'master' of github.com:eclipse/che into che-9323 --- dockerfiles/init/modules/che/templates/che.env.erb | 1 + .../server/spi/provision/env/CheApiExternalEnvVarProvider.java | 1 + .../server/spi/provision/env/CheApiInternalEnvVarProvider.java | 1 + 3 files changed, 3 insertions(+) diff --git a/dockerfiles/init/modules/che/templates/che.env.erb b/dockerfiles/init/modules/che/templates/che.env.erb index 36424e95f5b..08b962aa7f5 100644 --- a/dockerfiles/init/modules/che/templates/che.env.erb +++ b/dockerfiles/init/modules/che/templates/che.env.erb @@ -51,6 +51,7 @@ CHE_LOGS_DIR=/logs CHE_WORKSPACE_LOGS=/logs/machines CHE_TEMPLATE_STORAGE=/data/templates + <% if ! @che_http_proxy.empty? or ! @che_https_proxy.empty? -%> JAVA_HTTP_PROXY_SET=-Dhttp.proxySet=true <% end -%> diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiExternalEnvVarProvider.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiExternalEnvVarProvider.java index 2285da19675..0a7afd7c93c 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiExternalEnvVarProvider.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiExternalEnvVarProvider.java @@ -22,6 +22,7 @@ public interface CheApiExternalEnvVarProvider extends EnvVarProvider { /** * Returns Che API environment variable which should be injected into machines. + * External API URL is meant to be used by external clients like browsers. * * @param runtimeIdentity which may be needed to evaluate environment variable value */ diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiInternalEnvVarProvider.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiInternalEnvVarProvider.java index 6282bc7565d..dd3bbc98d3b 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiInternalEnvVarProvider.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiInternalEnvVarProvider.java @@ -22,6 +22,7 @@ public interface CheApiInternalEnvVarProvider extends EnvVarProvider { /** * Returns Che API environment variable which should be injected into machines. + * Internal API URL is meant to be used from the inside of other machine containers. * * @param runtimeIdentity which may be needed to evaluate environment variable value */ From 773de1e163021bc03af56488512310001b86740e Mon Sep 17 00:00:00 2001 From: Mykhailo Kuznietsov Date: Wed, 25 Apr 2018 17:17:46 +0300 Subject: [PATCH 17/17] fixup! fixup! Merge branch 'master' of github.com:eclipse/che into che-9323 --- .../docker/DockerCheApiInternalEnvVarProvider.java | 7 +++++++ .../spi/provision/env/CheApiExternalEnvVarProvider.java | 4 ++-- .../spi/provision/env/CheApiInternalEnvVarProvider.java | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiInternalEnvVarProvider.java b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiInternalEnvVarProvider.java index 06fb71362bd..4ba1774a011 100644 --- a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiInternalEnvVarProvider.java +++ b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiInternalEnvVarProvider.java @@ -10,6 +10,7 @@ */ package org.eclipse.che.workspace.infrastructure.docker; +import com.google.common.base.Strings; import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; @@ -25,11 +26,17 @@ @Singleton public class DockerCheApiInternalEnvVarProvider implements CheApiInternalEnvVarProvider { + private static final String CHE_API_VARIABLE = "CHE_API"; + private final Pair apiEnvVar; @Inject public DockerCheApiInternalEnvVarProvider( @Named("che.infra.docker.master_api_endpoint") String apiEndpoint) { + String apiEndpointEnvVar = System.getenv(CHE_API_VARIABLE); + if (Strings.isNullOrEmpty(apiEndpoint) && !Strings.isNullOrEmpty(apiEndpointEnvVar)) { + apiEndpoint = apiEndpointEnvVar; + } apiEnvVar = Pair.of(CHE_API_INTERNAL_VARIABLE, apiEndpoint); } diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiExternalEnvVarProvider.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiExternalEnvVarProvider.java index 0a7afd7c93c..daa5553c144 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiExternalEnvVarProvider.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiExternalEnvVarProvider.java @@ -21,8 +21,8 @@ public interface CheApiExternalEnvVarProvider extends EnvVarProvider { String CHE_API_EXTERNAL_VARIABLE = "CHE_API_EXTERNAL"; /** - * Returns Che API environment variable which should be injected into machines. - * External API URL is meant to be used by external clients like browsers. + * Returns Che API environment variable which should be injected into machines. External API URL + * is meant to be used by external clients like browsers. * * @param runtimeIdentity which may be needed to evaluate environment variable value */ diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiInternalEnvVarProvider.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiInternalEnvVarProvider.java index dd3bbc98d3b..c255231be8d 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiInternalEnvVarProvider.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/CheApiInternalEnvVarProvider.java @@ -21,8 +21,8 @@ public interface CheApiInternalEnvVarProvider extends EnvVarProvider { String CHE_API_INTERNAL_VARIABLE = "CHE_API_INTERNAL"; /** - * Returns Che API environment variable which should be injected into machines. - * Internal API URL is meant to be used from the inside of other machine containers. + * Returns Che API environment variable which should be injected into machines. Internal API URL + * is meant to be used from the inside of other machines. * * @param runtimeIdentity which may be needed to evaluate environment variable value */