forked from hkolvenbach/che
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add internal and external API URL environment variables for workspaces (
- Loading branch information
1 parent
e10b0db
commit 637f2d4
Showing
13 changed files
with
203 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...a/org/eclipse/che/workspace/infrastructure/docker/DockerCheApiExternalEnvVarProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...workspace/infrastructure/kubernetes/provision/KubernetesCheApiInternalEnvVarProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
47 changes: 0 additions & 47 deletions
47
...che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiEnvVarProviderTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
.../org/eclipse/che/api/workspace/server/spi/provision/env/CheApiExternalEnvVarProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* 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. External API URL | ||
* is meant to be used by external clients like browsers. | ||
* | ||
* @param runtimeIdentity which may be needed to evaluate environment variable value | ||
*/ | ||
@Override | ||
Pair<String, String> get(RuntimeIdentity runtimeIdentity) throws InfrastructureException; | ||
} |
Oops, something went wrong.