Move 'machineName' and 'plugin' attributes definition to Command class

Signed-off-by: Sergii Leshchenko <sleshche@redhat.com>
6.19.x
Sergii Leshchenko 2019-01-31 16:01:35 +02:00
parent 5907d1cad5
commit 99017c4553
2 changed files with 25 additions and 2 deletions

View File

@ -27,6 +27,19 @@ public interface Command {
*/
String WORKING_DIRECTORY_ATTRIBUTE = "workingDir";
/**
* {@link Command} attribute which indicates in which machine command must be run. It is optional,
* IDE should asks user to choose machine if null.
*/
String MACHINE_NAME_ATTRIBUTE = "machineName";
/**
* {@link Command} attribute which indicates in which plugin command must be run. If specified
* plugin has multiple containers then first containers should be used. Attribute value has the
* following format: `{PLUGIN_ID}:{PLUGIN_VERSION}`. For example: org.eclipse.sample-plugin:0.0.1
*/
String PLUGIN_ATTRIBUTE = "plugin";
/**
* Returns command name (i.e. 'start tomcat') The name should be unique per user in one workspace,
* which means that user may create only one command with the same name in the same workspace

View File

@ -216,7 +216,12 @@ public class KubernetesPluginsToolingApplier implements ChePluginsApplier {
machineConfig.getAttributes().put(CONTAINER_SOURCE_ATTRIBUTE, TOOL_CONTAINER_SOURCE);
kubernetesEnvironment.getMachines().put(machineName, machineConfig);
sidecarRelatedCommands.forEach(c -> c.getAttributes().put("machineName", machineName));
sidecarRelatedCommands.forEach(
c ->
c.getAttributes()
.put(
org.eclipse.che.api.core.model.workspace.config.Command.MACHINE_NAME_ATTRIBUTE,
machineName));
container
.getCommands()
@ -241,6 +246,7 @@ public class KubernetesPluginsToolingApplier implements ChePluginsApplier {
}
private static class CommandsResolver {
private final KubernetesEnvironment k8sEnvironment;
private final ArrayListMultimap<String, CommandImpl> pluginRefToCommand;
@ -252,7 +258,11 @@ public class KubernetesPluginsToolingApplier implements ChePluginsApplier {
.getCommands()
.forEach(
(c) -> {
String pluginRef = c.getAttributes().get("plugin");
String pluginRef =
c.getAttributes()
.get(
org.eclipse.che.api.core.model.workspace.config.Command
.PLUGIN_ATTRIBUTE);
if (pluginRef != null) {
pluginRefToCommand.put(pluginRef, c);
}