Add che.workspace.plugin_registry_url information to workspace/settings Rest method (#11015)
Add che.workspace.plugin_registry_url information to workspace/settings Rest method6.19.x
parent
70ebef71e3
commit
77a00179db
|
|
@ -492,6 +492,11 @@ che.workspace.plugin_registry_url=NULL
|
|||
# plugins dependencies to a workspace
|
||||
che.workspace.plugin_broker.image=eclipse/che-plugin-broker:latest
|
||||
|
||||
# Workspace tooling plugins registry endpoint. Should be a valid HTTP URL.
|
||||
# Example: http://che-plugin-registry-eclipse-che.192.168.65.2.nip.io
|
||||
# In case Che plugins tooling is not needed value 'NULL' should be used
|
||||
che.workspace.plugin_registry_url=NULL
|
||||
|
||||
# Configures in which way secure servers will be protected with authentication.
|
||||
# Suitable values:
|
||||
# - 'default': no additionally authentication system will be enabled.
|
||||
|
|
|
|||
|
|
@ -154,8 +154,8 @@ export PLUGIN_REGISTRY_IMAGE=${PLUGIN_REGISTRY_IMAGE:-${DEFAULT_PLUGIN_REGISTRY_
|
|||
DEFAULT_PLUGIN_REGISTRY_IMAGE_PULL_POLICY="Always"
|
||||
export PLUGIN_REGISTRY_IMAGE_PULL_POLICY=${PLUGIN_REGISTRY_IMAGE_PULL_POLICY:-${DEFAULT_PLUGIN_REGISTRY_IMAGE_PULL_POLICY}}
|
||||
|
||||
DEFAULT_CHE_WORKSPACE_PLUGIN__REGISTRY__URL="NULL"
|
||||
export CHE_WORKSPACE_PLUGIN__REGISTRY__URL=${CHE_WORKSPACE_PLUGIN__REGISTRY__URL:-${DEFAULT_CHE_WORKSPACE_PLUGIN__REGISTRY__URL}}
|
||||
DEFAULT_PLUGIN__REGISTRY__URL="NULL"
|
||||
export PLUGIN__REGISTRY__URL=${PLUGIN__REGISTRY__URL:-${DEFAULT_PLUGIN__REGISTRY__URL}}
|
||||
|
||||
if [ "${ENABLE_SSL}" == "true" ]; then
|
||||
HTTP_PROTOCOL="https"
|
||||
|
|
@ -442,7 +442,7 @@ ${CHE_VAR_ARRAY}"
|
|||
|
||||
if [ "${DEPLOY_CHE_PLUGIN_REGISTRY}" == "true" ]; then
|
||||
PLUGIN_REGISTRY_ROUTE=$($OC_BINARY get route/che-plugin-registry --namespace=${CHE_OPENSHIFT_PROJECT} -o=jsonpath={'.spec.host'})
|
||||
CHE_WORKSPACE_PLUGIN__REGISTRY__URL="${HTTP_PROTOCOL}://${PLUGIN_REGISTRY_ROUTE}/"
|
||||
PLUGIN__REGISTRY__URL="${HTTP_PROTOCOL}://${PLUGIN_REGISTRY_ROUTE}"
|
||||
fi
|
||||
|
||||
${OC_BINARY} new-app -f ${BASE_DIR}/templates/che-server-template.yaml \
|
||||
|
|
@ -457,7 +457,7 @@ ${CHE_VAR_ARRAY}"
|
|||
-p CHE_INFRA_OPENSHIFT_PROJECT=${CHE_INFRA_OPENSHIFT_PROJECT} \
|
||||
-p CHE_INFRA_OPENSHIFT_OAUTH__IDENTITY__PROVIDER=${CHE_INFRA_OPENSHIFT_OAUTH__IDENTITY__PROVIDER} \
|
||||
-p TLS=${TLS} \
|
||||
-p CHE_WORKSPACE_PLUGIN__REGISTRY__URL=${CHE_WORKSPACE_PLUGIN__REGISTRY__URL} \
|
||||
-p CHE_WORKSPACE_PLUGIN__REGISTRY__URL=${PLUGIN__REGISTRY__URL} \
|
||||
${ENV}
|
||||
|
||||
if [ ${UPDATE_STRATEGY} == "Recreate" ]; then
|
||||
|
|
|
|||
|
|
@ -44,6 +44,12 @@ public final class Constants {
|
|||
|
||||
public static final String CHE_WORKSPACE_AUTO_START = "che.workspace.auto_start";
|
||||
|
||||
/**
|
||||
* Property name for Che plugin registry url. Key name of api workspace/settings method results.
|
||||
*/
|
||||
public static final String CHE_WORKSPACE_PLUGIN_REGISTRY_ULR =
|
||||
"che.workspace.plugin_registry_url";
|
||||
|
||||
/** Name for environment variable of machine name */
|
||||
public static final String CHE_MACHINE_NAME_ENV_VAR = "CHE_MACHINE_NAME";
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -18,9 +18,11 @@ import static java.util.stream.Collectors.toList;
|
|||
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
||||
import static org.eclipse.che.api.workspace.server.DtoConverter.asDto;
|
||||
import static org.eclipse.che.api.workspace.shared.Constants.CHE_WORKSPACE_AUTO_START;
|
||||
import static org.eclipse.che.api.workspace.shared.Constants.CHE_WORKSPACE_PLUGIN_REGISTRY_ULR;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
import com.google.common.collect.Maps;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
|
@ -72,6 +74,7 @@ import org.eclipse.che.api.workspace.shared.dto.RuntimeDto;
|
|||
import org.eclipse.che.api.workspace.shared.dto.ServerDto;
|
||||
import org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto;
|
||||
import org.eclipse.che.api.workspace.shared.dto.WorkspaceDto;
|
||||
import org.eclipse.che.commons.annotation.Nullable;
|
||||
import org.eclipse.che.commons.env.EnvironmentContext;
|
||||
|
||||
/**
|
||||
|
|
@ -87,6 +90,7 @@ public class WorkspaceService extends Service {
|
|||
private final WorkspaceManager workspaceManager;
|
||||
private final MachineTokenProvider machineTokenProvider;
|
||||
private final WorkspaceLinksGenerator linksGenerator;
|
||||
private final String pluginRegistryUrl;
|
||||
private final String apiEndpoint;
|
||||
private final boolean cheWorkspaceAutoStart;
|
||||
|
||||
|
|
@ -96,12 +100,14 @@ public class WorkspaceService extends Service {
|
|||
@Named(CHE_WORKSPACE_AUTO_START) boolean cheWorkspaceAutoStart,
|
||||
WorkspaceManager workspaceManager,
|
||||
MachineTokenProvider machineTokenProvider,
|
||||
WorkspaceLinksGenerator linksGenerator) {
|
||||
WorkspaceLinksGenerator linksGenerator,
|
||||
@Named(CHE_WORKSPACE_PLUGIN_REGISTRY_ULR) @Nullable String pluginRegistryUrl) {
|
||||
this.apiEndpoint = apiEndpoint;
|
||||
this.cheWorkspaceAutoStart = cheWorkspaceAutoStart;
|
||||
this.workspaceManager = workspaceManager;
|
||||
this.machineTokenProvider = machineTokenProvider;
|
||||
this.linksGenerator = linksGenerator;
|
||||
this.pluginRegistryUrl = pluginRegistryUrl;
|
||||
}
|
||||
|
||||
@POST
|
||||
|
|
@ -664,11 +670,18 @@ public class WorkspaceService extends Service {
|
|||
@ApiOperation(value = "Get workspace server configuration values")
|
||||
@ApiResponses({@ApiResponse(code = 200, message = "The response contains server settings")})
|
||||
public Map<String, String> getSettings() {
|
||||
return ImmutableMap.of(
|
||||
Builder<String, String> settings = ImmutableMap.builder();
|
||||
|
||||
settings.put(
|
||||
Constants.SUPPORTED_RECIPE_TYPES,
|
||||
Joiner.on(",").join(workspaceManager.getSupportedRecipes()),
|
||||
CHE_WORKSPACE_AUTO_START,
|
||||
Boolean.toString(cheWorkspaceAutoStart));
|
||||
Joiner.on(",").join(workspaceManager.getSupportedRecipes()));
|
||||
settings.put(CHE_WORKSPACE_AUTO_START, Boolean.toString(cheWorkspaceAutoStart));
|
||||
|
||||
if (pluginRegistryUrl != null) {
|
||||
settings.put(CHE_WORKSPACE_PLUGIN_REGISTRY_ULR, pluginRegistryUrl);
|
||||
}
|
||||
|
||||
return settings.build();
|
||||
}
|
||||
|
||||
private static Map<String, String> parseAttrs(List<String> attributes)
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ public class WorkspaceServiceTest {
|
|||
private static final String NAMESPACE = "user";
|
||||
private static final String USER_ID = "user123";
|
||||
private static final String API_ENDPOINT = "http://localhost:8080/api";
|
||||
private static final String CHE_WORKSPACE_PLUGIN_REGISTRY_ULR = "http://localhost:9898/plugins/";
|
||||
private static final Account TEST_ACCOUNT = new AccountImpl("anyId", NAMESPACE, "test");
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
|
@ -122,7 +123,13 @@ public class WorkspaceServiceTest {
|
|||
@BeforeMethod
|
||||
public void setup() {
|
||||
service =
|
||||
new WorkspaceService(API_ENDPOINT, true, wsManager, machineTokenProvider, linksGenerator);
|
||||
new WorkspaceService(
|
||||
API_ENDPOINT,
|
||||
true,
|
||||
wsManager,
|
||||
machineTokenProvider,
|
||||
linksGenerator,
|
||||
CHE_WORKSPACE_PLUGIN_REGISTRY_ULR);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -1132,8 +1139,12 @@ public class WorkspaceServiceTest {
|
|||
assertEquals(
|
||||
settings,
|
||||
ImmutableMap.of(
|
||||
Constants.SUPPORTED_RECIPE_TYPES, "dockerimage,dockerfile",
|
||||
Constants.CHE_WORKSPACE_AUTO_START, "true"));
|
||||
Constants.SUPPORTED_RECIPE_TYPES,
|
||||
"dockerimage,dockerfile",
|
||||
Constants.CHE_WORKSPACE_AUTO_START,
|
||||
"true",
|
||||
Constants.CHE_WORKSPACE_PLUGIN_REGISTRY_ULR,
|
||||
CHE_WORKSPACE_PLUGIN_REGISTRY_ULR));
|
||||
}
|
||||
|
||||
private static String unwrapError(Response response) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue