-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add internal and external API URL environment variables for workspaces #9475
Changes from 8 commits
61e2780
3ff7e90
4e07ca8
5b2695c
f1c129c
25133b1
f42a5a8
308c5a5
b8fa831
8ddeb71
d75bc47
9ee2ad7
aea61c2
58fffc9
ab94315
d64d787
fbffe2a
e9574ec
5984ec0
773de1e
95da304
08d85d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,6 @@ CHE_LOGS_DIR=/logs | |
CHE_WORKSPACE_LOGS=/logs/machines | ||
CHE_TEMPLATE_STORAGE=/data/templates | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this change if not needed |
||
<% if ! @che_http_proxy.empty? or ! @che_https_proxy.empty? -%> | ||
JAVA_HTTP_PROXY_SET=-Dhttp.proxySet=true | ||
<% end -%> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* 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.CheApiExternalEnvVarProvider; | ||
import org.eclipse.che.commons.lang.Pair; | ||
|
||
/** | ||
* Provides env variable to docker machine with url of Che external API. | ||
* | ||
* @author Mykhailo Kuznietsov | ||
*/ | ||
@Singleton | ||
public class DockerCheApiExternalEnvVarProvider implements CheApiExternalEnvVarProvider { | ||
|
||
private final Pair<String, String> apiEnvVar; | ||
|
||
@Inject | ||
public DockerCheApiExternalEnvVarProvider(@Named("che.api") String apiEndpoint) { | ||
apiEnvVar = Pair.of(CHE_API_EXTERNAL_VARIABLE, apiEndpoint); | ||
} | ||
|
||
@Override | ||
public Pair<String, String> get(RuntimeIdentity runtimeIdentity) { | ||
return apiEnvVar; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.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.CheApiInternalEnvVarProvider; | ||
import org.eclipse.che.commons.lang.Pair; | ||
|
||
/** | ||
* Provides env variable to docker machine with url of Che API. | ||
* | ||
* @author Mykhailo Kuznietsov | ||
*/ | ||
@Singleton | ||
public class DockerCheApiInternalEnvVarProvider implements CheApiInternalEnvVarProvider { | ||
|
||
private final Pair<String, String> apiEnvVar; | ||
|
||
@Inject | ||
public DockerCheApiInternalEnvVarProvider( | ||
@Named("che.infra.docker.master_api_endpoint") String apiEndpoint) { | ||
apiEnvVar = Pair.of(CHE_API_INTERNAL_VARIABLE, apiEndpoint); | ||
} | ||
|
||
@Override | ||
public Pair<String, String> get(RuntimeIdentity runtimeIdentity) { | ||
return new Pair<>(apiEnvVar.first, apiEnvVar.second); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String, String> get(RuntimeIdentity runtimeIdentity) throws InfrastructureException { | ||
return Pair.of(CHE_API_EXTERNAL_VARIABLE, cheServerEndpoint); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.CheApiInternalEnvVarProvider; | ||
import org.eclipse.che.commons.lang.Pair; | ||
|
||
/** | ||
* Provides env variable to Kubernetes machine with url of Che API. | ||
* | ||
* @author Mykhailo Kuznietsov | ||
*/ | ||
public class KubernetesCheApiInternalEnvVarProvider implements CheApiInternalEnvVarProvider { | ||
|
||
private final String cheServerEndpoint; | ||
|
||
@Inject | ||
public KubernetesCheApiInternalEnvVarProvider(@Named("che.api") String cheServerEndpoint) { | ||
this.cheServerEndpoint = cheServerEndpoint; | ||
} | ||
|
||
@Override | ||
public Pair<String, String> get(RuntimeIdentity runtimeIdentity) throws InfrastructureException { | ||
return Pair.of(CHE_API_INTERNAL_VARIABLE, cheServerEndpoint); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,8 @@ | |
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; | ||
import org.eclipse.che.workspace.infrastructure.docker.environment.dockerimage.DockerImageEnvironmentFactory; | ||
|
@@ -36,6 +38,8 @@ | |
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; | ||
import org.eclipse.che.workspace.infrastructure.kubernetes.server.ExternalServerExposerStrategy; | ||
|
@@ -67,6 +71,8 @@ protected void configure() { | |
bind(RemoveProjectOnWorkspaceRemove.class).asEagerSingleton(); | ||
|
||
bind(CheApiEnvVarProvider.class).to(KubernetesCheApiEnvVarProvider.class); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we still need |
||
bind(CheApiInternalEnvVarProvider.class).to(KubernetesCheApiInternalEnvVarProvider.class); | ||
bind(CheApiExternalEnvVarProvider.class).to(KubernetesCheApiExternalEnvVarProvider.class); | ||
|
||
MapBinder<String, WorkspaceVolumesStrategy> volumesStrategies = | ||
MapBinder.newMapBinder(binder(), String.class, WorkspaceVolumesStrategy.class); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 Mykhailo Kuznietsov */ | ||
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<String, String> get(RuntimeIdentity runtimeIdentity) throws InfrastructureException; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we need to remove this change too.