From 99017c4553e6c5d0d679ff8cc2b790e6b47cefb7 Mon Sep 17 00:00:00 2001 From: Sergii Leshchenko Date: Thu, 31 Jan 2019 16:01:35 +0200 Subject: [PATCH] Move 'machineName' and 'plugin' attributes definition to Command class Signed-off-by: Sergii Leshchenko --- .../api/core/model/workspace/config/Command.java | 13 +++++++++++++ .../wsplugins/KubernetesPluginsToolingApplier.java | 14 ++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/config/Command.java b/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/config/Command.java index 9cf13a7ad0..f4c9817473 100644 --- a/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/config/Command.java +++ b/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/config/Command.java @@ -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 diff --git a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/KubernetesPluginsToolingApplier.java b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/KubernetesPluginsToolingApplier.java index 4e4d393069..b65d3b4a8c 100644 --- a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/KubernetesPluginsToolingApplier.java +++ b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/KubernetesPluginsToolingApplier.java @@ -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 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); }