Skip to content
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

CHE-12395: Add 'extensions' field to meta model #12858

Merged
merged 1 commit into from
Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
import static java.lang.String.format;
import static java.util.Collections.singletonMap;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import io.fabric8.kubernetes.api.model.ConfigMap;
import io.fabric8.kubernetes.api.model.ConfigMapBuilder;
import io.fabric8.kubernetes.api.model.Container;
Expand All @@ -44,6 +44,7 @@
import org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity;
import org.eclipse.che.api.workspace.server.model.impl.VolumeImpl;
import org.eclipse.che.api.workspace.server.spi.InfrastructureException;
import org.eclipse.che.api.workspace.server.spi.InternalInfrastructureException;
import org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig;
import org.eclipse.che.api.workspace.server.spi.provision.env.AgentAuthEnableEnvVarProvider;
import org.eclipse.che.api.workspace.server.spi.provision.env.MachineTokenEnvVarProvider;
Expand Down Expand Up @@ -73,11 +74,10 @@ public abstract class BrokerEnvironmentFactory<E extends KubernetesEnvironment>
private static final String BROKER_VOLUME = "broker-config-volume";
private static final String CONF_FOLDER = "/broker-config";
private static final String CONFIG_FILE = "config.json";
private static final String CONTAINER_NAME_SUFFIX = "broker";
private static final String PLUGINS_VOLUME_NAME = "plugins";
private static final String BROKERS_POD_NAME = "che-plugin-broker";
private static final Gson GSON = new GsonBuilder().disableHtmlEscaping().create();

private final ObjectMapper objectMapper = new ObjectMapper();
private final String cheWebsocketEndpoint;
private final String brokerPullPolicy;
private final AgentAuthEnableEnvVarProvider authEnableEnvVarProvider;
Expand Down Expand Up @@ -204,13 +204,18 @@ private Pod newPod() {
.build();
}

private ConfigMap newConfigMap(String configMapName, Collection<PluginMeta> pluginsMetas) {
return new ConfigMapBuilder()
.withNewMetadata()
.withName(configMapName)
.endMetadata()
.withData(singletonMap(CONFIG_FILE, GSON.toJson(pluginsMetas)))
.build();
private ConfigMap newConfigMap(String configMapName, Collection<PluginMeta> pluginsMetas)
throws InternalInfrastructureException {
try {
return new ConfigMapBuilder()
.withNewMetadata()
.withName(configMapName)
.endMetadata()
.withData(singletonMap(CONFIG_FILE, objectMapper.writeValueAsString(pluginsMetas)))
.build();
} catch (JsonProcessingException e) {
throw new InternalInfrastructureException(e.getMessage(), e);
}
}

private EnvVar asEnvVar(Pair<String, String> envVar) {
Expand All @@ -222,7 +227,8 @@ private BrokerConfig createBrokerConfig(
@Nullable Collection<PluginMeta> pluginsMeta,
List<EnvVar> envVars,
String image,
Pod pod) {
Pod pod)
throws InternalInfrastructureException {

BrokerConfig brokerConfig = new BrokerConfig();
String configMapVolume = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class PluginMeta {
private String icon = null;
private String url = null;
private Map<String, String> attributes = null;
private List<String> extensions = null;

public PluginMeta name(String name) {
this.name = name;
Expand Down Expand Up @@ -206,4 +207,16 @@ public PluginMeta latestUpdateDate(String latestUpdateDate) {
public String getLatestUpdateDate() {
return latestUpdateDate;
}

public List<String> getExtensions() {
if (extensions == null) {
extensions = new ArrayList<>();
}
return extensions;
}

public PluginMeta extensions(List<String> extensions) {
this.extensions = extensions;
return this;
}
}