From 748300ffa9786cf25caf32ab95aa906b28fe7050 Mon Sep 17 00:00:00 2001 From: Oleksandr Garagatyi Date: Tue, 16 Apr 2019 11:49:42 +0300 Subject: [PATCH 01/19] Small refactoring of PluginFQNParser Signed-off-by: Oleksandr Garagatyi --- .../server/wsplugins/PluginFQNParser.java | 71 +++++++++++-------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java index 80746f7cb27..ddbb061f779 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Map; import org.eclipse.che.api.workspace.server.spi.InfrastructureException; @@ -57,60 +58,70 @@ public Collection parsePlugins(Map attributes) List metaFQNs = new ArrayList<>(); if (!isNullOrEmpty(pluginsAttribute)) { - String[] plugins = splitAttribute(pluginsAttribute); - if (plugins.length != 0) { - metaFQNs.addAll(parsePluginFQNs(plugins)); - } + metaFQNs.addAll(parsePluginFQNs(pluginsAttribute)); } if (!isNullOrEmpty(editorAttribute)) { - String[] editor = splitAttribute(editorAttribute); - if (editor.length > 1) { + Collection editorsFQNs = parsePluginFQNs(editorAttribute); + if (editorsFQNs.size() > 1) { throw new InfrastructureException( "Multiple editors found in workspace config attributes. " + "Only one editor is supported per workspace."); } - metaFQNs.addAll(parsePluginFQNs(editor)); + metaFQNs.addAll(editorsFQNs); } return metaFQNs; } - private Collection parsePluginFQNs(String... plugins) throws InfrastructureException { + private Collection parsePluginFQNs(String attribute) throws InfrastructureException { + + String[] plugins = splitAttribute(attribute); + if (plugins.length == 0) { + return Collections.emptyList(); + } + List collectedFQNs = new ArrayList<>(); for (String plugin : plugins) { - URI repo = null; - String idVersionString; - final int idVersionTagDelimiter = plugin.lastIndexOf("/"); - idVersionString = plugin.substring(idVersionTagDelimiter + 1); - if (idVersionTagDelimiter > -1) { - try { - repo = new URI(plugin.substring(0, idVersionTagDelimiter)); - } catch (URISyntaxException e) { - throw new InfrastructureException( - String.format( - "Plugin registry URL is incorrect. Problematic plugin entry: %s", plugin)); - } - } - String[] idAndVersion = idVersionString.split(":"); - if (idAndVersion.length != 2 || idAndVersion[0].isEmpty() || idAndVersion[1].isEmpty()) { - throw new InfrastructureException( - String.format("Plugin format is illegal. Problematic plugin entry: %s", plugin)); - } + PluginFQN pFQN = parsePlugin(plugin); + if (collectedFQNs .stream() .anyMatch( - p -> p.getId().equals(idAndVersion[0]) && p.getVersion().equals(idAndVersion[1]))) { + p -> p.getId().equals(pFQN.getId()) && p.getVersion().equals(pFQN.getVersion()))) { throw new InfrastructureException( String.format( "Invalid Che tooling plugins configuration: plugin %s:%s is duplicated", - idAndVersion[0], idAndVersion[1])); // even if different repos + pFQN.getId(), pFQN.getVersion())); // even if different repos } - collectedFQNs.add(new PluginFQN(repo, idAndVersion[0], idAndVersion[1])); + collectedFQNs.add(pFQN); } return collectedFQNs; } + private PluginFQN parsePlugin(String plugin) throws InfrastructureException { + URI repo = null; + String idVersionString; + final int idVersionTagDelimiter = plugin.lastIndexOf("/"); + idVersionString = plugin.substring(idVersionTagDelimiter + 1); + if (idVersionTagDelimiter > -1) { + try { + repo = new URI(plugin.substring(0, idVersionTagDelimiter)); + } catch (URISyntaxException e) { + throw new InfrastructureException( + String.format( + "Plugin registry URL is incorrect. Problematic plugin entry: %s", plugin)); + } + } + String[] idAndVersion = idVersionString.split(":"); + if (idAndVersion.length != 2 || idAndVersion[0].isEmpty() || idAndVersion[1].isEmpty()) { + throw new InfrastructureException( + String.format("Plugin format is illegal. Problematic plugin entry: %s", plugin)); + } + + return new PluginFQN(repo, idAndVersion[0], idAndVersion[1]); + } + private String[] splitAttribute(String attribute) { String[] plugins = attribute.split(","); - return Arrays.stream(plugins).map(s -> s.trim()).toArray(String[]::new); + return Arrays.stream(plugins).map(String::trim).toArray(String[]::new); } } From b0d4140fea2881623fefa18eb70fd1d8e560016e Mon Sep 17 00:00:00 2001 From: Oleksandr Garagatyi Date: Thu, 25 Apr 2019 11:15:23 +0300 Subject: [PATCH 02/19] Rework Signed-off-by: Oleksandr Garagatyi --- .../webapp/WEB-INF/classes/che/che.properties | 24 +++---- .../core/model/workspace/config/Command.java | 3 +- .../workspace-editors.controller.ts | 36 +++++------ .../workspace-editors/workspace-editors.html | 12 ++-- .../workspace-plugins.controller.ts | 34 +++++----- .../workspace-plugins/workspace-plugins.html | 13 ++-- .../components/api/plugin-registry.factory.ts | 8 ++- .../src/main/resources/stacks.json | 48 +++++++------- .../KubernetesPluginsToolingApplier.java | 10 ++- .../kubernetes/wsplugins/MachineResolver.java | 18 +++--- .../wsplugins/MachineResolverBuilder.java | 18 ++++-- .../BrokerEnvironmentFactory.java | 5 +- .../SidecarToolingProvisionerTest.java | 8 +-- .../KubernetesPluginsToolingApplierTest.java | 35 ++++++----- .../wsplugins/MachineResolverTest.java | 13 ++-- .../BrokerEnvironmentFactoryTest.java | 8 +-- .../convert/DefaultEditorProvisioner.java | 27 +++++--- .../EditorComponentToWorkspaceApplier.java | 4 +- .../PluginComponentToWorkspaceApplier.java | 3 + .../server/urlfactory/URLFactoryBuilder.java | 2 +- .../server/wsplugins/PluginFQNParser.java | 62 ++++++++++++------- .../server/wsplugins/model/PluginBase.java | 26 +++++++- .../server/wsplugins/model/PluginFQN.java | 22 ++----- .../server/wsplugins/PluginFQNParserTest.java | 38 ++++++------ 24 files changed, 266 insertions(+), 211 deletions(-) diff --git a/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/che/che.properties b/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/che/che.properties index 05c7e183a13..d7970675e3e 100644 --- a/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/che/che.properties +++ b/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/che/che.properties @@ -546,8 +546,8 @@ che.singleport.wildcard_domain.ipless=false # Docker image of Che plugin broker app that resolves workspace tooling configuration and copies # plugins dependencies to a workspace -che.workspace.plugin_broker.init.image=eclipse/che-init-plugin-broker:v0.15.4 -che.workspace.plugin_broker.unified.image=eclipse/che-unified-plugin-broker:v0.15.4 +che.workspace.plugin_broker.init.image=eclipse/che-init-plugin-broker:v0.16 +che.workspace.plugin_broker.unified.image=eclipse/che-unified-plugin-broker:v0.16 # Docker image of Che plugin broker app that resolves workspace tooling configuration and copies # plugins dependencies to a workspace @@ -559,7 +559,7 @@ che.workspace.plugin_broker.wait_timeout_min=3 # 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=https://che-plugin-registry.openshift.io +che.workspace.plugin_registry_url=https://che-plugin-registry.openshift.io/v2 # Configures in which way secure servers will be protected with authentication. # Suitable values: @@ -619,24 +619,24 @@ che.wsagent.cors.enabled=true ## Factory defaults. # Editor and plugin which will be used for factories which are created from remote git repository # which doesn't contain any Che-specific workspace descriptors (like .devfile of .factory.json) -che.factory.default_editor=org.eclipse.che.editor.theia:1.0.0 +che.factory.default_editor=eclipse/che-theia/1.0.0 # multiple plugins must be comma-separated, for example: -# pluginFooName:pluginFooVersion,pluginBarName:pluginBarVersion -che.factory.default_plugins=che-machine-exec-plugin:0.0.1 +# pluginFooPublisher/pluginFooName/pluginFooVersion,pluginBarPublisher/pluginBarName/pluginBarVersion +che.factory.default_plugins=eclipse/che-machine-exec-plugin/0.0.1 ## Devfile settings # Devfile defaults # -# Default Editor that should be provisioned into Devfile if there is no other Editor specified -# Format is `editorId:editorVersion` value. +# Default Editor that should be provisioned into Devfile if there is no specified Editor +# Format is `editorPublisher/editorId/editorVersion` value. # `NULL` or absence of value means that default editor should not be provisioned. -che.workspace.devfile.default_editor=org.eclipse.che.editor.theia:1.0.0 +che.workspace.devfile.default_editor=eclipse/che-theia/1.0.0 # Default Plugins which should be provisioned for Default Editor. # All the plugins from this list that are not explicitly mentioned in the user-defined devfile # will be provisioned but only when the default editor is used or if the user-defined editor is # the same as the default one (even if in different version). -# Format is comma-separated `pluginId:pluginVersion` values, for example -# che-theia-exec-plugin:0.0.1,che-theia-terminal-plugin:0.0.1 -che.workspace.devfile.default_editor.plugins=che-machine-exec-plugin:0.0.1 +# Format is comma-separated `pluginPublisher/pluginId/pluginVersion` values, for example +# eclipse/che-theia-exec-plugin/0.0.1,eclipse/che-theia-terminal-plugin/0.0.1 +che.workspace.devfile.default_editor.plugins=eclipse/che-machine-exec-plugin/0.0.1 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 f4c98174731..08e86c19d43 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 @@ -36,7 +36,8 @@ public interface Command { /** * {@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 + * following format: `{PLUGIN_PUBLISHER}/{PLUGIN_NAME}/{PLUGIN_VERSION}`. For example: + * eclipse/sample-plugin/0.0.1 */ String PLUGIN_ATTRIBUTE = "plugin"; diff --git a/dashboard/src/app/workspaces/workspace-details/workspace-editors/workspace-editors.controller.ts b/dashboard/src/app/workspaces/workspace-details/workspace-editors/workspace-editors.controller.ts index d9ad7f240cf..2de9392fe36 100644 --- a/dashboard/src/app/workspaces/workspace-details/workspace-editors/workspace-editors.controller.ts +++ b/dashboard/src/app/workspaces/workspace-details/workspace-editors/workspace-editors.controller.ts @@ -10,9 +10,9 @@ * Red Hat, Inc. - initial API and implementation */ 'use strict'; -import {IPlugin, PluginRegistry} from '../../../../components/api/plugin-registry.factory'; +import { IPlugin, PluginRegistry } from '../../../../components/api/plugin-registry.factory'; import IWorkspaceConfig = che.IWorkspaceConfig; -import {CheNotification} from '../../../../components/notification/che-notification.factory'; +import { CheNotification } from '../../../../components/notification/che-notification.factory'; const PLUGIN_SEPARATOR = ','; const PLUGIN_VERSION_SEPARATOR = ':'; @@ -35,7 +35,7 @@ export class WorkspaceEditorsController { onChange: Function; isLoading: boolean; - editorOrderBy = 'name'; + editorOrderBy = 'displayName'; editors: Array = []; selectedEditor: string = ''; editorFilter: any; @@ -46,7 +46,7 @@ export class WorkspaceEditorsController { * Default constructor that is using resource */ constructor(pluginRegistry: PluginRegistry, cheListHelperFactory: che.widget.ICheListHelperFactory, $scope: ng.IScope, - cheNotification: CheNotification) { + cheNotification: CheNotification) { this.pluginRegistry = pluginRegistry; this.cheNotification = cheNotification; @@ -57,7 +57,7 @@ export class WorkspaceEditorsController { cheListHelperFactory.removeHelper(helperId); }); - this.editorFilter = {name: ''}; + this.editorFilter = { displayName: '' }; const deRegistrationFn = $scope.$watch(() => { return this.workspaceConfig; @@ -87,7 +87,7 @@ export class WorkspaceEditorsController { if (item.type === EDITOR_TYPE) { this.editors.push(item); }; - }); + }); this.updateEditors(); }, (error: any) => { @@ -102,8 +102,8 @@ export class WorkspaceEditorsController { * @param str {string} a string to filter projects names */ onSearchChanged(str: string): void { - this.editorFilter.name = str; - this.cheListHelper.applyFilter('name', this.editorFilter); + this.editorFilter.displayName = str; + this.cheListHelper.applyFilter('displayName', this.editorFilter); } /** @@ -112,13 +112,11 @@ export class WorkspaceEditorsController { * @param {IPlugin} plugin */ updateEditor(plugin: IPlugin): void { - let name = plugin.id + PLUGIN_VERSION_SEPARATOR + plugin.version; - if (plugin.type === EDITOR_TYPE) { - this.selectedEditor = plugin.isEnabled ? name : ''; + this.selectedEditor = plugin.isEnabled ? plugin.id : ''; this.workspaceConfig.attributes.editor = this.selectedEditor; } - + this.cleanupInstallers(); this.onChange(); } @@ -127,9 +125,9 @@ export class WorkspaceEditorsController { * Clean up all the installers in all machines, when plugin is selected. */ cleanupInstallers(): void { - let defaultEnv : string = this.workspaceConfig.defaultEnv; - let machines : any = this.workspaceConfig.environments[defaultEnv].machines; - let machineNames : Array = Object.keys(machines); + let defaultEnv: string = this.workspaceConfig.defaultEnv; + let machines: any = this.workspaceConfig.environments[defaultEnv].machines; + let machineNames: Array = Object.keys(machines); machineNames.forEach((machineName: string) => { machines[machineName].installers = []; }); @@ -141,9 +139,9 @@ export class WorkspaceEditorsController { private updateEditors(): void { // get selected plugins from workspace configuration attribute - "editor": this.selectedEditor = this.workspaceConfig && this.workspaceConfig.attributes && this.workspaceConfig.attributes.editor ? - this.workspaceConfig.attributes.editor : ''; + this.workspaceConfig.attributes.editor : ''; - // check each editor's enabled state: + // check each editor's enabled state: this.editors.forEach((editor: IPlugin) => { editor.isEnabled = this.isEditorEnabled(editor); }); @@ -157,8 +155,6 @@ export class WorkspaceEditorsController { * @returns {boolean} the editor's enabled state */ private isEditorEnabled(editor: IPlugin): boolean { - // name in the format: id:version - let name = editor.id + PLUGIN_VERSION_SEPARATOR + editor.version; - return name === this.selectedEditor; + return editor.id === this.selectedEditor; } } diff --git a/dashboard/src/app/workspaces/workspace-details/workspace-editors/workspace-editors.html b/dashboard/src/app/workspaces/workspace-details/workspace-editors/workspace-editors.html index 53752aa9848..c1b8601ae04 100644 --- a/dashboard/src/app/workspaces/workspace-details/workspace-editors/workspace-editors.html +++ b/dashboard/src/app/workspaces/workspace-details/workspace-editors/workspace-editors.html @@ -13,7 +13,7 @@ che-column-title="Enable"> @@ -26,12 +26,12 @@
+ ng-repeat="editor in workspaceEditorsController.editors | orderBy:[workspaceEditorsController.editorOrderBy, 'displayName' ]">
@@ -41,12 +41,13 @@ + plugin-switch="{{editor.displayName}}">
- {{editor.name}} + {{editor.displayName}} + ({{editor.publisher}} publisher)
@@ -67,4 +68,3 @@
- diff --git a/dashboard/src/app/workspaces/workspace-details/workspace-plugins/workspace-plugins.controller.ts b/dashboard/src/app/workspaces/workspace-details/workspace-plugins/workspace-plugins.controller.ts index 7c49e62464e..d7f0b353324 100644 --- a/dashboard/src/app/workspaces/workspace-details/workspace-plugins/workspace-plugins.controller.ts +++ b/dashboard/src/app/workspaces/workspace-details/workspace-plugins/workspace-plugins.controller.ts @@ -10,9 +10,9 @@ * Red Hat, Inc. - initial API and implementation */ 'use strict'; -import {IPlugin, PluginRegistry} from '../../../../components/api/plugin-registry.factory'; +import { IPlugin, PluginRegistry } from '../../../../components/api/plugin-registry.factory'; import IWorkspaceConfig = che.IWorkspaceConfig; -import {CheNotification} from '../../../../components/notification/che-notification.factory'; +import { CheNotification } from '../../../../components/notification/che-notification.factory'; const PLUGIN_SEPARATOR = ','; const PLUGIN_VERSION_SEPARATOR = ':'; @@ -35,7 +35,7 @@ export class WorkspacePluginsController { onChange: Function; isLoading: boolean; - pluginOrderBy = 'name'; + pluginOrderBy = 'displayName'; plugins: Array = []; selectedPlugins: Array = []; @@ -47,7 +47,7 @@ export class WorkspacePluginsController { * Default constructor that is using resource */ constructor(pluginRegistry: PluginRegistry, cheListHelperFactory: che.widget.ICheListHelperFactory, $scope: ng.IScope, - cheNotification: CheNotification) { + cheNotification: CheNotification) { this.pluginRegistry = pluginRegistry; this.cheNotification = cheNotification; @@ -58,7 +58,7 @@ export class WorkspacePluginsController { cheListHelperFactory.removeHelper(helperId); }); - this.pluginFilter = {name: ''}; + this.pluginFilter = { displayName: '' }; const deRegistrationFn = $scope.$watch(() => { return this.workspaceConfig; @@ -88,7 +88,7 @@ export class WorkspacePluginsController { if (item.type !== EDITOR_TYPE) { this.plugins.push(item); } - }); + }); this.updatePlugins(); }, (error: any) => { @@ -103,8 +103,8 @@ export class WorkspacePluginsController { * @param str {string} a string to filter projects names */ onSearchChanged(str: string): void { - this.pluginFilter.name = str; - this.cheListHelper.applyFilter('name', this.pluginFilter); + this.pluginFilter.displayName = str; + this.cheListHelper.applyFilter('displayName', this.pluginFilter); } /** @@ -113,13 +113,11 @@ export class WorkspacePluginsController { * @param {IPlugin} plugin */ updatePlugin(plugin: IPlugin): void { - let name = plugin.id + PLUGIN_VERSION_SEPARATOR + plugin.version; - if (plugin.type !== EDITOR_TYPE) { if (plugin.isEnabled) { - this.selectedPlugins.push(name); + this.selectedPlugins.push(plugin.id); } else { - this.selectedPlugins.splice(this.selectedPlugins.indexOf(name), 1); + this.selectedPlugins.splice(this.selectedPlugins.indexOf(plugin.id), 1); } this.workspaceConfig.attributes.plugins = this.selectedPlugins.join(PLUGIN_SEPARATOR); } @@ -132,9 +130,9 @@ export class WorkspacePluginsController { * Clean up all the installers in all machines, when plugin is selected. */ cleanupInstallers(): void { - let defaultEnv : string = this.workspaceConfig.defaultEnv; - let machines : any = this.workspaceConfig.environments[defaultEnv].machines; - let machineNames : Array = Object.keys(machines); + let defaultEnv: string = this.workspaceConfig.defaultEnv; + let machines: any = this.workspaceConfig.environments[defaultEnv].machines; + let machineNames: Array = Object.keys(machines); machineNames.forEach((machineName: string) => { machines[machineName].installers = []; }); @@ -151,7 +149,7 @@ export class WorkspacePluginsController { this.plugins.forEach((plugin: IPlugin) => { plugin.isEnabled = this.isPluginEnabled(plugin); }); - this.cheListHelper.setList(this.plugins, 'name'); + this.cheListHelper.setList(this.plugins, 'displayName'); } /** @@ -160,8 +158,6 @@ export class WorkspacePluginsController { * @returns {boolean} the plugin's enabled state */ private isPluginEnabled(plugin: IPlugin): boolean { - // name in the format: id:version - let name = plugin.id + PLUGIN_VERSION_SEPARATOR + plugin.version; - return this.selectedPlugins.indexOf(name) >= 0; + return this.selectedPlugins.indexOf(plugin.id) >= 0 } } diff --git a/dashboard/src/app/workspaces/workspace-details/workspace-plugins/workspace-plugins.html b/dashboard/src/app/workspaces/workspace-details/workspace-plugins/workspace-plugins.html index 68376ec069c..7dec5d2e919 100644 --- a/dashboard/src/app/workspaces/workspace-details/workspace-plugins/workspace-plugins.html +++ b/dashboard/src/app/workspaces/workspace-details/workspace-plugins/workspace-plugins.html @@ -5,7 +5,7 @@
@@ -23,7 +23,7 @@ che-column-title="Enable"> @@ -36,12 +36,12 @@
+ ng-repeat="plugin in workspacePluginsController.cheListHelper.getVisibleItems() | orderBy:[workspacePluginsController.pluginOrderBy, 'displayName' ]">
@@ -51,12 +51,13 @@ + plugin-switch="{{plugin.displayName}}">
- {{plugin.name}} + {{plugin.displayName}} + ({{plugin.publisher}} publisher)
diff --git a/dashboard/src/components/api/plugin-registry.factory.ts b/dashboard/src/components/api/plugin-registry.factory.ts index 18d61234156..bfbad73e734 100644 --- a/dashboard/src/components/api/plugin-registry.factory.ts +++ b/dashboard/src/components/api/plugin-registry.factory.ts @@ -14,6 +14,12 @@ export interface IPlugin { id: string; name: string; + publisher: string; + deprecate: { + autoMigrate: boolean; + migrateTo: string; + }; + displayName: string; type: string; version: string; description?: string; @@ -41,7 +47,7 @@ export class PluginRegistry { } fetchPlugins(location: string): ng.IPromise> { - let promise = this.$http({'method': 'GET', 'url': location + '/plugins/'}); + let promise = this.$http({ 'method': 'GET', 'url': location + '/plugins/' }); return promise.then((result: any) => { return result.data; }); diff --git a/ide/che-core-ide-stacks/src/main/resources/stacks.json b/ide/che-core-ide-stacks/src/main/resources/stacks.json index 4905e8e5ffb..5a6e1a62375 100644 --- a/ide/che-core-ide-stacks/src/main/resources/stacks.json +++ b/ide/che-core-ide-stacks/src/main/resources/stacks.json @@ -214,8 +214,8 @@ } ], "attributes": { - "plugins": "che-machine-exec-plugin:0.0.1", - "editor": "org.eclipse.che.editor.theia:1.0.0" + "plugins": "eclipse/che-machine-exec-plugin/0.0.1", + "editor": "eclipse/theia/1.0.0" }, "links": [] }, @@ -283,8 +283,8 @@ }, "projects": [], "attributes": { - "editor": "org.eclipse.che.editor.theia:1.0.0", - "plugins": "che-machine-exec-plugin:0.0.1" + "plugins": "eclipse/che-machine-exec-plugin/0.0.1", + "editor": "eclipse/theia/1.0.0" }, "commands": [], "links": [] @@ -357,8 +357,8 @@ }, "projects": [], "attributes": { - "editor": "org.eclipse.che.editor.theia:1.0.0", - "plugins": "che-machine-exec-plugin:0.0.1" + "plugins": "eclipse/che-machine-exec-plugin/0.0.1", + "editor": "eclipse/theia/1.0.0" }, "commands": [], "links": [] @@ -430,8 +430,8 @@ }, "projects": [], "attributes": { - "editor": "org.eclipse.che.editor.theia:1.0.0", - "plugins": "che-machine-exec-plugin:0.0.1" + "plugins": "eclipse/che-machine-exec-plugin/0.0.1", + "editor": "eclipse/theia/1.0.0" }, "commands": [ { @@ -800,10 +800,10 @@ "defaultEnv": "default", "description": null, "attributes": { - "plugins": "che-machine-exec-plugin:0.0.1,org.eclipse.che.vscode-redhat.java:0.38.0", - "editor": "org.eclipse.che.editor.theia:next", - "sidecar.org.eclipse.che.vscode-redhat.java.memory_limit": "1500Mi", - "sidecar.org.eclipse.che.editor.theia.memory_limit": "512Mi" + "plugins": "eclipse/che-machine-exec-plugin/0.0.1,redhat/java/0.38.0", + "editor": "eclipse/theia/next", + "sidecar.redhat/java.memory_limit": "1500Mi", + "sidecar.eclipse/theia.memory_limit": "512Mi" }, "commands": [] }, @@ -882,10 +882,10 @@ "defaultEnv": "default", "description": null, "attributes": { - "plugins": "che-machine-exec-plugin:0.0.1,org.eclipse.che.vscode-redhat.java:0.38.0", - "editor": "org.eclipse.che.editor.theia:next", - "sidecar.org.eclipse.che.vscode-redhat.java.memory_limit": "1500Mi", - "sidecar.org.eclipse.che.editor.theia.memory_limit": "512Mi" + "plugins": "eclipse/che-machine-exec-plugin/0.0.1,redhat/java/0.38.0", + "editor": "eclipse/theia/next", + "sidecar.redhat/java.memory_limit": "1500Mi", + "sidecar.eclipse/theia.memory_limit": "512Mi" }, "commands": [] }, @@ -2703,10 +2703,10 @@ "defaultEnv": "default", "description": null, "attributes": { - "sidecar.org.eclipse.che.editor.theia.memory_limit": "512Mi", - "sidecar.ms-python.python.memory_limit": "512Mi", - "editor": "org.eclipse.che.editor.theia:next", - "plugins": "che-machine-exec-plugin:0.0.1,ms-python.python:2019.2.5433" + "sidecar.eclipse/theia.memory_limit": "512Mi", + "sidecar.ms-python/python.memory_limit": "512Mi", + "editor": "eclipse/theia/next", + "plugins": "eclipse/che-machine-exec-plugin/0.0.1,ms-python/python/2019.2.5433" }, "links": [] }, @@ -2770,10 +2770,10 @@ "defaultEnv": "default", "description": null, "attributes": { - "sidecar.org.eclipse.che.editor.theia.memory_limit": "512Mi", - "sidecar.ms-vscode.go.memory_limit": "512Mi", - "editor": "org.eclipse.che.editor.theia:next", - "plugins": "che-machine-exec-plugin:0.0.1,ms-vscode.go:0.9.2" + "sidecar.eclipse/theia.memory_limit": "512Mi", + "sidecar.ms-vscode/go.memory_limit": "512Mi", + "editor": "eclipse/theia/next", + "plugins": "eclipse/che-machine-exec-plugin/0.0.1,ms-vscode/go/0.9.2" }, "links": [] }, 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 04a3ea0159e..a7ed7052e5a 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 @@ -212,7 +212,8 @@ private void addSidecar( .setDefaultSidecarMemorySizeAttribute(defaultSidecarMemoryLimitBytes) .setAttributes(kubernetesEnvironment.getAttributes()) .setProjectsRootPathEnvVar(projectsRootEnvVariableProvider.get(runtimeIdentity)) - .setPluginId(chePlugin.getId()) + .setPluginPublisher(chePlugin.getPublisher()) + .setPluginName(chePlugin.getName()) .build(); InternalMachineConfig machineConfig = machineResolver.resolve(); @@ -240,10 +241,7 @@ private void addSidecar( private CommandImpl asCommand(String machineName, Command command) { CommandImpl cmd = - new CommandImpl( - command.getName(), - command.getCommand().stream().collect(Collectors.joining(" ")), - "custom"); + new CommandImpl(command.getName(), String.join(" ", command.getCommand()), "custom"); cmd.getAttributes().put(WORKING_DIRECTORY_ATTRIBUTE, command.getWorkingDir()); cmd.getAttributes().put(MACHINE_NAME_ATTRIBUTE, machineName); return cmd; @@ -276,7 +274,7 @@ public CommandsResolver(KubernetesEnvironment k8sEnvironment) { private Collection resolve(ChePlugin chePlugin) { List containers = chePlugin.getContainers(); - String pluginRef = chePlugin.getId() + ":" + chePlugin.getVersion(); + String pluginRef = chePlugin.getId(); Collection pluginsCommands = pluginRefToCommand.removeAll(pluginRef); if (pluginsCommands.isEmpty()) { diff --git a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/MachineResolver.java b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/MachineResolver.java index 835522edaf8..0fadd3c3721 100644 --- a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/MachineResolver.java +++ b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/MachineResolver.java @@ -39,7 +39,8 @@ /** @author Oleksandr Garagatyi */ public class MachineResolver { - private final String pluginId; + private final String pluginName; + private final String pluginPublisherName; private final Container container; private final CheContainer cheContainer; private final String defaultSidecarMemoryLimitBytes; @@ -48,14 +49,16 @@ public class MachineResolver { private final Pair projectsRootPathEnvVar; public MachineResolver( - String pluginId, + String pluginPublisher, + String pluginName, Pair projectsRootPathEnvVar, Container container, CheContainer cheContainer, String defaultSidecarMemoryLimitBytes, List containerEndpoints, Map wsAttributes) { - this.pluginId = pluginId; + this.pluginName = pluginName; + this.pluginPublisherName = pluginPublisher + "/" + pluginName; this.container = container; this.cheContainer = cheContainer; this.defaultSidecarMemoryLimitBytes = defaultSidecarMemoryLimitBytes; @@ -78,8 +81,9 @@ private void normalizeMemory(Container container, InternalMachineConfig machineC if (ramLimit == 0) { machineConfig.getAttributes().put(MEMORY_LIMIT_ATTRIBUTE, defaultSidecarMemoryLimitBytes); } - String overriddenSidecarMemLimit = - wsAttributes.get(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, pluginId)); + // Use plugin_publisher/plugin_name to find overriding of memory limit. + String overriddenSidecarMemLimit = wsAttributes + .get(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, pluginPublisherName)); if (!isNullOrEmpty(overriddenSidecarMemLimit)) { machineConfig .getAttributes() @@ -108,7 +112,7 @@ private void normalizeMemory(Container container, InternalMachineConfig machineC + " the mountSources attribute to true instead and remove the manual volume" + " mount in the plugin. After that the mount path of the sources will be" + " available automatically in the '%s' environment variable.", - pluginId, + pluginPublisherName, PROJECTS_VOLUME_NAME, container.getName(), volume.getMountPath(), @@ -126,7 +130,7 @@ private void normalizeMemory(Container container, InternalMachineConfig machineC private ServerConfigImpl toServer(ChePluginEndpoint endpoint) { ServerConfigImpl serverConfig = - new ServerConfigImpl().withPort(Integer.toString(endpoint.getTargetPort()) + "/tcp"); + new ServerConfigImpl().withPort(endpoint.getTargetPort() + "/tcp"); serverConfig.getAttributes().put("internal", Boolean.toString(!endpoint.isPublic())); for (Entry attribute : endpoint.getAttributes().entrySet()) { switch (attribute.getKey()) { diff --git a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/MachineResolverBuilder.java b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/MachineResolverBuilder.java index 9b04263fc26..2bfaaa7f3a8 100644 --- a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/MachineResolverBuilder.java +++ b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/MachineResolverBuilder.java @@ -27,7 +27,8 @@ public class MachineResolverBuilder { private List containerEndpoints; private Map wsAttributes; private Pair projectsRootPathEnvVar; - private String pluginId; + private String pluginPublisher; + private String pluginName; public MachineResolver build() { if (container == null @@ -36,12 +37,14 @@ public MachineResolver build() { || wsAttributes == null || containerEndpoints == null || projectsRootPathEnvVar == null - || pluginId == null) { + || pluginPublisher == null + || pluginName == null) { throw new IllegalStateException(); } return new MachineResolver( - pluginId, + pluginPublisher, + pluginName, projectsRootPathEnvVar, container, cheContainer, @@ -82,8 +85,13 @@ public MachineResolverBuilder setProjectsRootPathEnvVar( return this; } - public MachineResolverBuilder setPluginId(String pluginId) { - this.pluginId = pluginId; + public MachineResolverBuilder setPluginPublisher(String pluginPublisher) { + this.pluginPublisher = pluginPublisher; + return this; + } + + public MachineResolverBuilder setPluginName(String pluginName) { + this.pluginName = pluginName; return this; } } diff --git a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactory.java b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactory.java index d0787eef898..ab68daedd72 100644 --- a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactory.java +++ b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactory.java @@ -50,7 +50,6 @@ import org.eclipse.che.workspace.infrastructure.kubernetes.Names; import org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment; import org.eclipse.che.workspace.infrastructure.kubernetes.util.Containers; -import org.eclipse.che.workspace.infrastructure.kubernetes.wsplugins.BrokersResult; /** * Creates {@link KubernetesEnvironment} with everything needed to deploy Plugin brokers. @@ -101,10 +100,8 @@ public BrokerEnvironmentFactory( /** * Creates {@link KubernetesEnvironment} with everything needed to deploy Plugin broker. * - * @param pluginFQN fully qualified names of plugins that needs to be resolved by the broker + * @param pluginFQNs fully qualified names of plugins that needs to be resolved by the broker * @param runtimeID ID of the runtime the broker would be started - * @param brokersResult needs to be called with {@link BrokersResult#oneMoreBroker()} for each - * broker to allow proper waiting of execution of all the brokers * @return kubernetes environment (or its extension) with the Plugin broker objects */ public E create(Collection pluginFQNs, RuntimeIdentity runtimeID) diff --git a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/SidecarToolingProvisionerTest.java b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/SidecarToolingProvisionerTest.java index 79a13a00a07..a4ea8281eb6 100644 --- a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/SidecarToolingProvisionerTest.java +++ b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/SidecarToolingProvisionerTest.java @@ -47,7 +47,6 @@ public class SidecarToolingProvisionerTest { private static final String RECIPE_TYPE = "TestingRecipe"; private static final String PLUGIN_FQN_ID = "TestPluginId"; - private static final String PLUGIN_FQN_VERSION = "TestPluginVersion"; @Mock private StartSynchronizer startSynchronizer; @Mock private KubernetesBrokerInitContainerApplier brokerApplier; @@ -60,11 +59,10 @@ public class SidecarToolingProvisionerTest { private static Map environmentAttributesBase = ImmutableMap.of( - "editor", "org.eclipse.che.editor.theia:1.0.0", - "plugins", "che-machine-exec-plugin:0.0.1"); + "editor", "eclipse/theia/1.0.0", + "plugins", "eclipse/che-machine-exec-plugin/0.0.1"); - private Collection pluginFQNs = - ImmutableList.of(new PluginFQN(null, PLUGIN_FQN_ID, PLUGIN_FQN_VERSION)); + private Collection pluginFQNs = ImmutableList.of(new PluginFQN(null, PLUGIN_FQN_ID)); private SidecarToolingProvisioner provisioner; diff --git a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/KubernetesPluginsToolingApplierTest.java b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/KubernetesPluginsToolingApplierTest.java index 87524da0639..c1f0db99c87 100644 --- a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/KubernetesPluginsToolingApplierTest.java +++ b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/KubernetesPluginsToolingApplierTest.java @@ -84,7 +84,7 @@ /** @author Alexander Garagatyi */ @Listeners(MockitoTestNGListener.class) public class KubernetesPluginsToolingApplierTest { - private static final String TEST_IMAGE = "testImage/test:test"; + private static final String TEST_IMAGE = "testImage/test/test"; private static final String TEST_IMAGE_POLICY = "IfNotPresent"; private static final String ENV_VAR = "PLUGINS_ENV_VAR"; private static final String ENV_VAR_VALUE = "PLUGINS_ENV_VAR_VALUE"; @@ -143,7 +143,7 @@ public void shouldProvisionPluginsCommandsToEnvironment() throws Exception { applier.apply( runtimeIdentity, internalEnvironment, - singletonList(createChePlugin("plugin", createContainer("container", pluginCommand)))); + singletonList(createChePlugin(createContainer("container", pluginCommand)))); // then List envCommands = internalEnvironment.getCommands(); @@ -152,7 +152,7 @@ public void shouldProvisionPluginsCommandsToEnvironment() throws Exception { assertEquals(envCommand.getName(), pluginCommand.getName()); assertEquals( envCommand.getCommandLine(), - pluginCommand.getCommand().stream().collect(Collectors.joining(" "))); + String.join(" ", pluginCommand.getCommand())); assertEquals(envCommand.getType(), "custom"); assertEquals( envCommand.getAttributes().get(WORKING_DIRECTORY_ATTRIBUTE), pluginCommand.getWorkingDir()); @@ -162,8 +162,8 @@ public void shouldProvisionPluginsCommandsToEnvironment() throws Exception { @Test public void shouldResolveMachineNameForCommandsInEnvironment() throws Exception { // given - ChePlugin chePlugin = createChePlugin("plugin", createContainer("container")); - String pluginRef = chePlugin.getId() + ":" + chePlugin.getVersion(); + ChePlugin chePlugin = createChePlugin(createContainer("container")); + String pluginRef = chePlugin.getId(); CommandImpl pluginCommand = new CommandImpl("test-command", "echo Hello World!", "custom"); pluginCommand.getAttributes().put("plugin", pluginRef); @@ -187,8 +187,8 @@ public void shouldResolveMachineNameForCommandsInEnvironment() throws Exception public void shouldFillInWarningIfChePluginDoesNotHaveAnyContainersButThereAreRelatedCommands() throws Exception { // given - ChePlugin chePlugin = createChePlugin("plugin"); - String pluginRef = chePlugin.getId() + ":" + chePlugin.getVersion(); + ChePlugin chePlugin = createChePlugin(); + String pluginRef = chePlugin.getId(); CommandImpl pluginCommand = new CommandImpl("test-command", "echo Hello World!", "custom"); pluginCommand.getAttributes().put("plugin", pluginRef); @@ -206,7 +206,7 @@ public void shouldFillInWarningIfChePluginDoesNotHaveAnyContainersButThereAreRel Warnings.COMMAND_IS_CONFIGURED_IN_PLUGIN_WITHOUT_CONTAINERS_WARNING_CODE); assertEquals( warning.getMessage(), - "There are configured commands for plugin 'some-id:0.0.3' that doesn't have any containers"); + "There are configured commands for plugin 'some-id' that doesn't have any containers"); } @Test @@ -214,7 +214,7 @@ public void shouldFillInWarningIfChePluginDoesNotHaveAnyContainersButThereAreRel shouldNotFillInWarningIfChePluginDoesNotHaveAnyContainersAndThereAreNotRelatedCommands() throws Exception { // given - ChePlugin chePlugin = createChePlugin("plugin"); + ChePlugin chePlugin = createChePlugin(); // when applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin)); @@ -227,8 +227,8 @@ public void shouldFillInWarningIfChePluginDoesNotHaveAnyContainersButThereAreRel public void shouldFillInWarningIfChePluginHasMultiplyContainersButThereAreRelatedCommands() throws Exception { // given - ChePlugin chePlugin = createChePlugin("plugin", createContainer(), createContainer()); - String pluginRef = chePlugin.getId() + ":" + chePlugin.getVersion(); + ChePlugin chePlugin = createChePlugin(createContainer(), createContainer()); + String pluginRef = chePlugin.getId(); CommandImpl pluginCommand = new CommandImpl("test-command", "echo Hello World!", "custom"); pluginCommand.getAttributes().put("plugin", pluginRef); @@ -246,14 +246,14 @@ public void shouldFillInWarningIfChePluginHasMultiplyContainersButThereAreRelate Warnings.COMMAND_IS_CONFIGURED_IN_PLUGIN_WITH_MULTIPLY_CONTAINERS_WARNING_CODE); assertEquals( warning.getMessage(), - "There are configured commands for plugin 'some-id:0.0.3' that has multiply containers. Commands will be configured to be run in first container"); + "There are configured commands for plugin '" + pluginRef + "' that has multiply containers. Commands will be configured to be run in first container"); } @Test public void shouldNotFillInWarningIfChePluginHasMultiplyContainersAndThereAreNotRelatedCommands() throws Exception { // given - ChePlugin chePlugin = createChePlugin("plugin", createContainer(), createContainer()); + ChePlugin chePlugin = createChePlugin(createContainer(), createContainer()); // when applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin)); @@ -672,10 +672,13 @@ private ChePlugin createChePlugin(CheContainer... containers) { } private ChePlugin createChePlugin(String name, CheContainer... containers) { + String version = "0.0.3"; + String publisher = "somePublisher"; ChePlugin plugin = new ChePlugin(); plugin.setName(name); - plugin.setId("some-id"); - plugin.setVersion("0.0.3"); + plugin.setPublisher(publisher); + plugin.setId(publisher + "/" + name + "/" + version); + plugin.setVersion(version); plugin.setContainers(Arrays.asList(containers)); return plugin; } @@ -895,6 +898,6 @@ private void addExpectedServer( serverAttributes.put("internal", Boolean.toString(!isExternal)); servers.put( portName, - new ServerConfigImpl(Integer.toString(port) + "/tcp", protocol, path, serverAttributes)); + new ServerConfigImpl(port + "/tcp", protocol, path, serverAttributes)); } } diff --git a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/MachineResolverTest.java b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/MachineResolverTest.java index 753c012d8d9..0ee7ca3c9b1 100644 --- a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/MachineResolverTest.java +++ b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/MachineResolverTest.java @@ -46,7 +46,9 @@ public class MachineResolverTest { private static final String DEFAULT_MEM_LIMIT = "100001"; - private static final String PLUGIN_ID = "testplugin"; + private static final String PLUGIN_NAME = "testplugin"; + private static final String PLUGIN_PUBLISHER = "testpublisher"; + private static final String PLUGIN_PUBLISHER_NAME = PLUGIN_PUBLISHER + "/" + PLUGIN_NAME; private static final String PROJECTS_ENV_VAR = "env_with_with_location_of_projects"; private static final String PROJECTS_MOUNT_PATH = "/wherever/i/may/roam"; @@ -64,7 +66,8 @@ public void setUp() { wsAttributes = new HashMap<>(); resolver = new MachineResolver( - PLUGIN_ID, + PLUGIN_PUBLISHER, + PLUGIN_NAME, new Pair<>(PROJECTS_ENV_VAR, PROJECTS_MOUNT_PATH), container, cheContainer, @@ -146,7 +149,8 @@ public void shouldSetDefaultMemLimitIfSidecarDoesNotHaveOne() throws Infrastruct public void shouldSetMemoryLimitOfASidecarIfCorrespondingWSConfigAttributeIsSet( String attributeValue, String expectedMemLimit) throws InfrastructureException { wsAttributes.put( - format(Constants.SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, PLUGIN_ID), attributeValue); + format(Constants.SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, PLUGIN_PUBLISHER_NAME), + attributeValue); InternalMachineConfig machineConfig = resolver.resolve(); @@ -171,7 +175,8 @@ public void shouldOverrideMemoryLimitOfASidecarIfCorrespondingWSConfigAttributeI String expectedMemLimit = toBytesString(attributeValue); Containers.addRamLimit(container, 123456789); wsAttributes.put( - format(Constants.SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, PLUGIN_ID), attributeValue); + format(Constants.SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, PLUGIN_PUBLISHER_NAME), + attributeValue); InternalMachineConfig machineConfig = resolver.resolve(); diff --git a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactoryTest.java b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactoryTest.java index 7311fcb1586..a83885a6b69 100644 --- a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactoryTest.java +++ b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactoryTest.java @@ -90,7 +90,7 @@ protected KubernetesEnvironment doCreate(BrokersConfigs brokersConfigs) { @Test public void testInitBrokerContainer() throws Exception { // given - Collection pluginFQNs = singletonList(new PluginFQN(null, "id", "version")); + Collection pluginFQNs = singletonList(new PluginFQN(null, "id")); ArgumentCaptor captor = ArgumentCaptor.forClass(BrokersConfigs.class); // when @@ -128,7 +128,7 @@ public void testInitBrokerContainer() throws Exception { @Test public void shouldNameContainersAfterPluginBrokerImage() throws Exception { // given - Collection pluginFQNs = singletonList(new PluginFQN(null, "id", "version")); + Collection pluginFQNs = singletonList(new PluginFQN(null, "id")); ArgumentCaptor captor = ArgumentCaptor.forClass(BrokersConfigs.class); // when @@ -153,8 +153,8 @@ public void shouldCreateConfigmapWithPluginFQNs() throws Exception { // given Collection pluginFQNs = ImmutableList.of( - new PluginFQN(null, "testPlugin1", "testver1"), - new PluginFQN(new URI("testregistry"), "testPlugin2", "testver2")); + new PluginFQN(null, "testPlugin1"), + new PluginFQN(new URI("testregistry"), "testPlugin2")); ArgumentCaptor captor = ArgumentCaptor.forClass(BrokersConfigs.class); // when diff --git a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisioner.java b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisioner.java index 26852bec870..5c6822a0363 100644 --- a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisioner.java +++ b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisioner.java @@ -23,6 +23,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.regex.Pattern; import javax.inject.Inject; import javax.inject.Named; import org.eclipse.che.api.core.model.workspace.devfile.Component; @@ -38,21 +39,25 @@ public class DefaultEditorProvisioner { private final String defaultEditorRef; - private final String defaultEditorId; - private final Map defaultPluginsIdToRef; + private final String defaultEditor; + private final Map defaultPluginsToRefs; + private final Pattern PLUGIN_PATTERN = + Pattern.compile("(.*/)?(?[^/]+)/(?[^/]+)/(?[^/]+)"); @Inject public DefaultEditorProvisioner( @Named("che.workspace.devfile.default_editor") String defaultEditorRef, @Named("che.workspace.devfile.default_editor.plugins") String[] defaultPluginsRefs) { this.defaultEditorRef = Strings.isNullOrEmpty(defaultEditorRef) ? null : defaultEditorRef; - this.defaultEditorId = this.defaultEditorRef == null ? null : getId(this.defaultEditorRef); - this.defaultPluginsIdToRef = - Arrays.stream(defaultPluginsRefs).collect(toMap(this::getId, identity())); + this.defaultEditor = this.defaultEditorRef == null ? null : getId(this.defaultEditorRef); + this.defaultPluginsToRefs = + Arrays.stream(defaultPluginsRefs) + .collect(toMap(this::getPluginPublisherAndName, identity())); } /** - * Provision default editor if there is no any another editor and default plugins for it. + * Provision default editor if there is no editor. Also provisions default plugins for default + * editor regardless whether it is provisioned or set by user. * * @param devfile devfile where editor and plugins should be provisioned */ @@ -77,7 +82,7 @@ public void apply(DevfileImpl devfile) { isDefaultEditorUsed = true; } else { Component editor = editorOpt.get(); - isDefaultEditorUsed = defaultEditorId.equals(resolveIdAndVersion(editor.getId()).first); + isDefaultEditorUsed = defaultEditor.equals(resolveIdAndVersion(editor.getId()).first); } if (isDefaultEditorUsed) { @@ -86,8 +91,9 @@ public void apply(DevfileImpl devfile) { } private void provisionDefaultPlugins(List components) { - Map missingPluginsIdToRef = new HashMap<>(defaultPluginsIdToRef); + Map missingPluginsIdToRef = new HashMap<>(defaultPluginsToRefs); + // TODO components .stream() .filter(t -> PLUGIN_COMPONENT_TYPE.equals(t.getType())) @@ -102,6 +108,11 @@ private String getId(String reference) { return resolveIdAndVersion(reference).first; } + private String getPluginPublisherAndName(String reference) { + return resolveIdAndVersion(reference).first; + } + + // todo private Pair resolveIdAndVersion(String ref) { int lastSlashPosition = ref.lastIndexOf("/"); String idVersion; diff --git a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplier.java b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplier.java index ccc7ad63035..7b2ce35bb17 100644 --- a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplier.java +++ b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplier.java @@ -65,9 +65,11 @@ public void apply( .put(EDITOR_COMPONENT_ALIAS_WORKSPACE_ATTRIBUTE, editorComponentAlias); } - String editorIdVersion = resolveIdAndVersion(editorComponent.getId()); + // TODO how to properly parse this and separate publisher/name/version + String editorIdVersion = resolveIdAndVersion(editorId); if (memoryLimit != null) { String editorIdPart = editorIdVersion.split(":")[0]; + // TODO workspaceConfig .getAttributes() .put(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, editorIdPart), memoryLimit); diff --git a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplier.java b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplier.java index 48173ad5612..acbbe0f48a3 100644 --- a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplier.java +++ b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplier.java @@ -58,6 +58,7 @@ public void apply( String workspacePluginsAttribute = workspaceConfig.getAttributes().get(WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE); + // TODO workspaceConfig .getAttributes() .put( @@ -67,6 +68,7 @@ public void apply( String pluginsAliases = workspaceConfig.getAttributes().get(PLUGINS_COMPONENTS_ALIASES_WORKSPACE_ATTRIBUTE); if (pluginComponent.getAlias() != null) { + // TODO workspaceConfig .getAttributes() .put( @@ -74,6 +76,7 @@ public void apply( append(pluginsAliases, pluginComponent.getId() + "=" + pluginComponent.getAlias())); } + // TODO String pluginIdVersion = resolveIdAndVersion(pluginComponent.getId()); String memoryLimit = pluginComponent.getMemoryLimit(); if (memoryLimit != null) { diff --git a/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/urlfactory/URLFactoryBuilder.java b/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/urlfactory/URLFactoryBuilder.java index 47830462888..6cae38b4d3e 100644 --- a/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/urlfactory/URLFactoryBuilder.java +++ b/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/urlfactory/URLFactoryBuilder.java @@ -53,7 +53,7 @@ public class URLFactoryBuilder { @Inject public URLFactoryBuilder( - @Named("che.factory.default_editor") String defaultCheEditor, + @Named("che.factory.default_editor") String defaultCheEditor, // TODO @Named("che.factory.default_plugins") String defaultChePlugins, URLFetcher urlFetcher, DevfileManager devfileManager) { diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java index ddbb061f779..ee027f942e9 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java @@ -12,6 +12,7 @@ package org.eclipse.che.api.workspace.server.wsplugins; import static com.google.common.base.Strings.isNullOrEmpty; +import static java.lang.String.format; import static java.util.Collections.emptyList; import com.google.common.annotations.Beta; @@ -23,6 +24,8 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.eclipse.che.api.workspace.server.spi.InfrastructureException; import org.eclipse.che.api.workspace.server.wsplugins.model.PluginFQN; import org.eclipse.che.api.workspace.shared.Constants; @@ -38,6 +41,14 @@ @Beta public class PluginFQNParser { + private static final String INCORRECT_PLUGIN_FORMAT_TEMPLATE = + "Plugin '%s' has incorrect format. Should be: 'registryURL/publisher/name/version' or 'registryURL/name/version' or 'name:version' or 'registryURL/name:version'"; + private static final Pattern PLUGIN_PATTERN_V1 = + Pattern.compile("(?(https?://)[-./\\w]+/)?(?\\w+):(?[-\\w.]+)"); + private static final Pattern PLUGIN_PATTERN_V2 = + Pattern.compile( + "(?(https?://)[-./\\w]+/)?(?[-a-z0-9]+/[-a-z0-9]+/[-.a-z0-9]+)"); + /** * Parses a workspace attributes map into a collection of {@link PluginFQN}. * @@ -81,43 +92,48 @@ private Collection parsePluginFQNs(String attribute) throws Infrastru List collectedFQNs = new ArrayList<>(); for (String plugin : plugins) { - PluginFQN pFQN = parsePlugin(plugin); + PluginFQN pFQN = parsePluginFQN(plugin); - if (collectedFQNs - .stream() - .anyMatch( - p -> p.getId().equals(pFQN.getId()) && p.getVersion().equals(pFQN.getVersion()))) { + if (collectedFQNs.stream().anyMatch(p -> p.getId().equals(pFQN.getId()))) { throw new InfrastructureException( - String.format( - "Invalid Che tooling plugins configuration: plugin %s:%s is duplicated", - pFQN.getId(), pFQN.getVersion())); // even if different repos + format( + "Invalid Che tooling plugins configuration: plugin %s is duplicated", + pFQN.getId())); // even if different registries } collectedFQNs.add(pFQN); } return collectedFQNs; } - private PluginFQN parsePlugin(String plugin) throws InfrastructureException { - URI repo = null; - String idVersionString; - final int idVersionTagDelimiter = plugin.lastIndexOf("/"); - idVersionString = plugin.substring(idVersionTagDelimiter + 1); - if (idVersionTagDelimiter > -1) { + private PluginFQN parsePluginFQN(String plugin) throws InfrastructureException { + String registry; + String id; + URI registryURI = null; + Matcher matcher = PLUGIN_PATTERN_V1.matcher(plugin); + if (matcher.matches()) { + registry = matcher.group("registry"); + id = matcher.group("name") + "/" + matcher.group("version"); + } else { + matcher = PLUGIN_PATTERN_V2.matcher(plugin); + if (matcher.matches()) { + registry = matcher.group("registry"); + id = matcher.group("id"); + } else { + throw new InfrastructureException(format(INCORRECT_PLUGIN_FORMAT_TEMPLATE, plugin)); + } + } + if (!isNullOrEmpty(registry)) { try { - repo = new URI(plugin.substring(0, idVersionTagDelimiter)); + registryURI = new URI(registry); } catch (URISyntaxException e) { throw new InfrastructureException( - String.format( - "Plugin registry URL is incorrect. Problematic plugin entry: %s", plugin)); + format( + "Plugin registry URL '%s' is incorrect. Problematic plugin entry: '%s'", + registry, plugin)); } } - String[] idAndVersion = idVersionString.split(":"); - if (idAndVersion.length != 2 || idAndVersion[0].isEmpty() || idAndVersion[1].isEmpty()) { - throw new InfrastructureException( - String.format("Plugin format is illegal. Problematic plugin entry: %s", plugin)); - } - return new PluginFQN(repo, idAndVersion[0], idAndVersion[1]); + return new PluginFQN(registryURI, id); } private String[] splitAttribute(String attribute) { diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/PluginBase.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/PluginBase.java index fbdf66f3625..dc85da77e1f 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/PluginBase.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/PluginBase.java @@ -19,6 +19,7 @@ public class PluginBase { private String name = null; + private String publisher = null; private String id = null; private String version = null; private List containers = new ArrayList<>(); @@ -59,6 +60,19 @@ public PluginBase version(String version) { return this; } + public String getPublisher() { + return publisher; + } + + public void setPublisher(String publisher) { + this.publisher = publisher; + } + + public PluginBase publisher(String publisher) { + this.publisher = publisher; + return this; + } + public String getVersion() { return version; } @@ -127,6 +141,7 @@ public boolean equals(Object o) { PluginBase chePlugin = (PluginBase) o; return Objects.equals(getName(), chePlugin.getName()) && Objects.equals(getId(), chePlugin.getId()) + && Objects.equals(getPublisher(), chePlugin.getPublisher()) && Objects.equals(getVersion(), chePlugin.getVersion()) && Objects.equals(getContainers(), chePlugin.getContainers()) && Objects.equals(getEndpoints(), chePlugin.getEndpoints()) @@ -136,7 +151,13 @@ public boolean equals(Object o) { @Override public int hashCode() { return Objects.hash( - getName(), getId(), getVersion(), getContainers(), getEndpoints(), getWorkspaceEnv()); + getName(), + getId(), + getVersion(), + getPublisher(), + getContainers(), + getEndpoints(), + getWorkspaceEnv()); } @Override @@ -148,6 +169,9 @@ public String toString() { + ", id='" + id + '\'' + + ", publisher='" + + publisher + + '\'' + ", version='" + version + '\'' diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/PluginFQN.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/PluginFQN.java index 6235a995e1b..a1c5a69f800 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/PluginFQN.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/PluginFQN.java @@ -17,7 +17,7 @@ import java.util.Objects; /** - * Represents full information about plugin, including registry address, id and version. + * Represents full information about plugin, including registry address and id. * * @author Max Shaposhnyk */ @@ -26,12 +26,10 @@ public class PluginFQN { private URI registry; private String id; - private String version; - public PluginFQN(URI registry, String id, String version) { + public PluginFQN(URI registry, String id) { this.registry = registry; this.id = id; - this.version = version; } public URI getRegistry() { @@ -50,17 +48,9 @@ public void setId(String id) { this.id = id; } - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - @Override public int hashCode() { - return Objects.hash(getRegistry(), getId(), getVersion()); + return Objects.hash(getRegistry(), getId()); } @Override @@ -72,13 +62,11 @@ public boolean equals(Object obj) { return false; } PluginFQN other = (PluginFQN) obj; - return Objects.equals(id, other.id) - && Objects.equals(version, other.version) - && Objects.equals(registry, other.registry); + return Objects.equals(id, other.id) && Objects.equals(registry, other.registry); } @Override public String toString() { - return String.format("{id:%s, version:%s, registry:%s}", this.id, this.version, this.registry); + return String.format("{id:%s, registry:%s}", this.id, this.registry); } } diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java index ad63c10f9e2..82bed7e3a46 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java @@ -35,9 +35,6 @@ @Listeners(MockitoTestNGListener.class) public class PluginFQNParserTest { - private static final String PLUGIN_FORMAT = "%s/%s:%s"; - private static final String PLUGIN_FORMAT_WITHOUT_REGISTRY = "%s:%s"; - private PluginFQNParser parser; @BeforeClass @@ -97,8 +94,8 @@ public void shouldThrowExceptionWhenDuplicatePluginDefined() throws Exception { Map attributes = createAttributes( "", - formatPlugin("http://testregistry1:8080", "testplugin", "1.0"), - formatPlugin("http://testregistry2:8080", "testplugin", "1.0")); + formatPlugin("http://testregistry1:8080", "testplugin/1.0"), + formatPlugin("http://testregistry2:8080", "testplugin/1.0")); parser.parsePlugins(attributes); } @@ -112,8 +109,8 @@ public void shouldDetectDuplicatedPluginsIfTheyArePrefixedSuffixedWithEmptySpace Map attributes = createAttributes( "", - " " + formatPlugin("http://testregistry1:8080", "testplugin", "1.0"), - formatPlugin("http://testregistry2:8080", "testplugin", "1.0") + " "); + " " + formatPlugin("http://testregistry1:8080", "testplugin/1.0"), + formatPlugin("http://testregistry2:8080", "testplugin/1.0") + " "); parser.parsePlugins(attributes); } @@ -121,10 +118,11 @@ public void shouldDetectDuplicatedPluginsIfTheyArePrefixedSuffixedWithEmptySpace @DataProvider(name = "invalidAttributeStringProvider") public static Object[][] invalidAttributeStringProvider() { return new Object[][] { - {formatPlugin("http://bad registry url", "testplugin", "1.0")}, - {formatPlugin("http://testregistry:8080", "bad:pluginname", "1.0")}, - {formatPlugin("http://testregistry:8080", "", "emptyID")}, - {formatPlugin("http://testregistry:8080", "emptyVersion", "")} + {formatPlugin("http://bad registry url", "testplugin/1.0")}, + {formatPlugin("http://testregistry:8080", "bad:pluginname/1.0")}, + {formatPlugin("http://testregistry:8080", "/version")}, + {formatPlugin("http://testregistry:8080", "id/")}, + {formatPlugin("http://testregistry:8080", "")} }; } @@ -132,11 +130,11 @@ public static Object[][] invalidAttributeStringProvider() { // (String description, List expectedPlugins, Map attributes) @DataProvider(name = "validAttributesProvider") public static Object[][] validAttributesProvider() { - PluginFQN basicEditor = new PluginFQN(URI.create("http://registry:8080"), "editor", "ver"); - PluginFQN withRegistry = new PluginFQN(URI.create("http://registry:8080"), "plugin", "1.0"); - PluginFQN noRegistry = new PluginFQN(null, "pluginNoRegistry", "2.0"); + PluginFQN basicEditor = new PluginFQN(URI.create("http://registry:8080"), "editor/ver"); + PluginFQN withRegistry = new PluginFQN(URI.create("http://registry:8080"), "plugin/1.0"); + PluginFQN noRegistry = new PluginFQN(null, "pluginNoRegistry/2.0"); PluginFQN pathRegistry = - new PluginFQN(URI.create("http://registry/multiple/path/"), "pluginPathRegistry", "3.0"); + new PluginFQN(URI.create("http://registry/multiple/path/"), "pluginPathRegistry/3.0"); return new Object[][] { { "Test plugin with registry", @@ -193,19 +191,19 @@ public static Object[][] validAttributesProvider() { } private static String[] formatPlugins(PluginFQN... plugins) { - return Arrays.stream(plugins).map(p -> formatPlugin(p)).toArray(String[]::new); + return Arrays.stream(plugins).map(PluginFQNParserTest::formatPlugin).toArray(String[]::new); } private static String formatPlugin(PluginFQN plugin) { String registry = plugin.getRegistry() == null ? null : plugin.getRegistry().toString(); - return formatPlugin(registry, plugin.getId(), plugin.getVersion()); + return formatPlugin(registry, plugin.getId()); } - private static String formatPlugin(String registry, String id, String version) { + private static String formatPlugin(String registry, String id) { if (registry == null) { - return String.format(PLUGIN_FORMAT_WITHOUT_REGISTRY, id, version); + return id; } else { - return String.format(PLUGIN_FORMAT, registry, id, version); + return registry + "/" + id; } } From 151e2c0f1ccb5b1c1e9a0761cc44d69550383d71 Mon Sep 17 00:00:00 2001 From: Oleksandr Garagatyi Date: Thu, 25 Apr 2019 15:01:30 +0300 Subject: [PATCH 03/19] fixup! Rework --- .../kubernetes/wsplugins/MachineResolver.java | 4 ++-- .../KubernetesPluginsToolingApplierTest.java | 22 ++++++++--------- .../BrokerEnvironmentFactoryTest.java | 10 ++++---- .../server/wsplugins/PluginFQNParser.java | 20 +++++----------- .../server/wsplugins/PluginFQNParserTest.java | 24 +++++++++---------- 5 files changed, 34 insertions(+), 46 deletions(-) diff --git a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/MachineResolver.java b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/MachineResolver.java index 0fadd3c3721..e3e613f4f66 100644 --- a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/MachineResolver.java +++ b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/MachineResolver.java @@ -82,8 +82,8 @@ private void normalizeMemory(Container container, InternalMachineConfig machineC machineConfig.getAttributes().put(MEMORY_LIMIT_ATTRIBUTE, defaultSidecarMemoryLimitBytes); } // Use plugin_publisher/plugin_name to find overriding of memory limit. - String overriddenSidecarMemLimit = wsAttributes - .get(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, pluginPublisherName)); + String overriddenSidecarMemLimit = + wsAttributes.get(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, pluginPublisherName)); if (!isNullOrEmpty(overriddenSidecarMemLimit)) { machineConfig .getAttributes() diff --git a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/KubernetesPluginsToolingApplierTest.java b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/KubernetesPluginsToolingApplierTest.java index c1f0db99c87..a9747eb804a 100644 --- a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/KubernetesPluginsToolingApplierTest.java +++ b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/KubernetesPluginsToolingApplierTest.java @@ -126,7 +126,7 @@ public void setUp() { internalEnvironment.addPod(pod); internalEnvironment.getMachines().putAll(machines); - when(projectsRootEnvVariableProvider.get(any())) + lenient().when(projectsRootEnvVariableProvider.get(any())) .thenReturn(new Pair<>("projects_root", "/somewhere/over/the/rainbow")); } @@ -150,13 +150,11 @@ public void shouldProvisionPluginsCommandsToEnvironment() throws Exception { assertEquals(envCommands.size(), 1); CommandImpl envCommand = envCommands.get(0); assertEquals(envCommand.getName(), pluginCommand.getName()); - assertEquals( - envCommand.getCommandLine(), - String.join(" ", pluginCommand.getCommand())); + assertEquals(envCommand.getCommandLine(), String.join(" ", pluginCommand.getCommand())); assertEquals(envCommand.getType(), "custom"); assertEquals( envCommand.getAttributes().get(WORKING_DIRECTORY_ATTRIBUTE), pluginCommand.getWorkingDir()); - assertEquals(envCommand.getAttributes().get(MACHINE_NAME_ATTRIBUTE), "plugin-container"); + assertEquals(envCommand.getAttributes().get(MACHINE_NAME_ATTRIBUTE), "some-name-container"); } @Test @@ -180,14 +178,14 @@ public void shouldResolveMachineNameForCommandsInEnvironment() throws Exception assertEquals(envCommand.getType(), pluginCommand.getType()); assertEquals(envCommand.getCommandLine(), pluginCommand.getCommandLine()); assertEquals(envCommand.getAttributes().get("plugin"), pluginRef); - assertEquals(envCommand.getAttributes().get(MACHINE_NAME_ATTRIBUTE), "plugin-container"); + assertEquals(envCommand.getAttributes().get(MACHINE_NAME_ATTRIBUTE), "some-name-container"); } @Test public void shouldFillInWarningIfChePluginDoesNotHaveAnyContainersButThereAreRelatedCommands() throws Exception { // given - ChePlugin chePlugin = createChePlugin(); + ChePlugin chePlugin = createChePlugin("custom-name"); String pluginRef = chePlugin.getId(); CommandImpl pluginCommand = new CommandImpl("test-command", "echo Hello World!", "custom"); @@ -206,7 +204,7 @@ public void shouldFillInWarningIfChePluginDoesNotHaveAnyContainersButThereAreRel Warnings.COMMAND_IS_CONFIGURED_IN_PLUGIN_WITHOUT_CONTAINERS_WARNING_CODE); assertEquals( warning.getMessage(), - "There are configured commands for plugin 'some-id' that doesn't have any containers"); + "There are configured commands for plugin 'somePublisher/custom-name/0.0.3' that doesn't have any containers"); } @Test @@ -246,7 +244,9 @@ public void shouldFillInWarningIfChePluginHasMultiplyContainersButThereAreRelate Warnings.COMMAND_IS_CONFIGURED_IN_PLUGIN_WITH_MULTIPLY_CONTAINERS_WARNING_CODE); assertEquals( warning.getMessage(), - "There are configured commands for plugin '" + pluginRef + "' that has multiply containers. Commands will be configured to be run in first container"); + "There are configured commands for plugin '" + + pluginRef + + "' that has multiply containers. Commands will be configured to be run in first container"); } @Test @@ -896,8 +896,6 @@ private void addExpectedServer( String path) { Map serverAttributes = new HashMap<>(attributes); serverAttributes.put("internal", Boolean.toString(!isExternal)); - servers.put( - portName, - new ServerConfigImpl(port + "/tcp", protocol, path, serverAttributes)); + servers.put(portName, new ServerConfigImpl(port + "/tcp", protocol, path, serverAttributes)); } } diff --git a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactoryTest.java b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactoryTest.java index a83885a6b69..4e227e1441b 100644 --- a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactoryTest.java +++ b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactoryTest.java @@ -153,8 +153,8 @@ public void shouldCreateConfigmapWithPluginFQNs() throws Exception { // given Collection pluginFQNs = ImmutableList.of( - new PluginFQN(null, "testPlugin1"), - new PluginFQN(new URI("testregistry"), "testPlugin2")); + new PluginFQN(null, "testPublisher/testPlugin1/testver1"), + new PluginFQN(new URI("testregistry"), "testPublisher/testPlugin2/testver2")); ArgumentCaptor captor = ArgumentCaptor.forClass(BrokersConfigs.class); // when @@ -169,11 +169,9 @@ public void shouldCreateConfigmapWithPluginFQNs() throws Exception { assertFalse(config.contains("\"registry\":null"), "Should not serialize null registry"); List expected = ImmutableList.of( - "\"id\":\"testPlugin1\"", - "\"version\":\"testver2\"", + "\"id\":\"testPublisher/testPlugin1/testver1\"", "\"registry\":\"testregistry\"", - "\"id\":\"testPlugin2\"", - "\"version\":\"testver2\""); + "\"id\":\"testPublisher/testPlugin2/testver2\""); for (String expect : expected) { assertTrue( config.contains(expect), diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java index ee027f942e9..7c3a5e23663 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java @@ -42,12 +42,10 @@ public class PluginFQNParser { private static final String INCORRECT_PLUGIN_FORMAT_TEMPLATE = - "Plugin '%s' has incorrect format. Should be: 'registryURL/publisher/name/version' or 'registryURL/name/version' or 'name:version' or 'registryURL/name:version'"; - private static final Pattern PLUGIN_PATTERN_V1 = - Pattern.compile("(?(https?://)[-./\\w]+/)?(?\\w+):(?[-\\w.]+)"); - private static final Pattern PLUGIN_PATTERN_V2 = + "Plugin '%s' has incorrect format. Should be: 'registryURL/publisher/name/version' or 'registryURL/name/version'"; + private static final Pattern PLUGIN_PATTERN = Pattern.compile( - "(?(https?://)[-./\\w]+/)?(?[-a-z0-9]+/[-a-z0-9]+/[-.a-z0-9]+)"); + "((?(https?://)[-./\\w]+(:[0-9]+)?)/)?(?[-a-z0-9]+/[-a-z0-9]+/[-.a-z0-9]+)"); /** * Parses a workspace attributes map into a collection of {@link PluginFQN}. @@ -109,18 +107,12 @@ private PluginFQN parsePluginFQN(String plugin) throws InfrastructureException { String registry; String id; URI registryURI = null; - Matcher matcher = PLUGIN_PATTERN_V1.matcher(plugin); + Matcher matcher = PLUGIN_PATTERN.matcher(plugin); if (matcher.matches()) { registry = matcher.group("registry"); - id = matcher.group("name") + "/" + matcher.group("version"); + id = matcher.group("id"); } else { - matcher = PLUGIN_PATTERN_V2.matcher(plugin); - if (matcher.matches()) { - registry = matcher.group("registry"); - id = matcher.group("id"); - } else { - throw new InfrastructureException(format(INCORRECT_PLUGIN_FORMAT_TEMPLATE, plugin)); - } + throw new InfrastructureException(format(INCORRECT_PLUGIN_FORMAT_TEMPLATE, plugin)); } if (!isNullOrEmpty(registry)) { try { diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java index 82bed7e3a46..72be05ef2fc 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java @@ -81,7 +81,7 @@ public void shouldThrowExceptionWhenEditorStringIsInvalid(String editor) throws expectedExceptions = InfrastructureException.class, expectedExceptionsMessageRegExp = "Multiple editors.*") public void shouldThrowExceptionWhenMultipleEditorsDefined() throws Exception { - Map attributes = createAttributes("editor1,editor2", ""); + Map attributes = createAttributes("publisher1/editor1/version1,publisher1/editor2/version1", ""); parser.parsePlugins(attributes); } @@ -89,13 +89,13 @@ public void shouldThrowExceptionWhenMultipleEditorsDefined() throws Exception { @Test( expectedExceptions = InfrastructureException.class, expectedExceptionsMessageRegExp = - "Invalid Che tooling plugins configuration: plugin .*:.* is duplicated") + "Invalid Che tooling plugins configuration: plugin publisher1/testplugin/1.0 is duplicated") public void shouldThrowExceptionWhenDuplicatePluginDefined() throws Exception { Map attributes = createAttributes( "", - formatPlugin("http://testregistry1:8080", "testplugin/1.0"), - formatPlugin("http://testregistry2:8080", "testplugin/1.0")); + formatPlugin("http://testregistry1:8080", "publisher1/testplugin/1.0"), + formatPlugin("http://testregistry2:8080", "publisher1/testplugin/1.0")); parser.parsePlugins(attributes); } @@ -103,14 +103,14 @@ public void shouldThrowExceptionWhenDuplicatePluginDefined() throws Exception { @Test( expectedExceptions = InfrastructureException.class, expectedExceptionsMessageRegExp = - "Invalid Che tooling plugins configuration: plugin .*:.* is duplicated") - public void shouldDetectDuplicatedPluginsIfTheyArePrefixedSuffixedWithEmptySpaces() + "Invalid Che tooling plugins configuration: plugin publisher1/testplugin/1.0 is duplicated") + public void shouldDetectDuplicatedPluginsIfTheyArePrefixedOrSuffixedWithEmptySpaces() throws Exception { Map attributes = createAttributes( "", - " " + formatPlugin("http://testregistry1:8080", "testplugin/1.0"), - formatPlugin("http://testregistry2:8080", "testplugin/1.0") + " "); + " " + formatPlugin("http://testregistry1:8080", "publisher1/testplugin/1.0"), + formatPlugin("http://testregistry2:8080", "publisher1/testplugin/1.0") + " "); parser.parsePlugins(attributes); } @@ -130,11 +130,11 @@ public static Object[][] invalidAttributeStringProvider() { // (String description, List expectedPlugins, Map attributes) @DataProvider(name = "validAttributesProvider") public static Object[][] validAttributesProvider() { - PluginFQN basicEditor = new PluginFQN(URI.create("http://registry:8080"), "editor/ver"); - PluginFQN withRegistry = new PluginFQN(URI.create("http://registry:8080"), "plugin/1.0"); - PluginFQN noRegistry = new PluginFQN(null, "pluginNoRegistry/2.0"); + PluginFQN basicEditor = new PluginFQN(URI.create("http://registry:8080"), "publisher/editor/ver"); + PluginFQN withRegistry = new PluginFQN(URI.create("http://registry:8080"), "publisher/plugin/1.0"); + PluginFQN noRegistry = new PluginFQN(null, "publisher/pluginnoregistry/2.0"); PluginFQN pathRegistry = - new PluginFQN(URI.create("http://registry/multiple/path/"), "pluginPathRegistry/3.0"); + new PluginFQN(URI.create("http://registry/multiple/path/"), "publisher/pluginpathregistry/3.0"); return new Object[][] { { "Test plugin with registry", From 4c854ca4a9811fd472a90a98dad7601a0e8d0d7b Mon Sep 17 00:00:00 2001 From: Oleksandr Garagatyi Date: Thu, 25 Apr 2019 16:11:48 +0300 Subject: [PATCH 04/19] fixup! fixup! Rework --- .../che/api/devfile/server/Constants.java | 2 +- .../EditorComponentToWorkspaceApplier.java | 22 ++++------ .../PluginComponentToWorkspaceApplier.java | 21 +++------- .../component/plugin/PluginProvisioner.java | 10 +++-- .../plugin/PluginReferenceParser.java | 42 +++++++++++++++++++ ...EditorComponentToWorkspaceApplierTest.java | 21 ++++------ ...PluginComponentToWorkspaceApplierTest.java | 31 +++++++------- .../plugin/PluginProvisionerTest.java | 18 ++++---- .../che/api/workspace/shared/Constants.java | 13 +++--- 9 files changed, 100 insertions(+), 80 deletions(-) create mode 100644 wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginReferenceParser.java diff --git a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/Constants.java b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/Constants.java index f9ea1d197db..f452017cc01 100644 --- a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/Constants.java +++ b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/Constants.java @@ -39,7 +39,7 @@ private Constants() {} *

Example value: * *

-   * eclipse/maven-jdk8:1.0.0=mvn-stack,eclipse/theia-jdtls:0.0.3=jdt.ls
+   * eclipse/maven-jdk8/1.0.0=mvn-stack,eclipse/theia-jdtls/0.0.3=jdt.ls
    * 
*/ public static final String PLUGINS_COMPONENTS_ALIASES_WORKSPACE_ATTRIBUTE = diff --git a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplier.java b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplier.java index 7b2ce35bb17..4c81a960ebb 100644 --- a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplier.java +++ b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplier.java @@ -23,7 +23,9 @@ import org.eclipse.che.api.core.model.workspace.devfile.Component; import org.eclipse.che.api.devfile.server.FileContentProvider; import org.eclipse.che.api.devfile.server.convert.component.ComponentToWorkspaceApplier; +import org.eclipse.che.api.devfile.server.convert.component.plugin.PluginReferenceParser; import org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl; +import org.eclipse.che.api.workspace.server.wsplugins.model.PluginMeta; /** * Applies changes on workspace config according to the specified editor component. @@ -38,7 +40,7 @@ public class EditorComponentToWorkspaceApplier implements ComponentToWorkspaceAp * @param workspaceConfig workspace config on which changes should be applied * @param editorComponent plugin component that should be applied * @param contentProvider optional content provider that may be used for external component - * resource fetching + * resource fetching * @throws IllegalArgumentException if specified workspace config or plugin component is null * @throws IllegalArgumentException if specified component has type different from cheEditor */ @@ -65,14 +67,12 @@ public void apply( .put(EDITOR_COMPONENT_ALIAS_WORKSPACE_ATTRIBUTE, editorComponentAlias); } - // TODO how to properly parse this and separate publisher/name/version - String editorIdVersion = resolveIdAndVersion(editorId); + PluginMeta meta = PluginReferenceParser.resolveMeta(editorId); if (memoryLimit != null) { - String editorIdPart = editorIdVersion.split(":")[0]; - // TODO workspaceConfig .getAttributes() - .put(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, editorIdPart), memoryLimit); + .put(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, + meta.getPublisher() + "/" + meta.getName()), memoryLimit); } workspaceConfig .getCommands() @@ -82,15 +82,7 @@ public void apply( c.getAttributes() .get(COMPONENT_ALIAS_COMMAND_ATTRIBUTE) .equals(editorComponentAlias)) - .forEach(c -> c.getAttributes().put(PLUGIN_ATTRIBUTE, editorIdVersion)); + .forEach(c -> c.getAttributes().put(PLUGIN_ATTRIBUTE, meta.getId())); } - private String resolveIdAndVersion(String ref) { - int lastSlashPosition = ref.lastIndexOf("/"); - if (lastSlashPosition < 0) { - return ref; - } else { - return ref.substring(lastSlashPosition + 1); - } - } } diff --git a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplier.java b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplier.java index acbbe0f48a3..3dcb8db9f1d 100644 --- a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplier.java +++ b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplier.java @@ -26,6 +26,7 @@ import org.eclipse.che.api.devfile.server.convert.component.ComponentToWorkspaceApplier; import org.eclipse.che.api.workspace.server.model.impl.CommandImpl; import org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl; +import org.eclipse.che.api.workspace.server.wsplugins.model.PluginMeta; import org.eclipse.che.commons.annotation.Nullable; /** @@ -58,7 +59,6 @@ public void apply( String workspacePluginsAttribute = workspaceConfig.getAttributes().get(WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE); - // TODO workspaceConfig .getAttributes() .put( @@ -68,7 +68,6 @@ public void apply( String pluginsAliases = workspaceConfig.getAttributes().get(PLUGINS_COMPONENTS_ALIASES_WORKSPACE_ATTRIBUTE); if (pluginComponent.getAlias() != null) { - // TODO workspaceConfig .getAttributes() .put( @@ -76,14 +75,13 @@ public void apply( append(pluginsAliases, pluginComponent.getId() + "=" + pluginComponent.getAlias())); } - // TODO - String pluginIdVersion = resolveIdAndVersion(pluginComponent.getId()); + PluginMeta meta = PluginReferenceParser.resolveMeta(pluginComponent.getId()); String memoryLimit = pluginComponent.getMemoryLimit(); if (memoryLimit != null) { - String pluginIdPart = pluginIdVersion.split(":")[0]; workspaceConfig .getAttributes() - .put(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, pluginIdPart), memoryLimit); + .put(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, + meta.getPublisher() + "/" + meta.getName()), memoryLimit); } for (CommandImpl command : workspaceConfig.getCommands()) { @@ -98,16 +96,7 @@ public void apply( continue; } - command.getAttributes().put(PLUGIN_ATTRIBUTE, pluginIdVersion); - } - } - - private String resolveIdAndVersion(String ref) { - int lastSlashPosition = ref.lastIndexOf("/"); - if (lastSlashPosition < 0) { - return ref; - } else { - return ref.substring(lastSlashPosition + 1); + command.getAttributes().put(PLUGIN_ATTRIBUTE, meta.getId()); } } diff --git a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginProvisioner.java b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginProvisioner.java index 284b12acbea..285bb7d7328 100644 --- a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginProvisioner.java +++ b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginProvisioner.java @@ -27,6 +27,7 @@ import org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl; +import org.eclipse.che.api.workspace.server.wsplugins.model.PluginMeta; import org.eclipse.che.api.workspace.shared.Constants; /** @@ -59,13 +60,16 @@ public void provision(DevfileImpl devfile, WorkspaceConfigImpl workspaceConfig) Map pluginIdToComponentAlias = extractPluginIdToComponentAlias(workspaceConfig); for (String pluginId : pluginsAttribute.split(",")) { - ComponentImpl pluginComponent = new ComponentImpl(PLUGIN_COMPONENT_TYPE, pluginId); + PluginMeta meta = PluginReferenceParser.resolveMeta(pluginId); - pluginComponent.setAlias(pluginIdToComponentAlias.get(pluginId)); + ComponentImpl pluginComponent = new ComponentImpl(PLUGIN_COMPONENT_TYPE, meta.getId()); + + pluginComponent.setAlias(pluginIdToComponentAlias.get(meta.getId())); pluginComponent.setMemoryLimit( workspaceConfig .getAttributes() - .get(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, pluginId.split(":")[0]))); + .get(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, + meta.getPublisher() + "/" + meta.getName()))); devfile.getComponents().add(pluginComponent); } } diff --git a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginReferenceParser.java b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginReferenceParser.java new file mode 100644 index 00000000000..3bbfb10157f --- /dev/null +++ b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginReferenceParser.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2012-2018 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.che.api.devfile.server.convert.component.plugin; + +import static java.lang.String.format; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.eclipse.che.api.workspace.server.wsplugins.model.PluginMeta; + +/** + * Parses plugin reference in devfile to plugin meta object. + * Only fields which value are present in reference are populated in the object. + * + * @author Alexander Garagatyi + */ +public class PluginReferenceParser { + private static final Pattern PLUGIN_PATTERN = Pattern + .compile("(.*/)?(?[-a-z0-9]+)/(?[-a-z0-9]+)/(?[-.a-z0-9]+)"); + + public static PluginMeta resolveMeta(String ref) { + Matcher matcher = PLUGIN_PATTERN.matcher(ref); + if (!matcher.matches()) { + throw new IllegalArgumentException(format("Plugin reference '%s' is invalid", ref)); + } + + PluginMeta meta = new PluginMeta().publisher(matcher.group("publisher")) + .name(matcher.group("name")) + .version(matcher.group("version")); + meta.id(meta.getPublisher() + "/" + meta.getName() + "/" + meta.getVersion()); + return meta; + } +} diff --git a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplierTest.java b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplierTest.java index ad4198bf7da..5ab5e96be20 100644 --- a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplierTest.java +++ b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplierTest.java @@ -37,9 +37,8 @@ public void setUp() { } @Test - public void shouldProvisionWorkspaceEditorAttributeDuringCheEditorComponentApplying() - throws Exception { - String editorId = "org.eclipse.che.super-editor:0.0.1"; + public void shouldProvisionWorkspaceEditorAttributeDuringCheEditorComponentApplying() { + String editorId = "eclipse/super-editor/0.0.1"; // given WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl(); ComponentImpl editorComponent = new ComponentImpl(); @@ -58,17 +57,16 @@ public void shouldProvisionWorkspaceEditorAttributeDuringCheEditorComponentApply assertEquals( workspaceConfig .getAttributes() - .get(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, editorId.split(":")[0])), + .get(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, "eclipse/super-editor")), "12345M"); } @Test - public void shouldProvisionPluginCommandAttributesDuringCheEditorComponentApplying() - throws Exception { + public void shouldProvisionPluginCommandAttributesDuringCheEditorComponentApplying() { // given ComponentImpl superPluginComponent = new ComponentImpl(); superPluginComponent.setAlias("editor"); - superPluginComponent.setId("org.eclipse.che.super-editor:0.0.1"); + superPluginComponent.setId("eclipse/super-editor/0.0.1"); superPluginComponent.setType(EDITOR_COMPONENT_TYPE); WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl(); @@ -82,17 +80,16 @@ public void shouldProvisionPluginCommandAttributesDuringCheEditorComponentApplyi // then assertEquals( workspaceConfig.getCommands().get(0).getAttributes().get(PLUGIN_ATTRIBUTE), - "org.eclipse.che.super-editor:0.0.1"); + "eclipse/super-editor/0.0.1"); } @Test - public void shouldProvisionPluginCommandAttributeWhenIdIsURLToCustomPluginRegistry() - throws Exception { + public void shouldProvisionPluginCommandAttributeWhenIdIsURLToCustomPluginRegistry() { // given ComponentImpl superPluginComponent = new ComponentImpl(); superPluginComponent.setAlias("editor"); superPluginComponent.setId( - "https://custom-plugin.registry/plugins/org.eclipse.che.super-editor:0.0.1"); + "https://custom-plugin.registry/plugins/eclipse/super-editor/0.0.1"); superPluginComponent.setType(EDITOR_COMPONENT_TYPE); WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl(); @@ -106,6 +103,6 @@ public void shouldProvisionPluginCommandAttributeWhenIdIsURLToCustomPluginRegist // then assertEquals( workspaceConfig.getCommands().get(0).getAttributes().get(PLUGIN_ATTRIBUTE), - "org.eclipse.che.super-editor:0.0.1"); + "eclipse/super-editor/0.0.1"); } } diff --git a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplierTest.java b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplierTest.java index 9e6cbd2cc29..61236708a19 100644 --- a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplierTest.java +++ b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplierTest.java @@ -38,10 +38,9 @@ public void setUp() { } @Test - public void shouldProvisionPluginWorkspaceAttributeDuringChePluginComponentApplying() - throws Exception { + public void shouldProvisionPluginWorkspaceAttributeDuringChePluginComponentApplying() { - String superPluginId = "org.eclipse.che.super-plugin:0.0.1"; + String superPluginId = "eclipse/super-plugin/0.0.1"; // given ComponentImpl superPluginComponent = new ComponentImpl(); superPluginComponent.setAlias("super-plugin"); @@ -51,7 +50,7 @@ public void shouldProvisionPluginWorkspaceAttributeDuringChePluginComponentApply ComponentImpl customPluginComponent = new ComponentImpl(); customPluginComponent.setAlias("custom"); - customPluginComponent.setId("custom-plugin:v1"); + customPluginComponent.setId("publisher1/custom-plugin/v1"); customPluginComponent.setType(PLUGIN_COMPONENT_TYPE); WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl(); @@ -63,28 +62,27 @@ public void shouldProvisionPluginWorkspaceAttributeDuringChePluginComponentApply // then String workspaceTooling = workspaceConfig.getAttributes().get(WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE); - assertTrue(workspaceTooling.matches("(.+:.+),(.+:.+)")); + assertTrue(workspaceTooling.matches("(.+/.+/.+),(.+/.+/.+)")); assertTrue(workspaceTooling.contains(superPluginId)); - assertTrue(workspaceTooling.contains("custom-plugin:v1")); + assertTrue(workspaceTooling.contains("publisher1/custom-plugin/v1")); String toolingAliases = workspaceConfig.getAttributes().get(PLUGINS_COMPONENTS_ALIASES_WORKSPACE_ATTRIBUTE); - assertTrue(toolingAliases.matches("(.+:.+=.+),(.+:.+=.+)")); + assertTrue(toolingAliases.matches("(.+/.+/.+=.+),(.+/.+/.+=.+)")); assertTrue(toolingAliases.contains(superPluginId + "=super-plugin")); - assertTrue(toolingAliases.contains("custom-plugin:v1=custom")); + assertTrue(toolingAliases.contains("publisher1/custom-plugin/v1=custom")); assertEquals( workspaceConfig .getAttributes() - .get(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, superPluginId.split(":")[0])), + .get(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, "eclipse/super-plugin")), "1234M"); } @Test - public void shouldProvisionPluginCommandAttributesDuringChePluginComponentApplying() - throws Exception { + public void shouldProvisionPluginCommandAttributesDuringChePluginComponentApplying() { // given ComponentImpl superPluginComponent = new ComponentImpl(); superPluginComponent.setAlias("super-plugin"); - superPluginComponent.setId("org.eclipse.che.super-plugin:0.0.1"); + superPluginComponent.setId("eclipse/super-plugin/0.0.1"); superPluginComponent.setType(PLUGIN_COMPONENT_TYPE); WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl(); @@ -98,17 +96,16 @@ public void shouldProvisionPluginCommandAttributesDuringChePluginComponentApplyi // then assertEquals( workspaceConfig.getCommands().get(0).getAttributes().get(PLUGIN_ATTRIBUTE), - "org.eclipse.che.super-plugin:0.0.1"); + "eclipse/super-plugin/0.0.1"); } @Test - public void shouldProvisionPluginCommandAttributeWhenIdIsURLToCustomPluginRegistry() - throws Exception { + public void shouldProvisionPluginCommandAttributeWhenIdIsURLToCustomPluginRegistry() { // given ComponentImpl superPluginComponent = new ComponentImpl(); superPluginComponent.setAlias("super-plugin"); superPluginComponent.setId( - "https://custom-plugin.registry/plugins/org.eclipse.che.super-plugin:0.0.1"); + "https://custom-plugin.registry/plugins/eclipse/super-plugin/0.0.1"); superPluginComponent.setType(PLUGIN_COMPONENT_TYPE); WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl(); @@ -122,6 +119,6 @@ public void shouldProvisionPluginCommandAttributeWhenIdIsURLToCustomPluginRegist // then assertEquals( workspaceConfig.getCommands().get(0).getAttributes().get(PLUGIN_ATTRIBUTE), - "org.eclipse.che.super-plugin:0.0.1"); + "eclipse/super-plugin/0.0.1"); } } diff --git a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginProvisionerTest.java b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginProvisionerTest.java index 9ef161608db..f931107da55 100644 --- a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginProvisionerTest.java +++ b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginProvisionerTest.java @@ -36,22 +36,22 @@ public void setUp() { } @Test - public void shouldProvisionChePluginComponent() throws Exception { + public void shouldProvisionChePluginComponent() { // given WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl(); workspaceConfig .getAttributes() .put( WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE, - "org.eclipse.che.super-plugin:0.0.1,custom-plugin:v1"); + "eclipse/super-plugin/0.0.1,https://localhost:8080/publisher1/custom-plugin/v1"); workspaceConfig .getAttributes() .put( PLUGINS_COMPONENTS_ALIASES_WORKSPACE_ATTRIBUTE, - "org.eclipse.che.super-plugin:0.0.1=super-plugin,custom-plugin:v1=custom"); + "eclipse/super-plugin/0.0.1=super-plugin,publisher1/custom-plugin/v1=custom"); workspaceConfig .getAttributes() - .put(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, "custom-plugin"), "1024M"); + .put(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, "publisher1/custom-plugin"), "1024M"); DevfileImpl devfile = new DevfileImpl(); // when @@ -61,23 +61,23 @@ public void shouldProvisionChePluginComponent() throws Exception { assertEquals(devfile.getComponents().size(), 2); ComponentImpl superPluginComponent = devfile.getComponents().get(0); assertEquals(superPluginComponent.getAlias(), "super-plugin"); - assertEquals(superPluginComponent.getId(), "org.eclipse.che.super-plugin:0.0.1"); + assertEquals(superPluginComponent.getId(), "eclipse/super-plugin/0.0.1"); assertEquals(superPluginComponent.getType(), PLUGIN_COMPONENT_TYPE); ComponentImpl customPluginComponent = devfile.getComponents().get(1); assertEquals(customPluginComponent.getAlias(), "custom"); - assertEquals(customPluginComponent.getId(), "custom-plugin:v1"); + assertEquals(customPluginComponent.getId(), "publisher1/custom-plugin/v1"); assertEquals(customPluginComponent.getType(), PLUGIN_COMPONENT_TYPE); assertEquals(customPluginComponent.getMemoryLimit(), "1024M"); } @Test - public void shouldSetAliasOnComponentIfAliasIsMissingInWorkspaceConfig() throws Exception { + public void shouldSetAliasOnComponentIfAliasIsMissingInWorkspaceConfig() { // given WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl(); workspaceConfig .getAttributes() - .put(WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE, "org.eclipse.che.super-plugin:0.0.1"); + .put(WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE, "eclipse/super-plugin/0.0.1"); DevfileImpl devfile = new DevfileImpl(); // when @@ -87,7 +87,7 @@ public void shouldSetAliasOnComponentIfAliasIsMissingInWorkspaceConfig() throws assertEquals(devfile.getComponents().size(), 1); ComponentImpl superPluginComponent = devfile.getComponents().get(0); assertNull(superPluginComponent.getAlias()); - assertEquals(superPluginComponent.getId(), "org.eclipse.che.super-plugin:0.0.1"); + assertEquals(superPluginComponent.getId(), "eclipse/super-plugin/0.0.1"); assertEquals(superPluginComponent.getType(), PLUGIN_COMPONENT_TYPE); } } diff --git a/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/Constants.java b/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/Constants.java index c962ce36c13..11d24d82905 100644 --- a/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/Constants.java +++ b/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/Constants.java @@ -34,7 +34,7 @@ public final class Constants { public static final String LINK_REL_CREATE_STACK = "create stack"; public static final String LINK_REL_UPDATE_STACK = "update stack"; public static final String LINK_REL_REMOVE_STACK = "remove stack"; - public static final String LINK_REL_GET_STACK_BY_ID = "get stack by id";; + public static final String LINK_REL_GET_STACK_BY_ID = "get stack by id"; public static final String LINK_REL_SEARCH_STACKS = "search stacks"; public static final String LINK_REL_GET_ICON = "get icon link"; @@ -81,11 +81,11 @@ public final class Constants { * Contains an identifier of an editor that should be used in a workspace. Should be set/read from * {@link WorkspaceConfig#getAttributes}. * - *

Value is colon separated id, version. + *

Value is plugin id. * *

This is beta constant that is subject to change or removal. * - *

Example of the attribute value: 'org.eclipse.che.super-editor:0.0.1' + *

Example of the attribute value: 'eclipse/super-editor/0.0.1' */ public static final String WORKSPACE_TOOLING_EDITOR_ATTRIBUTE = "editor"; @@ -108,13 +108,12 @@ public final class Constants { * Contains a list of workspace tooling plugins that should be used in a workspace. Should be * set/read from {@link WorkspaceConfig#getAttributes}. * - *

Value is comma separated list of plugins in a format: '< plugin1ID >:< plugin1Version >,< - * plugin2ID >/< plugin2Version >'
+ *

Value is comma separated list of plugins in a format: '< plugin1ID >,'
* Spaces around commas are trimmed.
* *

This is beta constant that is subject to change or removal. * - *

Example of the attribute value: 'org.eclipse.che.plugin1:0.0.1, com.redhat.plugin2:1.0.0' + *

Example of the attribute value: 'eclipse/plugin1/0.0.1, redhat/plugin2/1.0.0' */ public static final String WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE = "plugins"; @@ -170,7 +169,7 @@ public final class Constants { /** * Attribute of {@link Machine} that indicates by which plugin this machines is provisioned * - *

It contains plugin id, like "plugin": "org.eclipse.che.editor.theia" + *

It contains plugin id, like "plugin": "eclipse/che-theia/master" */ public static final String PLUGIN_MACHINE_ATTRIBUTE = "plugin"; From a4563155cec047a07e5e23401df3bc72fe901b5a Mon Sep 17 00:00:00 2001 From: Oleksandr Garagatyi Date: Thu, 25 Apr 2019 16:42:22 +0300 Subject: [PATCH 05/19] fixup! fixup! fixup! Rework --- .../convert/DefaultEditorProvisioner.java | 34 +++------ .../editor/EditorComponentProvisioner.java | 11 ++- .../convert/DefaultEditorProvisionerTest.java | 72 +++++++++++-------- .../EditorComponentProvisionerTest.java | 13 ++-- 4 files changed, 65 insertions(+), 65 deletions(-) diff --git a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisioner.java b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisioner.java index 5c6822a0363..f40e4d5be64 100644 --- a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisioner.java +++ b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisioner.java @@ -23,13 +23,13 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.regex.Pattern; import javax.inject.Inject; import javax.inject.Named; import org.eclipse.che.api.core.model.workspace.devfile.Component; +import org.eclipse.che.api.devfile.server.convert.component.plugin.PluginReferenceParser; import org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl; -import org.eclipse.che.commons.lang.Pair; +import org.eclipse.che.api.workspace.server.wsplugins.model.PluginMeta; /** * Provision default editor if there is no any another editor and default plugins for it. @@ -41,15 +41,14 @@ public class DefaultEditorProvisioner { private final String defaultEditorRef; private final String defaultEditor; private final Map defaultPluginsToRefs; - private final Pattern PLUGIN_PATTERN = - Pattern.compile("(.*/)?(?[^/]+)/(?[^/]+)/(?[^/]+)"); @Inject public DefaultEditorProvisioner( @Named("che.workspace.devfile.default_editor") String defaultEditorRef, @Named("che.workspace.devfile.default_editor.plugins") String[] defaultPluginsRefs) { this.defaultEditorRef = Strings.isNullOrEmpty(defaultEditorRef) ? null : defaultEditorRef; - this.defaultEditor = this.defaultEditorRef == null ? null : getId(this.defaultEditorRef); + this.defaultEditor = + this.defaultEditorRef == null ? null : getPluginPublisherAndName(this.defaultEditorRef); this.defaultPluginsToRefs = Arrays.stream(defaultPluginsRefs) .collect(toMap(this::getPluginPublisherAndName, identity())); @@ -82,7 +81,7 @@ public void apply(DevfileImpl devfile) { isDefaultEditorUsed = true; } else { Component editor = editorOpt.get(); - isDefaultEditorUsed = defaultEditor.equals(resolveIdAndVersion(editor.getId()).first); + isDefaultEditorUsed = defaultEditor.equals(getPluginPublisherAndName(editor.getId())); } if (isDefaultEditorUsed) { @@ -93,35 +92,18 @@ public void apply(DevfileImpl devfile) { private void provisionDefaultPlugins(List components) { Map missingPluginsIdToRef = new HashMap<>(defaultPluginsToRefs); - // TODO components .stream() .filter(t -> PLUGIN_COMPONENT_TYPE.equals(t.getType())) - .forEach(t -> missingPluginsIdToRef.remove(getId(t.getId()))); + .forEach(t -> missingPluginsIdToRef.remove(getPluginPublisherAndName(t.getId()))); missingPluginsIdToRef .values() .forEach(pluginRef -> components.add(new ComponentImpl(PLUGIN_COMPONENT_TYPE, pluginRef))); } - private String getId(String reference) { - return resolveIdAndVersion(reference).first; - } - private String getPluginPublisherAndName(String reference) { - return resolveIdAndVersion(reference).first; - } - - // todo - private Pair resolveIdAndVersion(String ref) { - int lastSlashPosition = ref.lastIndexOf("/"); - String idVersion; - if (lastSlashPosition < 0) { - idVersion = ref; - } else { - idVersion = ref.substring(lastSlashPosition + 1); - } - String[] splitted = idVersion.split(":", 2); - return Pair.of(splitted[0], splitted[1]); + PluginMeta meta = PluginReferenceParser.resolveMeta(reference); + return meta.getPublisher() + "/" + meta.getName(); } } diff --git a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentProvisioner.java b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentProvisioner.java index 521562a101c..0cb6d2dda70 100644 --- a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentProvisioner.java +++ b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentProvisioner.java @@ -18,9 +18,11 @@ import static org.eclipse.che.api.workspace.shared.Constants.WORKSPACE_TOOLING_EDITOR_ATTRIBUTE; import org.eclipse.che.api.devfile.server.convert.component.ComponentProvisioner; +import org.eclipse.che.api.devfile.server.convert.component.plugin.PluginReferenceParser; import org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl; +import org.eclipse.che.api.workspace.server.wsplugins.model.PluginMeta; import org.eclipse.che.api.workspace.shared.Constants; /** @@ -46,16 +48,19 @@ public void provision(DevfileImpl devfile, WorkspaceConfigImpl workspaceConfig) return; } - ComponentImpl editorComponent = new ComponentImpl(EDITOR_COMPONENT_TYPE, editorAttribute); + PluginMeta meta = PluginReferenceParser.resolveMeta(editorAttribute); + + ComponentImpl editorComponent = new ComponentImpl(EDITOR_COMPONENT_TYPE, meta.getId()); editorComponent.setAlias( workspaceConfig .getAttributes() - .getOrDefault(EDITOR_COMPONENT_ALIAS_WORKSPACE_ATTRIBUTE, editorAttribute)); + .getOrDefault(EDITOR_COMPONENT_ALIAS_WORKSPACE_ATTRIBUTE, meta.getId())); editorComponent.setMemoryLimit( workspaceConfig .getAttributes() - .get(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, editorAttribute.split(":")[0]))); + .get(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, + meta.getPublisher() + "/" + meta.getName()))); devfile.getComponents().add(editorComponent); } } diff --git a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisionerTest.java b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisionerTest.java index 857432c8813..b70284621c0 100644 --- a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisionerTest.java +++ b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisionerTest.java @@ -31,22 +31,26 @@ */ public class DefaultEditorProvisionerTest { - private static final String DEFAULT_EDITOR_ID = "org.eclipse.che.theia"; + private static final String DEFAULT_EDITOR_NAME = "theia"; private static final String DEFAULT_EDITOR_VERSION = "1.0.0"; - private static final String DEFAULT_EDITOR_REF = DEFAULT_EDITOR_ID + ":" + DEFAULT_EDITOR_VERSION; + private static final String DEFAULT_EDITOR_PUBLISHER = "eclipse"; + private static final String DEFAULT_EDITOR_REF = + DEFAULT_EDITOR_PUBLISHER + "/" + DEFAULT_EDITOR_NAME + "/" + DEFAULT_EDITOR_VERSION; - private static final String DEFAULT_TERMINAL_PLUGIN_ID = "org.eclipse.che.theia-terminal"; - private static final String DEFAULT_TERMINAL_PLUGIN_REF = DEFAULT_TERMINAL_PLUGIN_ID + ":0.0.4"; + private static final String DEFAULT_TERMINAL_PLUGIN_NAME = "theia-terminal"; + private static final String DEFAULT_TERMINAL_PLUGIN_REF = + DEFAULT_EDITOR_PUBLISHER + "/" + DEFAULT_TERMINAL_PLUGIN_NAME + "/0.0.4"; - private static final String DEFAULT_COMMAND_PLUGIN_ID = "org.eclipse.che.theia-command"; - private static final String DEFAULT_COMMAND_PLUGIN_REF = DEFAULT_COMMAND_PLUGIN_ID + ":v1.0.0"; + private static final String DEFAULT_COMMAND_PLUGIN_NAME = "theia-command"; + private static final String DEFAULT_COMMAND_PLUGIN_REF = + DEFAULT_EDITOR_PUBLISHER + "/" + DEFAULT_COMMAND_PLUGIN_NAME + "/v1.0.0"; private DefaultEditorProvisioner defaultEditorProvisioner; @Test public void shouldNotProvisionDefaultEditorIfItIsNotConfigured() { // given - defaultEditorProvisioner = new DefaultEditorProvisioner(null, new String[] {}); + defaultEditorProvisioner = new DefaultEditorProvisioner(null, new String[]{}); DevfileImpl devfile = new DevfileImpl(); // when @@ -62,7 +66,7 @@ public void shouldProvisionDefaultEditorWithPluginsWhenDevfileDoNotHaveAny() { defaultEditorProvisioner = new DefaultEditorProvisioner( DEFAULT_EDITOR_REF, - new String[] {DEFAULT_TERMINAL_PLUGIN_REF, DEFAULT_COMMAND_PLUGIN_REF}); + new String[]{DEFAULT_TERMINAL_PLUGIN_REF, DEFAULT_COMMAND_PLUGIN_REF}); DevfileImpl devfile = new DevfileImpl(); // when @@ -83,11 +87,12 @@ public void shouldProvisionDefaultPluginsIfTheyAreNotSpecifiedAndDefaultEditorIs // given defaultEditorProvisioner = new DefaultEditorProvisioner( - DEFAULT_EDITOR_REF, new String[] {DEFAULT_TERMINAL_PLUGIN_REF}); + DEFAULT_EDITOR_REF, new String[]{DEFAULT_TERMINAL_PLUGIN_REF}); DevfileImpl devfile = new DevfileImpl(); ComponentImpl defaultEditorWithDifferentVersion = - new ComponentImpl(EDITOR_COMPONENT_TYPE, DEFAULT_EDITOR_ID + ":latest"); + new ComponentImpl(EDITOR_COMPONENT_TYPE, + DEFAULT_EDITOR_PUBLISHER + "/" + DEFAULT_EDITOR_NAME + "/latest"); devfile.getComponents().add(defaultEditorWithDifferentVersion); // when @@ -105,16 +110,18 @@ public void shouldProvisionDefaultPluginsIfTheyAreNotSpecifiedAndDefaultEditorIs @Test public void - shouldProvisionDefaultPluginsIfTheyAreNotSpecifiedAndDefaultEditorFromCustomRegistryIsConfigured() { + shouldProvisionDefaultPluginsIfTheyAreNotSpecifiedAndDefaultEditorFromCustomRegistryIsConfigured() { // given defaultEditorProvisioner = new DefaultEditorProvisioner( - DEFAULT_EDITOR_REF, new String[] {DEFAULT_TERMINAL_PLUGIN_REF}); + DEFAULT_EDITOR_REF, new String[]{DEFAULT_TERMINAL_PLUGIN_REF}); DevfileImpl devfile = new DevfileImpl(); ComponentImpl defaultEditorWithDifferentVersion = new ComponentImpl( - EDITOR_COMPONENT_TYPE, "https://my-custom-registry/" + DEFAULT_EDITOR_ID + ":latest"); + EDITOR_COMPONENT_TYPE, + "https://my-custom-registry/" + DEFAULT_EDITOR_PUBLISHER + "/" + DEFAULT_EDITOR_NAME + + "/latest"); devfile.getComponents().add(defaultEditorWithDifferentVersion); // when @@ -135,11 +142,12 @@ public void shouldNotProvisionDefaultPluginsIfCustomEditorIsConfiguredWhichStart // given defaultEditorProvisioner = new DefaultEditorProvisioner( - DEFAULT_EDITOR_REF, new String[] {DEFAULT_TERMINAL_PLUGIN_REF}); + DEFAULT_EDITOR_REF, new String[]{DEFAULT_TERMINAL_PLUGIN_REF}); DevfileImpl devfile = new DevfileImpl(); ComponentImpl editorWithNameSimilarToDefault = - new ComponentImpl(EDITOR_COMPONENT_TYPE, DEFAULT_EDITOR_ID + "-dev:dev-version"); + new ComponentImpl(EDITOR_COMPONENT_TYPE, + DEFAULT_EDITOR_PUBLISHER + "/" + DEFAULT_EDITOR_NAME + "-dev/dev-version"); devfile.getComponents().add(editorWithNameSimilarToDefault); // when @@ -149,7 +157,7 @@ public void shouldNotProvisionDefaultPluginsIfCustomEditorIsConfiguredWhichStart List components = devfile.getComponents(); assertEquals(components.size(), 1); assertTrue(components.contains(editorWithNameSimilarToDefault)); - assertNull(findById(components, DEFAULT_EDITOR_ID)); + assertNull(findById(components, DEFAULT_EDITOR_NAME)); } @Test @@ -157,7 +165,7 @@ public void shouldNotProvisionDefaultPluginsIfDevfileContainsEditorFreeAttribute // given defaultEditorProvisioner = new DefaultEditorProvisioner( - DEFAULT_EDITOR_REF, new String[] {DEFAULT_TERMINAL_PLUGIN_REF}); + DEFAULT_EDITOR_REF, new String[]{DEFAULT_TERMINAL_PLUGIN_REF}); DevfileImpl devfile = new DevfileImpl(); devfile.getAttributes().put(EDITOR_FREE_DEVFILE_ATTRIBUTE, "true"); @@ -172,15 +180,16 @@ public void shouldNotProvisionDefaultPluginsIfDevfileContainsEditorFreeAttribute @Test public void - shouldProvisionDefaultPluginIfDevfileAlreadyContainPluginWithNameWhichStartWithDefaultOne() { + shouldProvisionDefaultPluginIfDevfileAlreadyContainPluginWithNameWhichStartWithDefaultOne() { // given defaultEditorProvisioner = new DefaultEditorProvisioner( - DEFAULT_EDITOR_REF, new String[] {DEFAULT_TERMINAL_PLUGIN_REF}); + DEFAULT_EDITOR_REF, new String[]{DEFAULT_TERMINAL_PLUGIN_REF}); DevfileImpl devfile = new DevfileImpl(); ComponentImpl pluginWithNameSimilarToDefault = - new ComponentImpl(PLUGIN_COMPONENT_TYPE, DEFAULT_TERMINAL_PLUGIN_ID + "-dummy:latest"); + new ComponentImpl(PLUGIN_COMPONENT_TYPE, + DEFAULT_EDITOR_PUBLISHER + "/" + DEFAULT_TERMINAL_PLUGIN_NAME + "-dummy/latest"); devfile.getComponents().add(pluginWithNameSimilarToDefault); // when @@ -198,10 +207,10 @@ public void shouldNotProvisionDefaultPluginsIfDevfileContainsEditorFreeAttribute @Test public void shouldNotProvisionDefaultEditorOrDefaultPluginsIfDevfileAlreadyHasNonDefaultEditor() { // given - defaultEditorProvisioner = new DefaultEditorProvisioner(DEFAULT_EDITOR_REF, new String[] {}); + defaultEditorProvisioner = new DefaultEditorProvisioner(DEFAULT_EDITOR_REF, new String[]{}); DevfileImpl devfile = new DevfileImpl(); ComponentImpl nonDefaultEditor = - new ComponentImpl(EDITOR_COMPONENT_TYPE, "any:v" + DEFAULT_EDITOR_VERSION); + new ComponentImpl(EDITOR_COMPONENT_TYPE, "anypublisher/anyname/v" + DEFAULT_EDITOR_VERSION); devfile.getComponents().add(nonDefaultEditor); // when @@ -216,10 +225,11 @@ public void shouldNotProvisionDefaultEditorOrDefaultPluginsIfDevfileAlreadyHasNo @Test public void shouldNonProvisionDefaultEditorIfDevfileAlreadyContainsSuchButWithDifferentVersion() { // given - defaultEditorProvisioner = new DefaultEditorProvisioner(DEFAULT_EDITOR_REF, new String[] {}); + defaultEditorProvisioner = new DefaultEditorProvisioner(DEFAULT_EDITOR_REF, new String[]{}); DevfileImpl devfile = new DevfileImpl(); ComponentImpl myTheiaEditor = - new ComponentImpl(EDITOR_COMPONENT_TYPE, DEFAULT_EDITOR_REF + ":my-custom"); + new ComponentImpl(EDITOR_COMPONENT_TYPE, + DEFAULT_EDITOR_PUBLISHER + "/" + DEFAULT_EDITOR_NAME + "/my-custom"); devfile.getComponents().add(myTheiaEditor); // when @@ -236,10 +246,11 @@ public void shouldNotProvisionDefaultPluginIfDevfileAlreadyContainsSuchButWithDi // given defaultEditorProvisioner = new DefaultEditorProvisioner( - DEFAULT_EDITOR_REF, new String[] {DEFAULT_TERMINAL_PLUGIN_REF}); + DEFAULT_EDITOR_REF, new String[]{DEFAULT_TERMINAL_PLUGIN_REF}); DevfileImpl devfile = new DevfileImpl(); ComponentImpl myTerminal = - new ComponentImpl(PLUGIN_COMPONENT_TYPE, DEFAULT_TERMINAL_PLUGIN_ID + ":my-custom"); + new ComponentImpl(PLUGIN_COMPONENT_TYPE, + DEFAULT_EDITOR_PUBLISHER + "/" + DEFAULT_TERMINAL_PLUGIN_NAME + "/my-custom"); devfile.getComponents().add(myTerminal); // when @@ -256,9 +267,11 @@ public void shouldNotProvisionDefaultPluginIfDevfileAlreadyContainsSuchButWithDi public void shouldGenerateDefaultPluginNameIfIdIsNotUnique() { // given defaultEditorProvisioner = - new DefaultEditorProvisioner(DEFAULT_EDITOR_REF, new String[] {"my-plugin:v2.0"}); + new DefaultEditorProvisioner(DEFAULT_EDITOR_REF, + new String[]{DEFAULT_EDITOR_PUBLISHER + "/" + "my-plugin/v2.0"}); DevfileImpl devfile = new DevfileImpl(); - ComponentImpl myPlugin = new ComponentImpl(PLUGIN_COMPONENT_TYPE, "my-custom-plugin:v0.0.3"); + ComponentImpl myPlugin = new ComponentImpl(PLUGIN_COMPONENT_TYPE, + DEFAULT_EDITOR_PUBLISHER + "/" + "my-custom-plugin/v0.0.3"); devfile.getComponents().add(myPlugin); // when @@ -269,7 +282,8 @@ public void shouldGenerateDefaultPluginNameIfIdIsNotUnique() { assertEquals(components.size(), 3); assertTrue(components.contains(new ComponentImpl(EDITOR_COMPONENT_TYPE, DEFAULT_EDITOR_REF))); assertTrue(components.contains(myPlugin)); - ComponentImpl defaultPlugin = findByRef(components, "my-plugin:v2.0"); + ComponentImpl defaultPlugin = findByRef(components, + DEFAULT_EDITOR_PUBLISHER + "/" + "my-plugin/v2.0"); assertNotNull(defaultPlugin); assertNull(defaultPlugin.getAlias()); } diff --git a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentProvisionerTest.java b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentProvisionerTest.java index 5d675a0a977..79ed5f5331b 100644 --- a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentProvisionerTest.java +++ b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentProvisionerTest.java @@ -35,14 +35,14 @@ public void setUp() { } @Test - public void shouldProvisionCheEditorComponent() throws Exception { + public void shouldProvisionCheEditorComponent() { // given WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl(); - String editorId = "org.eclipse.che.super-editor:0.0.1"; + String editorId = "eclipse/super-editor/0.0.1"; workspaceConfig.getAttributes().put(WORKSPACE_TOOLING_EDITOR_ATTRIBUTE, editorId); workspaceConfig .getAttributes() - .put(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, editorId.split(":")[0]), "245G"); + .put(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, "eclipse/super-editor"), "245G"); workspaceConfig.getAttributes().put(EDITOR_COMPONENT_ALIAS_WORKSPACE_ATTRIBUTE, "editor"); DevfileImpl devfile = new DevfileImpl(); @@ -59,13 +59,12 @@ public void shouldProvisionCheEditorComponent() throws Exception { } @Test - public void shouldUseEditorIdAsComponentNameIfAliasIsMissingDuringEditorComponentProvisioning() - throws Exception { + public void shouldUseEditorIdAsComponentNameIfAliasIsMissingDuringEditorComponentProvisioning() { // given WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl(); workspaceConfig .getAttributes() - .put(WORKSPACE_TOOLING_EDITOR_ATTRIBUTE, "org.eclipse.che.super-editor:0.0.1"); + .put(WORKSPACE_TOOLING_EDITOR_ATTRIBUTE, "eclipse/super-editor/0.0.1"); DevfileImpl devfile = new DevfileImpl(); // when @@ -74,6 +73,6 @@ public void shouldUseEditorIdAsComponentNameIfAliasIsMissingDuringEditorComponen // then assertEquals(devfile.getComponents().size(), 1); ComponentImpl editorComponent = devfile.getComponents().get(0); - assertEquals(editorComponent.getAlias(), "org.eclipse.che.super-editor:0.0.1"); + assertEquals(editorComponent.getAlias(), "eclipse/super-editor/0.0.1"); } } From 1bde31acfcf90fbb6281d457db4156b0763f2d36 Mon Sep 17 00:00:00 2001 From: Oleksandr Garagatyi Date: Thu, 25 Apr 2019 16:56:24 +0300 Subject: [PATCH 06/19] fixup! fixup! fixup! fixup! Rework --- .../KubernetesPluginsToolingApplierTest.java | 3 +- .../editor/EditorComponentProvisioner.java | 6 +- .../EditorComponentToWorkspaceApplier.java | 9 +-- .../PluginComponentToWorkspaceApplier.java | 6 +- .../component/plugin/PluginProvisioner.java | 6 +- .../plugin/PluginReferenceParser.java | 26 +++++---- .../convert/DefaultEditorProvisionerTest.java | 57 +++++++++++-------- ...EditorComponentToWorkspaceApplierTest.java | 3 +- ...PluginComponentToWorkspaceApplierTest.java | 3 +- .../server/urlfactory/URLFactoryBuilder.java | 2 +- .../server/wsplugins/PluginFQNParserTest.java | 12 ++-- 11 files changed, 77 insertions(+), 56 deletions(-) diff --git a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/KubernetesPluginsToolingApplierTest.java b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/KubernetesPluginsToolingApplierTest.java index a9747eb804a..b57ffc3318c 100644 --- a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/KubernetesPluginsToolingApplierTest.java +++ b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/KubernetesPluginsToolingApplierTest.java @@ -126,7 +126,8 @@ public void setUp() { internalEnvironment.addPod(pod); internalEnvironment.getMachines().putAll(machines); - lenient().when(projectsRootEnvVariableProvider.get(any())) + lenient() + .when(projectsRootEnvVariableProvider.get(any())) .thenReturn(new Pair<>("projects_root", "/somewhere/over/the/rainbow")); } diff --git a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentProvisioner.java b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentProvisioner.java index 0cb6d2dda70..28cea77bf2d 100644 --- a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentProvisioner.java +++ b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentProvisioner.java @@ -59,8 +59,10 @@ public void provision(DevfileImpl devfile, WorkspaceConfigImpl workspaceConfig) editorComponent.setMemoryLimit( workspaceConfig .getAttributes() - .get(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, - meta.getPublisher() + "/" + meta.getName()))); + .get( + format( + SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, + meta.getPublisher() + "/" + meta.getName()))); devfile.getComponents().add(editorComponent); } } diff --git a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplier.java b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplier.java index 4c81a960ebb..d260464bd18 100644 --- a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplier.java +++ b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplier.java @@ -40,7 +40,7 @@ public class EditorComponentToWorkspaceApplier implements ComponentToWorkspaceAp * @param workspaceConfig workspace config on which changes should be applied * @param editorComponent plugin component that should be applied * @param contentProvider optional content provider that may be used for external component - * resource fetching + * resource fetching * @throws IllegalArgumentException if specified workspace config or plugin component is null * @throws IllegalArgumentException if specified component has type different from cheEditor */ @@ -71,8 +71,10 @@ public void apply( if (memoryLimit != null) { workspaceConfig .getAttributes() - .put(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, - meta.getPublisher() + "/" + meta.getName()), memoryLimit); + .put( + format( + SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, meta.getPublisher() + "/" + meta.getName()), + memoryLimit); } workspaceConfig .getCommands() @@ -84,5 +86,4 @@ public void apply( .equals(editorComponentAlias)) .forEach(c -> c.getAttributes().put(PLUGIN_ATTRIBUTE, meta.getId())); } - } diff --git a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplier.java b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplier.java index 3dcb8db9f1d..66536ea22b3 100644 --- a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplier.java +++ b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplier.java @@ -80,8 +80,10 @@ public void apply( if (memoryLimit != null) { workspaceConfig .getAttributes() - .put(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, - meta.getPublisher() + "/" + meta.getName()), memoryLimit); + .put( + format( + SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, meta.getPublisher() + "/" + meta.getName()), + memoryLimit); } for (CommandImpl command : workspaceConfig.getCommands()) { diff --git a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginProvisioner.java b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginProvisioner.java index 285bb7d7328..f6014c137cf 100644 --- a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginProvisioner.java +++ b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginProvisioner.java @@ -68,8 +68,10 @@ public void provision(DevfileImpl devfile, WorkspaceConfigImpl workspaceConfig) pluginComponent.setMemoryLimit( workspaceConfig .getAttributes() - .get(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, - meta.getPublisher() + "/" + meta.getName()))); + .get( + format( + SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, + meta.getPublisher() + "/" + meta.getName()))); devfile.getComponents().add(pluginComponent); } } diff --git a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginReferenceParser.java b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginReferenceParser.java index 3bbfb10157f..ef740815b4c 100644 --- a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginReferenceParser.java +++ b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginReferenceParser.java @@ -18,25 +18,27 @@ import org.eclipse.che.api.workspace.server.wsplugins.model.PluginMeta; /** - * Parses plugin reference in devfile to plugin meta object. - * Only fields which value are present in reference are populated in the object. + * Parses plugin reference in devfile to plugin meta object. Only fields which value are present in + * reference are populated in the object. * * @author Alexander Garagatyi */ public class PluginReferenceParser { - private static final Pattern PLUGIN_PATTERN = Pattern - .compile("(.*/)?(?[-a-z0-9]+)/(?[-a-z0-9]+)/(?[-.a-z0-9]+)"); + private static final Pattern PLUGIN_PATTERN = + Pattern.compile("(.*/)?(?[-a-z0-9]+)/(?[-a-z0-9]+)/(?[-.a-z0-9]+)"); public static PluginMeta resolveMeta(String ref) { - Matcher matcher = PLUGIN_PATTERN.matcher(ref); - if (!matcher.matches()) { - throw new IllegalArgumentException(format("Plugin reference '%s' is invalid", ref)); - } + Matcher matcher = PLUGIN_PATTERN.matcher(ref); + if (!matcher.matches()) { + throw new IllegalArgumentException(format("Plugin reference '%s' is invalid", ref)); + } - PluginMeta meta = new PluginMeta().publisher(matcher.group("publisher")) + PluginMeta meta = + new PluginMeta() + .publisher(matcher.group("publisher")) .name(matcher.group("name")) .version(matcher.group("version")); - meta.id(meta.getPublisher() + "/" + meta.getName() + "/" + meta.getVersion()); - return meta; - } + meta.id(meta.getPublisher() + "/" + meta.getName() + "/" + meta.getVersion()); + return meta; + } } diff --git a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisionerTest.java b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisionerTest.java index b70284621c0..5777a36f2be 100644 --- a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisionerTest.java +++ b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisionerTest.java @@ -50,7 +50,7 @@ public class DefaultEditorProvisionerTest { @Test public void shouldNotProvisionDefaultEditorIfItIsNotConfigured() { // given - defaultEditorProvisioner = new DefaultEditorProvisioner(null, new String[]{}); + defaultEditorProvisioner = new DefaultEditorProvisioner(null, new String[] {}); DevfileImpl devfile = new DevfileImpl(); // when @@ -66,7 +66,7 @@ public void shouldProvisionDefaultEditorWithPluginsWhenDevfileDoNotHaveAny() { defaultEditorProvisioner = new DefaultEditorProvisioner( DEFAULT_EDITOR_REF, - new String[]{DEFAULT_TERMINAL_PLUGIN_REF, DEFAULT_COMMAND_PLUGIN_REF}); + new String[] {DEFAULT_TERMINAL_PLUGIN_REF, DEFAULT_COMMAND_PLUGIN_REF}); DevfileImpl devfile = new DevfileImpl(); // when @@ -87,11 +87,12 @@ public void shouldProvisionDefaultPluginsIfTheyAreNotSpecifiedAndDefaultEditorIs // given defaultEditorProvisioner = new DefaultEditorProvisioner( - DEFAULT_EDITOR_REF, new String[]{DEFAULT_TERMINAL_PLUGIN_REF}); + DEFAULT_EDITOR_REF, new String[] {DEFAULT_TERMINAL_PLUGIN_REF}); DevfileImpl devfile = new DevfileImpl(); ComponentImpl defaultEditorWithDifferentVersion = - new ComponentImpl(EDITOR_COMPONENT_TYPE, + new ComponentImpl( + EDITOR_COMPONENT_TYPE, DEFAULT_EDITOR_PUBLISHER + "/" + DEFAULT_EDITOR_NAME + "/latest"); devfile.getComponents().add(defaultEditorWithDifferentVersion); @@ -110,17 +111,20 @@ public void shouldProvisionDefaultPluginsIfTheyAreNotSpecifiedAndDefaultEditorIs @Test public void - shouldProvisionDefaultPluginsIfTheyAreNotSpecifiedAndDefaultEditorFromCustomRegistryIsConfigured() { + shouldProvisionDefaultPluginsIfTheyAreNotSpecifiedAndDefaultEditorFromCustomRegistryIsConfigured() { // given defaultEditorProvisioner = new DefaultEditorProvisioner( - DEFAULT_EDITOR_REF, new String[]{DEFAULT_TERMINAL_PLUGIN_REF}); + DEFAULT_EDITOR_REF, new String[] {DEFAULT_TERMINAL_PLUGIN_REF}); DevfileImpl devfile = new DevfileImpl(); ComponentImpl defaultEditorWithDifferentVersion = new ComponentImpl( EDITOR_COMPONENT_TYPE, - "https://my-custom-registry/" + DEFAULT_EDITOR_PUBLISHER + "/" + DEFAULT_EDITOR_NAME + "https://my-custom-registry/" + + DEFAULT_EDITOR_PUBLISHER + + "/" + + DEFAULT_EDITOR_NAME + "/latest"); devfile.getComponents().add(defaultEditorWithDifferentVersion); @@ -142,11 +146,12 @@ public void shouldNotProvisionDefaultPluginsIfCustomEditorIsConfiguredWhichStart // given defaultEditorProvisioner = new DefaultEditorProvisioner( - DEFAULT_EDITOR_REF, new String[]{DEFAULT_TERMINAL_PLUGIN_REF}); + DEFAULT_EDITOR_REF, new String[] {DEFAULT_TERMINAL_PLUGIN_REF}); DevfileImpl devfile = new DevfileImpl(); ComponentImpl editorWithNameSimilarToDefault = - new ComponentImpl(EDITOR_COMPONENT_TYPE, + new ComponentImpl( + EDITOR_COMPONENT_TYPE, DEFAULT_EDITOR_PUBLISHER + "/" + DEFAULT_EDITOR_NAME + "-dev/dev-version"); devfile.getComponents().add(editorWithNameSimilarToDefault); @@ -165,7 +170,7 @@ public void shouldNotProvisionDefaultPluginsIfDevfileContainsEditorFreeAttribute // given defaultEditorProvisioner = new DefaultEditorProvisioner( - DEFAULT_EDITOR_REF, new String[]{DEFAULT_TERMINAL_PLUGIN_REF}); + DEFAULT_EDITOR_REF, new String[] {DEFAULT_TERMINAL_PLUGIN_REF}); DevfileImpl devfile = new DevfileImpl(); devfile.getAttributes().put(EDITOR_FREE_DEVFILE_ATTRIBUTE, "true"); @@ -180,15 +185,16 @@ public void shouldNotProvisionDefaultPluginsIfDevfileContainsEditorFreeAttribute @Test public void - shouldProvisionDefaultPluginIfDevfileAlreadyContainPluginWithNameWhichStartWithDefaultOne() { + shouldProvisionDefaultPluginIfDevfileAlreadyContainPluginWithNameWhichStartWithDefaultOne() { // given defaultEditorProvisioner = new DefaultEditorProvisioner( - DEFAULT_EDITOR_REF, new String[]{DEFAULT_TERMINAL_PLUGIN_REF}); + DEFAULT_EDITOR_REF, new String[] {DEFAULT_TERMINAL_PLUGIN_REF}); DevfileImpl devfile = new DevfileImpl(); ComponentImpl pluginWithNameSimilarToDefault = - new ComponentImpl(PLUGIN_COMPONENT_TYPE, + new ComponentImpl( + PLUGIN_COMPONENT_TYPE, DEFAULT_EDITOR_PUBLISHER + "/" + DEFAULT_TERMINAL_PLUGIN_NAME + "-dummy/latest"); devfile.getComponents().add(pluginWithNameSimilarToDefault); @@ -207,7 +213,7 @@ public void shouldNotProvisionDefaultPluginsIfDevfileContainsEditorFreeAttribute @Test public void shouldNotProvisionDefaultEditorOrDefaultPluginsIfDevfileAlreadyHasNonDefaultEditor() { // given - defaultEditorProvisioner = new DefaultEditorProvisioner(DEFAULT_EDITOR_REF, new String[]{}); + defaultEditorProvisioner = new DefaultEditorProvisioner(DEFAULT_EDITOR_REF, new String[] {}); DevfileImpl devfile = new DevfileImpl(); ComponentImpl nonDefaultEditor = new ComponentImpl(EDITOR_COMPONENT_TYPE, "anypublisher/anyname/v" + DEFAULT_EDITOR_VERSION); @@ -225,10 +231,11 @@ public void shouldNotProvisionDefaultEditorOrDefaultPluginsIfDevfileAlreadyHasNo @Test public void shouldNonProvisionDefaultEditorIfDevfileAlreadyContainsSuchButWithDifferentVersion() { // given - defaultEditorProvisioner = new DefaultEditorProvisioner(DEFAULT_EDITOR_REF, new String[]{}); + defaultEditorProvisioner = new DefaultEditorProvisioner(DEFAULT_EDITOR_REF, new String[] {}); DevfileImpl devfile = new DevfileImpl(); ComponentImpl myTheiaEditor = - new ComponentImpl(EDITOR_COMPONENT_TYPE, + new ComponentImpl( + EDITOR_COMPONENT_TYPE, DEFAULT_EDITOR_PUBLISHER + "/" + DEFAULT_EDITOR_NAME + "/my-custom"); devfile.getComponents().add(myTheiaEditor); @@ -246,10 +253,11 @@ public void shouldNotProvisionDefaultPluginIfDevfileAlreadyContainsSuchButWithDi // given defaultEditorProvisioner = new DefaultEditorProvisioner( - DEFAULT_EDITOR_REF, new String[]{DEFAULT_TERMINAL_PLUGIN_REF}); + DEFAULT_EDITOR_REF, new String[] {DEFAULT_TERMINAL_PLUGIN_REF}); DevfileImpl devfile = new DevfileImpl(); ComponentImpl myTerminal = - new ComponentImpl(PLUGIN_COMPONENT_TYPE, + new ComponentImpl( + PLUGIN_COMPONENT_TYPE, DEFAULT_EDITOR_PUBLISHER + "/" + DEFAULT_TERMINAL_PLUGIN_NAME + "/my-custom"); devfile.getComponents().add(myTerminal); @@ -267,11 +275,12 @@ public void shouldNotProvisionDefaultPluginIfDevfileAlreadyContainsSuchButWithDi public void shouldGenerateDefaultPluginNameIfIdIsNotUnique() { // given defaultEditorProvisioner = - new DefaultEditorProvisioner(DEFAULT_EDITOR_REF, - new String[]{DEFAULT_EDITOR_PUBLISHER + "/" + "my-plugin/v2.0"}); + new DefaultEditorProvisioner( + DEFAULT_EDITOR_REF, new String[] {DEFAULT_EDITOR_PUBLISHER + "/" + "my-plugin/v2.0"}); DevfileImpl devfile = new DevfileImpl(); - ComponentImpl myPlugin = new ComponentImpl(PLUGIN_COMPONENT_TYPE, - DEFAULT_EDITOR_PUBLISHER + "/" + "my-custom-plugin/v0.0.3"); + ComponentImpl myPlugin = + new ComponentImpl( + PLUGIN_COMPONENT_TYPE, DEFAULT_EDITOR_PUBLISHER + "/" + "my-custom-plugin/v0.0.3"); devfile.getComponents().add(myPlugin); // when @@ -282,8 +291,8 @@ public void shouldGenerateDefaultPluginNameIfIdIsNotUnique() { assertEquals(components.size(), 3); assertTrue(components.contains(new ComponentImpl(EDITOR_COMPONENT_TYPE, DEFAULT_EDITOR_REF))); assertTrue(components.contains(myPlugin)); - ComponentImpl defaultPlugin = findByRef(components, - DEFAULT_EDITOR_PUBLISHER + "/" + "my-plugin/v2.0"); + ComponentImpl defaultPlugin = + findByRef(components, DEFAULT_EDITOR_PUBLISHER + "/" + "my-plugin/v2.0"); assertNotNull(defaultPlugin); assertNull(defaultPlugin.getAlias()); } diff --git a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplierTest.java b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplierTest.java index 5ab5e96be20..070a70b6251 100644 --- a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplierTest.java +++ b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplierTest.java @@ -88,8 +88,7 @@ public void shouldProvisionPluginCommandAttributeWhenIdIsURLToCustomPluginRegist // given ComponentImpl superPluginComponent = new ComponentImpl(); superPluginComponent.setAlias("editor"); - superPluginComponent.setId( - "https://custom-plugin.registry/plugins/eclipse/super-editor/0.0.1"); + superPluginComponent.setId("https://custom-plugin.registry/plugins/eclipse/super-editor/0.0.1"); superPluginComponent.setType(EDITOR_COMPONENT_TYPE); WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl(); diff --git a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplierTest.java b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplierTest.java index 61236708a19..abf2f9697a3 100644 --- a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplierTest.java +++ b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplierTest.java @@ -104,8 +104,7 @@ public void shouldProvisionPluginCommandAttributeWhenIdIsURLToCustomPluginRegist // given ComponentImpl superPluginComponent = new ComponentImpl(); superPluginComponent.setAlias("super-plugin"); - superPluginComponent.setId( - "https://custom-plugin.registry/plugins/eclipse/super-plugin/0.0.1"); + superPluginComponent.setId("https://custom-plugin.registry/plugins/eclipse/super-plugin/0.0.1"); superPluginComponent.setType(PLUGIN_COMPONENT_TYPE); WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl(); diff --git a/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/urlfactory/URLFactoryBuilder.java b/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/urlfactory/URLFactoryBuilder.java index 6cae38b4d3e..7efbfd6178b 100644 --- a/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/urlfactory/URLFactoryBuilder.java +++ b/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/urlfactory/URLFactoryBuilder.java @@ -132,7 +132,7 @@ public WorkspaceConfigDto buildDefaultWorkspaceConfig(String name) { Map attributes = new HashMap<>(); attributes.put(WORKSPACE_TOOLING_EDITOR_ATTRIBUTE, defaultCheEditor); - attributes.put(WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE, defaultChePlugins); + attributes.put(WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE, defaultChePlugins); // TODO // workspace configuration using the environment return newDto(WorkspaceConfigDto.class).withName(name).withAttributes(attributes); diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java index 72be05ef2fc..613544de277 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java @@ -81,7 +81,8 @@ public void shouldThrowExceptionWhenEditorStringIsInvalid(String editor) throws expectedExceptions = InfrastructureException.class, expectedExceptionsMessageRegExp = "Multiple editors.*") public void shouldThrowExceptionWhenMultipleEditorsDefined() throws Exception { - Map attributes = createAttributes("publisher1/editor1/version1,publisher1/editor2/version1", ""); + Map attributes = + createAttributes("publisher1/editor1/version1,publisher1/editor2/version1", ""); parser.parsePlugins(attributes); } @@ -130,11 +131,14 @@ public static Object[][] invalidAttributeStringProvider() { // (String description, List expectedPlugins, Map attributes) @DataProvider(name = "validAttributesProvider") public static Object[][] validAttributesProvider() { - PluginFQN basicEditor = new PluginFQN(URI.create("http://registry:8080"), "publisher/editor/ver"); - PluginFQN withRegistry = new PluginFQN(URI.create("http://registry:8080"), "publisher/plugin/1.0"); + PluginFQN basicEditor = + new PluginFQN(URI.create("http://registry:8080"), "publisher/editor/ver"); + PluginFQN withRegistry = + new PluginFQN(URI.create("http://registry:8080"), "publisher/plugin/1.0"); PluginFQN noRegistry = new PluginFQN(null, "publisher/pluginnoregistry/2.0"); PluginFQN pathRegistry = - new PluginFQN(URI.create("http://registry/multiple/path/"), "publisher/pluginpathregistry/3.0"); + new PluginFQN( + URI.create("http://registry/multiple/path/"), "publisher/pluginpathregistry/3.0"); return new Object[][] { { "Test plugin with registry", From f1f10f75b031f53024aa6009b1377728807d990b Mon Sep 17 00:00:00 2001 From: Oleksandr Garagatyi Date: Thu, 25 Apr 2019 17:13:02 +0300 Subject: [PATCH 07/19] fixup! fixup! fixup! fixup! fixup! Rework --- .../che/api/factory/server/urlfactory/URLFactoryBuilder.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/urlfactory/URLFactoryBuilder.java b/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/urlfactory/URLFactoryBuilder.java index 7efbfd6178b..47830462888 100644 --- a/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/urlfactory/URLFactoryBuilder.java +++ b/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/urlfactory/URLFactoryBuilder.java @@ -53,7 +53,7 @@ public class URLFactoryBuilder { @Inject public URLFactoryBuilder( - @Named("che.factory.default_editor") String defaultCheEditor, // TODO + @Named("che.factory.default_editor") String defaultCheEditor, @Named("che.factory.default_plugins") String defaultChePlugins, URLFetcher urlFetcher, DevfileManager devfileManager) { @@ -132,7 +132,7 @@ public WorkspaceConfigDto buildDefaultWorkspaceConfig(String name) { Map attributes = new HashMap<>(); attributes.put(WORKSPACE_TOOLING_EDITOR_ATTRIBUTE, defaultCheEditor); - attributes.put(WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE, defaultChePlugins); // TODO + attributes.put(WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE, defaultChePlugins); // workspace configuration using the environment return newDto(WorkspaceConfigDto.class).withName(name).withAttributes(attributes); From 7f3af625f55bc5ad5b4d7a38b103809fd216fb2c Mon Sep 17 00:00:00 2001 From: Oleksandr Garagatyi Date: Fri, 26 Apr 2019 10:22:09 +0300 Subject: [PATCH 08/19] fixup! fixup! fixup! fixup! fixup! fixup! Rework --- .../webapp/WEB-INF/classes/che/che.properties | 4 +- .../src/main/resources/stacks.json | 2 +- .../kubernetes/wsplugins/MachineResolver.java | 10 +- .../convert/DefaultEditorProvisionerTest.java | 139 +++++++----------- .../che/api/workspace/shared/Constants.java | 4 +- .../server/wsplugins/PluginFQNParser.java | 7 +- .../server/wsplugins/PluginFQNParserTest.java | 6 + 7 files changed, 73 insertions(+), 99 deletions(-) diff --git a/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/che/che.properties b/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/che/che.properties index d7970675e3e..317eb9da88a 100644 --- a/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/che/che.properties +++ b/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/che/che.properties @@ -629,7 +629,7 @@ che.factory.default_plugins=eclipse/che-machine-exec-plugin/0.0.1 # Devfile defaults # # Default Editor that should be provisioned into Devfile if there is no specified Editor -# Format is `editorPublisher/editorId/editorVersion` value. +# Format is `editorPublisher/editorName/editorVersion` value. # `NULL` or absence of value means that default editor should not be provisioned. che.workspace.devfile.default_editor=eclipse/che-theia/1.0.0 @@ -637,6 +637,6 @@ che.workspace.devfile.default_editor=eclipse/che-theia/1.0.0 # All the plugins from this list that are not explicitly mentioned in the user-defined devfile # will be provisioned but only when the default editor is used or if the user-defined editor is # the same as the default one (even if in different version). -# Format is comma-separated `pluginPublisher/pluginId/pluginVersion` values, for example +# Format is comma-separated `pluginPublisher/pluginName/pluginVersion` values, for example # eclipse/che-theia-exec-plugin/0.0.1,eclipse/che-theia-terminal-plugin/0.0.1 che.workspace.devfile.default_editor.plugins=eclipse/che-machine-exec-plugin/0.0.1 diff --git a/ide/che-core-ide-stacks/src/main/resources/stacks.json b/ide/che-core-ide-stacks/src/main/resources/stacks.json index 5a6e1a62375..ea3b7421010 100644 --- a/ide/che-core-ide-stacks/src/main/resources/stacks.json +++ b/ide/che-core-ide-stacks/src/main/resources/stacks.json @@ -215,7 +215,7 @@ ], "attributes": { "plugins": "eclipse/che-machine-exec-plugin/0.0.1", - "editor": "eclipse/theia/1.0.0" + "editor": "eclipse/che-theia/1.0.0" }, "links": [] }, diff --git a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/MachineResolver.java b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/MachineResolver.java index e3e613f4f66..9116029d7a2 100644 --- a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/MachineResolver.java +++ b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/MachineResolver.java @@ -39,8 +39,7 @@ /** @author Oleksandr Garagatyi */ public class MachineResolver { - private final String pluginName; - private final String pluginPublisherName; + private final String pluginPublisherAndName; private final Container container; private final CheContainer cheContainer; private final String defaultSidecarMemoryLimitBytes; @@ -57,8 +56,7 @@ public MachineResolver( String defaultSidecarMemoryLimitBytes, List containerEndpoints, Map wsAttributes) { - this.pluginName = pluginName; - this.pluginPublisherName = pluginPublisher + "/" + pluginName; + this.pluginPublisherAndName = pluginPublisher + "/" + pluginName; this.container = container; this.cheContainer = cheContainer; this.defaultSidecarMemoryLimitBytes = defaultSidecarMemoryLimitBytes; @@ -83,7 +81,7 @@ private void normalizeMemory(Container container, InternalMachineConfig machineC } // Use plugin_publisher/plugin_name to find overriding of memory limit. String overriddenSidecarMemLimit = - wsAttributes.get(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, pluginPublisherName)); + wsAttributes.get(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, pluginPublisherAndName)); if (!isNullOrEmpty(overriddenSidecarMemLimit)) { machineConfig .getAttributes() @@ -112,7 +110,7 @@ private void normalizeMemory(Container container, InternalMachineConfig machineC + " the mountSources attribute to true instead and remove the manual volume" + " mount in the plugin. After that the mount path of the sources will be" + " available automatically in the '%s' environment variable.", - pluginPublisherName, + pluginPublisherAndName, PROJECTS_VOLUME_NAME, container.getName(), volume.getMountPath(), diff --git a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisionerTest.java b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisionerTest.java index 5777a36f2be..1173d813942 100644 --- a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisionerTest.java +++ b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisionerTest.java @@ -31,30 +31,30 @@ */ public class DefaultEditorProvisionerTest { - private static final String DEFAULT_EDITOR_NAME = "theia"; - private static final String DEFAULT_EDITOR_VERSION = "1.0.0"; - private static final String DEFAULT_EDITOR_PUBLISHER = "eclipse"; - private static final String DEFAULT_EDITOR_REF = - DEFAULT_EDITOR_PUBLISHER + "/" + DEFAULT_EDITOR_NAME + "/" + DEFAULT_EDITOR_VERSION; + private static final String EDITOR_NAME = "theia"; + private static final String EDITOR_VERSION = "1.0.0"; + private static final String EDITOR_PUBLISHER = "eclipse"; + private static final String EDITOR_REF = + EDITOR_PUBLISHER + "/" + EDITOR_NAME + "/" + EDITOR_VERSION; - private static final String DEFAULT_TERMINAL_PLUGIN_NAME = "theia-terminal"; - private static final String DEFAULT_TERMINAL_PLUGIN_REF = - DEFAULT_EDITOR_PUBLISHER + "/" + DEFAULT_TERMINAL_PLUGIN_NAME + "/0.0.4"; + private static final String TERMINAL_PLUGIN_NAME = "theia-terminal"; + private static final String TERMINAL_PLUGIN_REF = + EDITOR_PUBLISHER + "/" + TERMINAL_PLUGIN_NAME + "/0.0.4"; - private static final String DEFAULT_COMMAND_PLUGIN_NAME = "theia-command"; - private static final String DEFAULT_COMMAND_PLUGIN_REF = - DEFAULT_EDITOR_PUBLISHER + "/" + DEFAULT_COMMAND_PLUGIN_NAME + "/v1.0.0"; + private static final String COMMAND_PLUGIN_NAME = "theia-command"; + private static final String COMMAND_PLUGIN_REF = + EDITOR_PUBLISHER + "/" + COMMAND_PLUGIN_NAME + "/v1.0.0"; - private DefaultEditorProvisioner defaultEditorProvisioner; + private DefaultEditorProvisioner provisioner; @Test public void shouldNotProvisionDefaultEditorIfItIsNotConfigured() { // given - defaultEditorProvisioner = new DefaultEditorProvisioner(null, new String[] {}); + provisioner = new DefaultEditorProvisioner(null, new String[] {}); DevfileImpl devfile = new DevfileImpl(); // when - defaultEditorProvisioner.apply(devfile); + provisioner.apply(devfile); // then assertTrue(devfile.getComponents().isEmpty()); @@ -63,41 +63,34 @@ public void shouldNotProvisionDefaultEditorIfItIsNotConfigured() { @Test public void shouldProvisionDefaultEditorWithPluginsWhenDevfileDoNotHaveAny() { // given - defaultEditorProvisioner = + provisioner = new DefaultEditorProvisioner( - DEFAULT_EDITOR_REF, - new String[] {DEFAULT_TERMINAL_PLUGIN_REF, DEFAULT_COMMAND_PLUGIN_REF}); + EDITOR_REF, new String[] {TERMINAL_PLUGIN_REF, COMMAND_PLUGIN_REF}); DevfileImpl devfile = new DevfileImpl(); // when - defaultEditorProvisioner.apply(devfile); + provisioner.apply(devfile); // then List components = devfile.getComponents(); assertEquals(components.size(), 3); - assertTrue(components.contains(new ComponentImpl(EDITOR_COMPONENT_TYPE, DEFAULT_EDITOR_REF))); - assertTrue( - components.contains(new ComponentImpl(PLUGIN_COMPONENT_TYPE, DEFAULT_COMMAND_PLUGIN_REF))); - assertTrue( - components.contains(new ComponentImpl(PLUGIN_COMPONENT_TYPE, DEFAULT_TERMINAL_PLUGIN_REF))); + assertTrue(components.contains(new ComponentImpl(EDITOR_COMPONENT_TYPE, EDITOR_REF))); + assertTrue(components.contains(new ComponentImpl(PLUGIN_COMPONENT_TYPE, COMMAND_PLUGIN_REF))); + assertTrue(components.contains(new ComponentImpl(PLUGIN_COMPONENT_TYPE, TERMINAL_PLUGIN_REF))); } @Test public void shouldProvisionDefaultPluginsIfTheyAreNotSpecifiedAndDefaultEditorIsConfigured() { // given - defaultEditorProvisioner = - new DefaultEditorProvisioner( - DEFAULT_EDITOR_REF, new String[] {DEFAULT_TERMINAL_PLUGIN_REF}); + provisioner = new DefaultEditorProvisioner(EDITOR_REF, new String[] {TERMINAL_PLUGIN_REF}); DevfileImpl devfile = new DevfileImpl(); ComponentImpl defaultEditorWithDifferentVersion = - new ComponentImpl( - EDITOR_COMPONENT_TYPE, - DEFAULT_EDITOR_PUBLISHER + "/" + DEFAULT_EDITOR_NAME + "/latest"); + new ComponentImpl(EDITOR_COMPONENT_TYPE, EDITOR_PUBLISHER + "/" + EDITOR_NAME + "/latest"); devfile.getComponents().add(defaultEditorWithDifferentVersion); // when - defaultEditorProvisioner.apply(devfile); + provisioner.apply(devfile); // then List components = devfile.getComponents(); @@ -105,31 +98,24 @@ public void shouldProvisionDefaultPluginsIfTheyAreNotSpecifiedAndDefaultEditorIs assertTrue(components.contains(defaultEditorWithDifferentVersion)); - assertTrue( - components.contains(new ComponentImpl(PLUGIN_COMPONENT_TYPE, DEFAULT_TERMINAL_PLUGIN_REF))); + assertTrue(components.contains(new ComponentImpl(PLUGIN_COMPONENT_TYPE, TERMINAL_PLUGIN_REF))); } @Test public void shouldProvisionDefaultPluginsIfTheyAreNotSpecifiedAndDefaultEditorFromCustomRegistryIsConfigured() { // given - defaultEditorProvisioner = - new DefaultEditorProvisioner( - DEFAULT_EDITOR_REF, new String[] {DEFAULT_TERMINAL_PLUGIN_REF}); + provisioner = new DefaultEditorProvisioner(EDITOR_REF, new String[] {TERMINAL_PLUGIN_REF}); DevfileImpl devfile = new DevfileImpl(); ComponentImpl defaultEditorWithDifferentVersion = new ComponentImpl( EDITOR_COMPONENT_TYPE, - "https://my-custom-registry/" - + DEFAULT_EDITOR_PUBLISHER - + "/" - + DEFAULT_EDITOR_NAME - + "/latest"); + "https://my-custom-registry/" + EDITOR_PUBLISHER + "/" + EDITOR_NAME + "/latest"); devfile.getComponents().add(defaultEditorWithDifferentVersion); // when - defaultEditorProvisioner.apply(devfile); + provisioner.apply(devfile); // then List components = devfile.getComponents(); @@ -137,46 +123,40 @@ public void shouldProvisionDefaultPluginsIfTheyAreNotSpecifiedAndDefaultEditorIs assertTrue(components.contains(defaultEditorWithDifferentVersion)); - assertTrue( - components.contains(new ComponentImpl(PLUGIN_COMPONENT_TYPE, DEFAULT_TERMINAL_PLUGIN_REF))); + assertTrue(components.contains(new ComponentImpl(PLUGIN_COMPONENT_TYPE, TERMINAL_PLUGIN_REF))); } @Test public void shouldNotProvisionDefaultPluginsIfCustomEditorIsConfiguredWhichStartWithDefaultId() { // given - defaultEditorProvisioner = - new DefaultEditorProvisioner( - DEFAULT_EDITOR_REF, new String[] {DEFAULT_TERMINAL_PLUGIN_REF}); + provisioner = new DefaultEditorProvisioner(EDITOR_REF, new String[] {TERMINAL_PLUGIN_REF}); DevfileImpl devfile = new DevfileImpl(); ComponentImpl editorWithNameSimilarToDefault = new ComponentImpl( - EDITOR_COMPONENT_TYPE, - DEFAULT_EDITOR_PUBLISHER + "/" + DEFAULT_EDITOR_NAME + "-dev/dev-version"); + EDITOR_COMPONENT_TYPE, EDITOR_PUBLISHER + "/" + EDITOR_NAME + "-dev/dev-version"); devfile.getComponents().add(editorWithNameSimilarToDefault); // when - defaultEditorProvisioner.apply(devfile); + provisioner.apply(devfile); // then List components = devfile.getComponents(); assertEquals(components.size(), 1); assertTrue(components.contains(editorWithNameSimilarToDefault)); - assertNull(findById(components, DEFAULT_EDITOR_NAME)); + assertNull(findById(components, EDITOR_NAME)); } @Test public void shouldNotProvisionDefaultPluginsIfDevfileContainsEditorFreeAttribute() { // given - defaultEditorProvisioner = - new DefaultEditorProvisioner( - DEFAULT_EDITOR_REF, new String[] {DEFAULT_TERMINAL_PLUGIN_REF}); + provisioner = new DefaultEditorProvisioner(EDITOR_REF, new String[] {TERMINAL_PLUGIN_REF}); DevfileImpl devfile = new DevfileImpl(); devfile.getAttributes().put(EDITOR_FREE_DEVFILE_ATTRIBUTE, "true"); // when - defaultEditorProvisioner.apply(devfile); + provisioner.apply(devfile); // then List components = devfile.getComponents(); @@ -187,40 +167,36 @@ public void shouldNotProvisionDefaultPluginsIfDevfileContainsEditorFreeAttribute public void shouldProvisionDefaultPluginIfDevfileAlreadyContainPluginWithNameWhichStartWithDefaultOne() { // given - defaultEditorProvisioner = - new DefaultEditorProvisioner( - DEFAULT_EDITOR_REF, new String[] {DEFAULT_TERMINAL_PLUGIN_REF}); + provisioner = new DefaultEditorProvisioner(EDITOR_REF, new String[] {TERMINAL_PLUGIN_REF}); DevfileImpl devfile = new DevfileImpl(); ComponentImpl pluginWithNameSimilarToDefault = new ComponentImpl( - PLUGIN_COMPONENT_TYPE, - DEFAULT_EDITOR_PUBLISHER + "/" + DEFAULT_TERMINAL_PLUGIN_NAME + "-dummy/latest"); + PLUGIN_COMPONENT_TYPE, EDITOR_PUBLISHER + "/" + TERMINAL_PLUGIN_NAME + "-dummy/latest"); devfile.getComponents().add(pluginWithNameSimilarToDefault); // when - defaultEditorProvisioner.apply(devfile); + provisioner.apply(devfile); // then List components = devfile.getComponents(); assertEquals(components.size(), 3); - assertTrue(components.contains(new ComponentImpl(EDITOR_COMPONENT_TYPE, DEFAULT_EDITOR_REF))); - assertTrue( - components.contains(new ComponentImpl(PLUGIN_COMPONENT_TYPE, DEFAULT_TERMINAL_PLUGIN_REF))); + assertTrue(components.contains(new ComponentImpl(EDITOR_COMPONENT_TYPE, EDITOR_REF))); + assertTrue(components.contains(new ComponentImpl(PLUGIN_COMPONENT_TYPE, TERMINAL_PLUGIN_REF))); assertTrue(components.contains(pluginWithNameSimilarToDefault)); } @Test public void shouldNotProvisionDefaultEditorOrDefaultPluginsIfDevfileAlreadyHasNonDefaultEditor() { // given - defaultEditorProvisioner = new DefaultEditorProvisioner(DEFAULT_EDITOR_REF, new String[] {}); + provisioner = new DefaultEditorProvisioner(EDITOR_REF, new String[] {}); DevfileImpl devfile = new DevfileImpl(); ComponentImpl nonDefaultEditor = - new ComponentImpl(EDITOR_COMPONENT_TYPE, "anypublisher/anyname/v" + DEFAULT_EDITOR_VERSION); + new ComponentImpl(EDITOR_COMPONENT_TYPE, "anypublisher/anyname/v" + EDITOR_VERSION); devfile.getComponents().add(nonDefaultEditor); // when - defaultEditorProvisioner.apply(devfile); + provisioner.apply(devfile); // then List components = devfile.getComponents(); @@ -231,16 +207,15 @@ public void shouldNotProvisionDefaultEditorOrDefaultPluginsIfDevfileAlreadyHasNo @Test public void shouldNonProvisionDefaultEditorIfDevfileAlreadyContainsSuchButWithDifferentVersion() { // given - defaultEditorProvisioner = new DefaultEditorProvisioner(DEFAULT_EDITOR_REF, new String[] {}); + provisioner = new DefaultEditorProvisioner(EDITOR_REF, new String[] {}); DevfileImpl devfile = new DevfileImpl(); ComponentImpl myTheiaEditor = new ComponentImpl( - EDITOR_COMPONENT_TYPE, - DEFAULT_EDITOR_PUBLISHER + "/" + DEFAULT_EDITOR_NAME + "/my-custom"); + EDITOR_COMPONENT_TYPE, EDITOR_PUBLISHER + "/" + EDITOR_NAME + "/my-custom"); devfile.getComponents().add(myTheiaEditor); // when - defaultEditorProvisioner.apply(devfile); + provisioner.apply(devfile); // then List components = devfile.getComponents(); @@ -251,48 +226,44 @@ public void shouldNonProvisionDefaultEditorIfDevfileAlreadyContainsSuchButWithDi @Test public void shouldNotProvisionDefaultPluginIfDevfileAlreadyContainsSuchButWithDifferentVersion() { // given - defaultEditorProvisioner = - new DefaultEditorProvisioner( - DEFAULT_EDITOR_REF, new String[] {DEFAULT_TERMINAL_PLUGIN_REF}); + provisioner = new DefaultEditorProvisioner(EDITOR_REF, new String[] {TERMINAL_PLUGIN_REF}); DevfileImpl devfile = new DevfileImpl(); ComponentImpl myTerminal = new ComponentImpl( - PLUGIN_COMPONENT_TYPE, - DEFAULT_EDITOR_PUBLISHER + "/" + DEFAULT_TERMINAL_PLUGIN_NAME + "/my-custom"); + PLUGIN_COMPONENT_TYPE, EDITOR_PUBLISHER + "/" + TERMINAL_PLUGIN_NAME + "/my-custom"); devfile.getComponents().add(myTerminal); // when - defaultEditorProvisioner.apply(devfile); + provisioner.apply(devfile); // then List components = devfile.getComponents(); assertEquals(components.size(), 2); - assertTrue(components.contains(new ComponentImpl(EDITOR_COMPONENT_TYPE, DEFAULT_EDITOR_REF))); + assertTrue(components.contains(new ComponentImpl(EDITOR_COMPONENT_TYPE, EDITOR_REF))); assertTrue(components.contains(myTerminal)); } @Test public void shouldGenerateDefaultPluginNameIfIdIsNotUnique() { // given - defaultEditorProvisioner = + provisioner = new DefaultEditorProvisioner( - DEFAULT_EDITOR_REF, new String[] {DEFAULT_EDITOR_PUBLISHER + "/" + "my-plugin/v2.0"}); + EDITOR_REF, new String[] {EDITOR_PUBLISHER + "/" + "my-plugin/v2.0"}); DevfileImpl devfile = new DevfileImpl(); ComponentImpl myPlugin = new ComponentImpl( - PLUGIN_COMPONENT_TYPE, DEFAULT_EDITOR_PUBLISHER + "/" + "my-custom-plugin/v0.0.3"); + PLUGIN_COMPONENT_TYPE, EDITOR_PUBLISHER + "/" + "my-custom-plugin/v0.0.3"); devfile.getComponents().add(myPlugin); // when - defaultEditorProvisioner.apply(devfile); + provisioner.apply(devfile); // then List components = devfile.getComponents(); assertEquals(components.size(), 3); - assertTrue(components.contains(new ComponentImpl(EDITOR_COMPONENT_TYPE, DEFAULT_EDITOR_REF))); + assertTrue(components.contains(new ComponentImpl(EDITOR_COMPONENT_TYPE, EDITOR_REF))); assertTrue(components.contains(myPlugin)); - ComponentImpl defaultPlugin = - findByRef(components, DEFAULT_EDITOR_PUBLISHER + "/" + "my-plugin/v2.0"); + ComponentImpl defaultPlugin = findByRef(components, EDITOR_PUBLISHER + "/" + "my-plugin/v2.0"); assertNotNull(defaultPlugin); assertNull(defaultPlugin.getAlias()); } diff --git a/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/Constants.java b/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/Constants.java index 11d24d82905..3d695b145df 100644 --- a/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/Constants.java +++ b/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/Constants.java @@ -83,9 +83,9 @@ public final class Constants { * *

Value is plugin id. * - *

This is beta constant that is subject to change or removal. - * *

Example of the attribute value: 'eclipse/super-editor/0.0.1' + * + *

This is beta constant that is subject to change or removal. */ public static final String WORKSPACE_TOOLING_EDITOR_ATTRIBUTE = "editor"; diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java index 7c3a5e23663..c8159e8a48f 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java @@ -21,7 +21,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.regex.Matcher; @@ -42,7 +41,7 @@ public class PluginFQNParser { private static final String INCORRECT_PLUGIN_FORMAT_TEMPLATE = - "Plugin '%s' has incorrect format. Should be: 'registryURL/publisher/name/version' or 'registryURL/name/version'"; + "Plugin '%s' has incorrect format. Should be: 'registryURL/publisher/name/version' or 'publisher/name/version'"; private static final Pattern PLUGIN_PATTERN = Pattern.compile( "((?(https?://)[-./\\w]+(:[0-9]+)?)/)?(?[-a-z0-9]+/[-a-z0-9]+/[-.a-z0-9]+)"); @@ -85,7 +84,7 @@ private Collection parsePluginFQNs(String attribute) throws Infrastru String[] plugins = splitAttribute(attribute); if (plugins.length == 0) { - return Collections.emptyList(); + return emptyList(); } List collectedFQNs = new ArrayList<>(); @@ -120,7 +119,7 @@ private PluginFQN parsePluginFQN(String plugin) throws InfrastructureException { } catch (URISyntaxException e) { throw new InfrastructureException( format( - "Plugin registry URL '%s' is incorrect. Problematic plugin entry: '%s'", + "Plugin registry URL '%s' is invalid. Problematic plugin entry: '%s'", registry, plugin)); } } diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java index 613544de277..f254681f528 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java @@ -123,6 +123,10 @@ public static Object[][] invalidAttributeStringProvider() { {formatPlugin("http://testregistry:8080", "bad:pluginname/1.0")}, {formatPlugin("http://testregistry:8080", "/version")}, {formatPlugin("http://testregistry:8080", "id/")}, + {formatPlugin("http://testregistry:8080", "name/version")}, + {formatPlugin("http://testregistry:8080", "id:version")}, + {formatPlugin("http://testregistry:8080", "publisher/name:version")}, + {formatPlugin("http://testregistry:8080", "publisher/name/version/odd")}, {formatPlugin("http://testregistry:8080", "")} }; } @@ -145,6 +149,8 @@ public static Object[][] validAttributesProvider() { ImmutableList.of(basicEditor, withRegistry), createAttributes(formatPlugin(basicEditor), formatPlugins(withRegistry)) }, + // https + // with path v3 { "Test plugin without registry", ImmutableList.of(basicEditor, noRegistry), From eb4b7376b8181b215352ef048513a3a365ce9bf6 Mon Sep 17 00:00:00 2001 From: Oleksandr Garagatyi Date: Fri, 26 Apr 2019 10:39:44 +0300 Subject: [PATCH 09/19] fixup! fixup! fixup! fixup! fixup! fixup! fixup! Rework --- .../org/eclipse/che/api/workspace/shared/Constants.java | 5 +++-- .../api/workspace/server/wsplugins/PluginFQNParser.java | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/Constants.java b/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/Constants.java index 3d695b145df..fb3f3320b62 100644 --- a/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/Constants.java +++ b/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/Constants.java @@ -119,8 +119,9 @@ public final class Constants { /** * Template for workspace attribute key that sets sidecar limit in a plugin. %s should be replaced - * with plugin ID. When plugin provides several sidecars this property sets the same limit for - * each sidecar, so is not that useful in such a case. Value format see {@link KubernetesSize} + * with pluginPublisher/pluginName. When plugin provides several sidecars this property sets the + * same limit for each sidecar, so is not that useful in such a case. + * Value format see {@link KubernetesSize} */ public static final String SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE = "sidecar.%s.memory_limit"; diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java index c8159e8a48f..6941c49290a 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java @@ -42,9 +42,14 @@ public class PluginFQNParser { private static final String INCORRECT_PLUGIN_FORMAT_TEMPLATE = "Plugin '%s' has incorrect format. Should be: 'registryURL/publisher/name/version' or 'publisher/name/version'"; + private static final String REGISTRY_PATTERN = "https?://[-./\\w]+(:[0-9]+)?"; + private static final String PUBLISHER_PATTERN = "[-a-z0-9]+"; + private static final String NAME_PATTERN = "[-a-z0-9]+"; + private static final String VERSION_PATTERN = "[-.a-z0-9]+"; + private static final String ID_PATTERN = PUBLISHER_PATTERN + "/" + NAME_PATTERN + "/" + VERSION_PATTERN; private static final Pattern PLUGIN_PATTERN = Pattern.compile( - "((?(https?://)[-./\\w]+(:[0-9]+)?)/)?(?[-a-z0-9]+/[-a-z0-9]+/[-.a-z0-9]+)"); + "((?" + REGISTRY_PATTERN + ")/)?(?" + ID_PATTERN + ")"); /** * Parses a workspace attributes map into a collection of {@link PluginFQN}. From 6d46c293a40ae61880b6d58b578d86db7acf8af1 Mon Sep 17 00:00:00 2001 From: Oleksandr Garagatyi Date: Fri, 26 Apr 2019 11:59:18 +0300 Subject: [PATCH 10/19] Add new capabilities to FQN parser Signed-off-by: Oleksandr Garagatyi --- .../BrokerEnvironmentFactoryTest.java | 2 +- .../server/wsplugins/PluginFQNParser.java | 17 +- .../wsplugins/model/ExtendedPluginFQN.java | 91 +++++++ .../server/wsplugins/model/PluginFQN.java | 5 +- .../server/wsplugins/PluginFQNParserTest.java | 247 +++++++++++++----- 5 files changed, 285 insertions(+), 77 deletions(-) create mode 100644 wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/ExtendedPluginFQN.java diff --git a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactoryTest.java b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactoryTest.java index 4e227e1441b..789f13ea860 100644 --- a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactoryTest.java +++ b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactoryTest.java @@ -149,7 +149,7 @@ public void shouldNameContainersAfterPluginBrokerImage() throws Exception { } @Test - public void shouldCreateConfigmapWithPluginFQNs() throws Exception { + public void shouldCreateConfigMapWithPluginFQNs() throws Exception { // given Collection pluginFQNs = ImmutableList.of( diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java index 6941c49290a..feb3cbed378 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java @@ -26,6 +26,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import org.eclipse.che.api.workspace.server.spi.InfrastructureException; +import org.eclipse.che.api.workspace.server.wsplugins.model.ExtendedPluginFQN; import org.eclipse.che.api.workspace.server.wsplugins.model.PluginFQN; import org.eclipse.che.api.workspace.shared.Constants; @@ -42,11 +43,13 @@ public class PluginFQNParser { private static final String INCORRECT_PLUGIN_FORMAT_TEMPLATE = "Plugin '%s' has incorrect format. Should be: 'registryURL/publisher/name/version' or 'publisher/name/version'"; - private static final String REGISTRY_PATTERN = "https?://[-./\\w]+(:[0-9]+)?"; + private static final String REGISTRY_PATTERN = "https?://[-./\\w]+(:[0-9]+)?(/[-./\\w]+)?"; private static final String PUBLISHER_PATTERN = "[-a-z0-9]+"; private static final String NAME_PATTERN = "[-a-z0-9]+"; private static final String VERSION_PATTERN = "[-.a-z0-9]+"; - private static final String ID_PATTERN = PUBLISHER_PATTERN + "/" + NAME_PATTERN + "/" + VERSION_PATTERN; + private static final String ID_PATTERN = + "(?" + PUBLISHER_PATTERN + ")/(?" + NAME_PATTERN + ")/(?" + + VERSION_PATTERN + ")"; private static final Pattern PLUGIN_PATTERN = Pattern.compile( "((?" + REGISTRY_PATTERN + ")/)?(?" + ID_PATTERN + ")"); @@ -107,14 +110,20 @@ private Collection parsePluginFQNs(String attribute) throws Infrastru return collectedFQNs; } - private PluginFQN parsePluginFQN(String plugin) throws InfrastructureException { + public ExtendedPluginFQN parsePluginFQN(String plugin) throws InfrastructureException { String registry; String id; + String publisher; + String name; + String version; URI registryURI = null; Matcher matcher = PLUGIN_PATTERN.matcher(plugin); if (matcher.matches()) { registry = matcher.group("registry"); id = matcher.group("id"); + publisher = matcher.group("publisher"); + name = matcher.group("name"); + version = matcher.group("version"); } else { throw new InfrastructureException(format(INCORRECT_PLUGIN_FORMAT_TEMPLATE, plugin)); } @@ -129,7 +138,7 @@ private PluginFQN parsePluginFQN(String plugin) throws InfrastructureException { } } - return new PluginFQN(registryURI, id); + return new ExtendedPluginFQN(registryURI, id, publisher, name, version); } private String[] splitAttribute(String attribute) { diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/ExtendedPluginFQN.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/ExtendedPluginFQN.java new file mode 100644 index 00000000000..c1e112758a3 --- /dev/null +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/ExtendedPluginFQN.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2012-2018 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.che.api.workspace.server.wsplugins.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import java.net.URI; +import java.util.Objects; + +/** + * Represents extended information about plugin identification. + * + * @author Oleksandr Garagatyi + * @see PluginFQN + */ +@JsonInclude(Include.NON_NULL) +public class ExtendedPluginFQN extends PluginFQN { + + private String name; + private String version; + private String publisher; + + public ExtendedPluginFQN(URI registry, String id, String publisher, String name, String version) { + super(registry, id); + this.publisher = publisher; + this.name = name; + this.version = version; + } + + public String getPublisher() { + return publisher; + } + + public void setPublisher(String publisher) { + this.publisher = publisher; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof ExtendedPluginFQN)) { + return false; + } + if (!super.equals(o)) { + return false; + } + ExtendedPluginFQN that = (ExtendedPluginFQN) o; + return Objects.equals(getName(), that.getName()) && + Objects.equals(getVersion(), that.getVersion()) && + Objects.equals(getPublisher(), that.getPublisher()); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), getName(), getVersion(), getPublisher()); + } + + @Override + public String toString() { + return String + .format("{id:%s, registry:%s, publisher:%s, name:%s, version:%s}", getId(), getRegistry(), + getPublisher(), getName(), getVersion()); + } +} diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/PluginFQN.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/PluginFQN.java index a1c5a69f800..cf7fc11463e 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/PluginFQN.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/PluginFQN.java @@ -58,11 +58,12 @@ public boolean equals(Object obj) { if (this == obj) { return true; } - if (obj == null || getClass() != obj.getClass()) { + if (!(obj instanceof PluginFQN)) { return false; } PluginFQN other = (PluginFQN) obj; - return Objects.equals(id, other.id) && Objects.equals(registry, other.registry); + return Objects.equals(getId(), other.getId()) && Objects + .equals(getRegistry(), other.getRegistry()); } @Override diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java index f254681f528..b0c66b2adb2 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java @@ -11,6 +11,7 @@ */ package org.eclipse.che.api.workspace.server.wsplugins; +import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEqualsNoOrder; import static org.testng.Assert.assertTrue; @@ -24,6 +25,7 @@ import java.util.List; import java.util.Map; import org.eclipse.che.api.workspace.server.spi.InfrastructureException; +import org.eclipse.che.api.workspace.server.wsplugins.model.ExtendedPluginFQN; import org.eclipse.che.api.workspace.server.wsplugins.model.PluginFQN; import org.eclipse.che.api.workspace.shared.Constants; import org.mockito.testng.MockitoTestNGListener; @@ -54,10 +56,16 @@ public void shouldReturnEmptyListWhenNoPluginsOrEditors() throws Exception { } @Test(dataProvider = "validAttributesProvider") - public void shouldParseAllPluginsAndEditor( - String desc, List expected, Map attributes) throws Exception { - Collection actual = parser.parsePlugins(attributes); - assertEqualsNoOrder(actual.toArray(), expected.toArray(), desc); + public void shouldParseAllPluginsAndEditor(AttributeParsingTestCase testCase) throws Exception { + Collection actual = parser.parsePlugins(testCase.attributes); + assertEqualsNoOrder(actual.toArray(), testCase.expectedPlugins.toArray()); + } + + @Test(dataProvider = "validPluginStringProvider") + public void shouldParsePluginOrEditorToExtendedFQN(String plugin, ExtendedPluginFQN expected) + throws Exception { + ExtendedPluginFQN actual = parser.parsePluginFQN(plugin); + assertEquals(actual, expected); } @Test( @@ -118,21 +126,18 @@ public void shouldDetectDuplicatedPluginsIfTheyArePrefixedOrSuffixedWithEmptySpa @DataProvider(name = "invalidAttributeStringProvider") public static Object[][] invalidAttributeStringProvider() { - return new Object[][] { - {formatPlugin("http://bad registry url", "testplugin/1.0")}, - {formatPlugin("http://testregistry:8080", "bad:pluginname/1.0")}, - {formatPlugin("http://testregistry:8080", "/version")}, - {formatPlugin("http://testregistry:8080", "id/")}, - {formatPlugin("http://testregistry:8080", "name/version")}, - {formatPlugin("http://testregistry:8080", "id:version")}, - {formatPlugin("http://testregistry:8080", "publisher/name:version")}, - {formatPlugin("http://testregistry:8080", "publisher/name/version/odd")}, - {formatPlugin("http://testregistry:8080", "")} + return new Object[][]{ + {formatPlugin("http://bad registry url", "testplugin/1.0")}, + {formatPlugin("http://testregistry:8080", "bad:pluginname/1.0")}, + {formatPlugin("http://testregistry:8080", "/version")}, + {formatPlugin("http://testregistry:8080", "id/")}, + {formatPlugin("http://testregistry:8080", "name/version")}, + {formatPlugin("http://testregistry:8080", "id:version")}, + {formatPlugin("http://testregistry:8080", "publisher/name:version")}, + {formatPlugin("http://testregistry:8080", "")} }; } - // Objects are - // (String description, List expectedPlugins, Map attributes) @DataProvider(name = "validAttributesProvider") public static Object[][] validAttributesProvider() { PluginFQN basicEditor = @@ -143,60 +148,138 @@ public static Object[][] validAttributesProvider() { PluginFQN pathRegistry = new PluginFQN( URI.create("http://registry/multiple/path/"), "publisher/pluginpathregistry/3.0"); - return new Object[][] { - { - "Test plugin with registry", - ImmutableList.of(basicEditor, withRegistry), - createAttributes(formatPlugin(basicEditor), formatPlugins(withRegistry)) - }, - // https - // with path v3 - { - "Test plugin without registry", - ImmutableList.of(basicEditor, noRegistry), - createAttributes(formatPlugin(basicEditor), formatPlugins(noRegistry)) - }, - { - "Test plugin with multi-level path in registry", - ImmutableList.of(basicEditor, pathRegistry), - createAttributes(formatPlugin(basicEditor), formatPlugins(pathRegistry)) - }, - { - "Test attributes with no editor field", - ImmutableList.of(withRegistry), - createAttributes(null, formatPlugins(withRegistry)) - }, - { - "Test attributes with empty editor field", - ImmutableList.of(withRegistry), - createAttributes("", formatPlugins(withRegistry)) - }, - { - "Test attributes with no plugin field", - ImmutableList.of(basicEditor), - createAttributes(formatPlugin(basicEditor), (String[]) null) - }, - { - "Test attributes with empty plugin field", - ImmutableList.of(basicEditor), - createAttributes(formatPlugin(basicEditor), "") - }, - { - "Test attributes with no plugin or editor field", - Collections.emptyList(), - createAttributes(null, (String[]) null) - }, - { - "Test attributes with empty plugin and editor field", - Collections.emptyList(), - createAttributes("", "") - }, - { - "Test multiple plugins and an editor", - ImmutableList.of(basicEditor, withRegistry, noRegistry, pathRegistry), - createAttributes( - formatPlugin(basicEditor), formatPlugins(withRegistry, noRegistry, pathRegistry)) - }, + return new AttributeParsingTestCase[][]{ + { + new AttributeParsingTestCase("Test plugin with registry", + ImmutableList.of(basicEditor, withRegistry), + createAttributes(formatPlugin(basicEditor), formatPlugins(withRegistry))) + }, + { + new AttributeParsingTestCase("Test plugin with https registry", + ImmutableList.of( + new PluginFQN(URI.create("https://registry:8080"), "publisher/editor/ver")), + createAttributes(null, formatPlugin( + new PluginFQN(URI.create("https://registry:8080"), "publisher/editor/ver")))) + }, + { + new AttributeParsingTestCase("Test plugin with registry containing path", + ImmutableList.of(new PluginFQN(URI.create("https://registry:8080/some/path/v3"), + "publisher/editor/ver")), + createAttributes(null, formatPlugin( + new PluginFQN(URI.create("https://registry:8080/some/path/v3"), + "publisher/editor/ver")))) + }, + { + new AttributeParsingTestCase("Test plugin without registry", + ImmutableList.of(basicEditor, noRegistry), + createAttributes(formatPlugin(basicEditor), formatPlugins(noRegistry))) + }, + { + new AttributeParsingTestCase("Test plugin with multi-level path in registry", + ImmutableList.of(basicEditor, pathRegistry), + createAttributes(formatPlugin(basicEditor), formatPlugins(pathRegistry))) + }, + { + new AttributeParsingTestCase("Test attributes with no editor field", + ImmutableList.of(withRegistry), + createAttributes(null, formatPlugins(withRegistry))) + }, + { + new AttributeParsingTestCase("Test attributes with empty editor field", + ImmutableList.of(withRegistry), + createAttributes("", formatPlugins(withRegistry))) + }, + { + new AttributeParsingTestCase("Test attributes with no plugin field", + ImmutableList.of(basicEditor), + createAttributes(formatPlugin(basicEditor), (String[]) null)) + }, + { + new AttributeParsingTestCase("Test attributes with empty plugin field", + ImmutableList.of(basicEditor), + createAttributes(formatPlugin(basicEditor), "")) + }, + { + new AttributeParsingTestCase("Test attributes with no plugin or editor field", + Collections.emptyList(), + createAttributes(null, (String[]) null)) + }, + { + new AttributeParsingTestCase("Test attributes with empty plugin and editor field", + Collections.emptyList(), + createAttributes("", "")) + }, + { + new AttributeParsingTestCase("Test multiple plugins and an editor", + ImmutableList.of(basicEditor, withRegistry, noRegistry, pathRegistry), + createAttributes( + formatPlugin(basicEditor), + formatPlugins(withRegistry, noRegistry, pathRegistry))) + }, + }; + } + + // Objects are + // (String plugin, ExtendedPluginFQN expectedPlugin) + @DataProvider(name = "validPluginStringProvider") + public static Object[][] validPluginStringProvider() { + return new Object[][]{ + { + "http://registry:8080/publisher/editor/ver", + new ExtendedPluginFQN(URI.create("http://registry:8080"), "publisher/editor/ver", + "publisher", "editor", "ver") + }, + { + "https://registry:8080/publisher/editor/ver", + new ExtendedPluginFQN(URI.create("https://registry:8080"), "publisher/editor/ver", + "publisher", "editor", "ver") + }, + { + "https://che-registry.com.ua/publisher/editor/ver", + new ExtendedPluginFQN(URI.create("https://che-registry.com.ua"), "publisher/editor/ver", + "publisher", "editor", "ver") + }, + { + "https://che-registry.com.ua/plugins/publisher/editor/ver", + new ExtendedPluginFQN(URI.create("https://che-registry.com.ua/plugins"), + "publisher/editor/ver", + "publisher", "editor", "ver") + }, + { + "https://che-registry.com.ua/plugins/v3/publisher/editor/ver", + new ExtendedPluginFQN(URI.create("https://che-registry.com.ua/plugins/v3"), + "publisher/editor/ver", + "publisher", "editor", "ver") + }, + { + "https://che-registry.com.ua/some/long/path/publisher/editor/ver", + new ExtendedPluginFQN(URI.create("https://che-registry.com.ua/some/long/path"), + "publisher/editor/ver", + "publisher", "editor", "ver") + }, + { + "publisher/editor/ver", + new ExtendedPluginFQN(null, "publisher/editor/ver", "publisher", "editor", "ver") + }, + { + "publisher/editor/1.12.1", + new ExtendedPluginFQN(null, "publisher/editor/1.12.1", "publisher", "editor", "1.12.1") + }, + { + "publisher/editor/v2.12.x", + new ExtendedPluginFQN(null, "publisher/editor/v2.12.x", "publisher", "editor", + "v2.12.x") + }, + { + "publisher/che-theia/next", + new ExtendedPluginFQN(null, "publisher/che-theia/next", "publisher", "che-theia", + "next") + }, + { + "publisher/che-theia/2.12-latest", + new ExtendedPluginFQN(null, "publisher/che-theia/2.12-latest", "publisher", "che-theia", + "2.12-latest") + }, }; } @@ -228,4 +311,28 @@ private static Map createAttributes(String editor, String... plu } return ImmutableMap.copyOf(attributes); } + + /** + * Holder of data for a test case. Syntax sugar that primary goal is to allow IDE log test case + * description (in one of the fields) and compare expected and actual arrays in a way that prints + * diff when they are not equal + */ + private static class AttributeParsingTestCase { + + String description; + List expectedPlugins; + Map attributes; + + public AttributeParsingTestCase(String description, List expectedPlugins, + Map attributes) { + this.description = description; + this.expectedPlugins = expectedPlugins; + this.attributes = attributes; + } + + @Override + public String toString() { + return description; + } + } } From 826646a3403825d7dddb094167adc924d42e2ca1 Mon Sep 17 00:00:00 2001 From: Oleksandr Garagatyi Date: Fri, 26 Apr 2019 12:27:15 +0300 Subject: [PATCH 11/19] Move fqn parsing for devfile to PLuginFQNParser Signed-off-by: Oleksandr Garagatyi --- .../convert/DefaultEditorProvisioner.java | 46 +-- .../editor/EditorComponentProvisioner.java | 33 +- .../EditorComponentToWorkspaceApplier.java | 31 +- .../PluginComponentToWorkspaceApplier.java | 30 +- .../component/plugin/PluginProvisioner.java | 32 +- .../plugin/PluginReferenceParser.java | 44 --- .../exception/WorkspaceExportException.java | 4 + .../convert/DefaultEditorProvisionerTest.java | 63 ++-- .../EditorComponentProvisionerTest.java | 10 +- ...EditorComponentToWorkspaceApplierTest.java | 14 +- ...PluginComponentToWorkspaceApplierTest.java | 14 +- .../plugin/PluginProvisionerTest.java | 10 +- .../DefaultFactoryParameterResolverTest.java | 4 +- .../che/api/workspace/shared/Constants.java | 4 +- .../server/wsplugins/PluginFQNParser.java | 12 +- .../wsplugins/model/ExtendedPluginFQN.java | 19 +- .../server/wsplugins/model/PluginFQN.java | 4 +- .../server/wsplugins/PluginFQNParserTest.java | 303 ++++++++++-------- 18 files changed, 391 insertions(+), 286 deletions(-) delete mode 100644 wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginReferenceParser.java diff --git a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisioner.java b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisioner.java index f40e4d5be64..3c21aa6c444 100644 --- a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisioner.java +++ b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisioner.java @@ -11,14 +11,11 @@ */ package org.eclipse.che.api.devfile.server.convert; -import static java.util.function.Function.identity; -import static java.util.stream.Collectors.toMap; import static org.eclipse.che.api.devfile.server.Constants.EDITOR_COMPONENT_TYPE; import static org.eclipse.che.api.devfile.server.Constants.EDITOR_FREE_DEVFILE_ATTRIBUTE; import static org.eclipse.che.api.devfile.server.Constants.PLUGIN_COMPONENT_TYPE; import com.google.common.base.Strings; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -26,10 +23,12 @@ import javax.inject.Inject; import javax.inject.Named; import org.eclipse.che.api.core.model.workspace.devfile.Component; -import org.eclipse.che.api.devfile.server.convert.component.plugin.PluginReferenceParser; +import org.eclipse.che.api.devfile.server.exception.DevfileException; import org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl; -import org.eclipse.che.api.workspace.server.wsplugins.model.PluginMeta; +import org.eclipse.che.api.workspace.server.spi.InfrastructureException; +import org.eclipse.che.api.workspace.server.wsplugins.PluginFQNParser; +import org.eclipse.che.api.workspace.server.wsplugins.model.ExtendedPluginFQN; /** * Provision default editor if there is no any another editor and default plugins for it. @@ -41,17 +40,23 @@ public class DefaultEditorProvisioner { private final String defaultEditorRef; private final String defaultEditor; private final Map defaultPluginsToRefs; + private final PluginFQNParser fqnParser; @Inject public DefaultEditorProvisioner( @Named("che.workspace.devfile.default_editor") String defaultEditorRef, - @Named("che.workspace.devfile.default_editor.plugins") String[] defaultPluginsRefs) { + @Named("che.workspace.devfile.default_editor.plugins") String[] defaultPluginsRefs, + PluginFQNParser fqnParser) + throws DevfileException { this.defaultEditorRef = Strings.isNullOrEmpty(defaultEditorRef) ? null : defaultEditorRef; + this.fqnParser = fqnParser; this.defaultEditor = this.defaultEditorRef == null ? null : getPluginPublisherAndName(this.defaultEditorRef); - this.defaultPluginsToRefs = - Arrays.stream(defaultPluginsRefs) - .collect(toMap(this::getPluginPublisherAndName, identity())); + Map map = new HashMap<>(); + for (String defaultPluginsRef : defaultPluginsRefs) { + map.put(getPluginPublisherAndName(defaultPluginsRef), defaultPluginsRef); + } + this.defaultPluginsToRefs = map; } /** @@ -60,7 +65,7 @@ public DefaultEditorProvisioner( * * @param devfile devfile where editor and plugins should be provisioned */ - public void apply(DevfileImpl devfile) { + public void apply(DevfileImpl devfile) throws DevfileException { if (defaultEditorRef == null) { // there is no default editor configured return; @@ -89,21 +94,26 @@ public void apply(DevfileImpl devfile) { } } - private void provisionDefaultPlugins(List components) { + private void provisionDefaultPlugins(List components) throws DevfileException { Map missingPluginsIdToRef = new HashMap<>(defaultPluginsToRefs); - components - .stream() - .filter(t -> PLUGIN_COMPONENT_TYPE.equals(t.getType())) - .forEach(t -> missingPluginsIdToRef.remove(getPluginPublisherAndName(t.getId()))); + for (ComponentImpl t : components) { + if (PLUGIN_COMPONENT_TYPE.equals(t.getType())) { + missingPluginsIdToRef.remove(getPluginPublisherAndName(t.getId())); + } + } missingPluginsIdToRef .values() .forEach(pluginRef -> components.add(new ComponentImpl(PLUGIN_COMPONENT_TYPE, pluginRef))); } - private String getPluginPublisherAndName(String reference) { - PluginMeta meta = PluginReferenceParser.resolveMeta(reference); - return meta.getPublisher() + "/" + meta.getName(); + private String getPluginPublisherAndName(String reference) throws DevfileException { + try { + ExtendedPluginFQN meta = fqnParser.parsePluginFQN(reference); + return meta.getPublisherAndName(); + } catch (InfrastructureException e) { + throw new DevfileException(e.getMessage(), e); + } } } diff --git a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentProvisioner.java b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentProvisioner.java index 28cea77bf2d..beab49a0815 100644 --- a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentProvisioner.java +++ b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentProvisioner.java @@ -17,12 +17,15 @@ import static org.eclipse.che.api.workspace.shared.Constants.SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE; import static org.eclipse.che.api.workspace.shared.Constants.WORKSPACE_TOOLING_EDITOR_ATTRIBUTE; +import javax.inject.Inject; import org.eclipse.che.api.devfile.server.convert.component.ComponentProvisioner; -import org.eclipse.che.api.devfile.server.convert.component.plugin.PluginReferenceParser; +import org.eclipse.che.api.devfile.server.exception.WorkspaceExportException; import org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl; -import org.eclipse.che.api.workspace.server.wsplugins.model.PluginMeta; +import org.eclipse.che.api.workspace.server.spi.InfrastructureException; +import org.eclipse.che.api.workspace.server.wsplugins.PluginFQNParser; +import org.eclipse.che.api.workspace.server.wsplugins.model.ExtendedPluginFQN; import org.eclipse.che.api.workspace.shared.Constants; /** @@ -33,6 +36,13 @@ */ public class EditorComponentProvisioner implements ComponentProvisioner { + private final PluginFQNParser fqnParser; + + @Inject + public EditorComponentProvisioner(PluginFQNParser fqnParser) { + this.fqnParser = fqnParser; + } + /** * Converts workspace editor attribute to cheEditor component and injects it into the specified * {@link DevfileImpl devfile}. @@ -41,28 +51,31 @@ public class EditorComponentProvisioner implements ComponentProvisioner { * @param workspaceConfig workspace config that may contain environments to convert */ @Override - public void provision(DevfileImpl devfile, WorkspaceConfigImpl workspaceConfig) { + public void provision(DevfileImpl devfile, WorkspaceConfigImpl workspaceConfig) + throws WorkspaceExportException { String editorAttribute = workspaceConfig.getAttributes().get(WORKSPACE_TOOLING_EDITOR_ATTRIBUTE); if (editorAttribute == null) { return; } - PluginMeta meta = PluginReferenceParser.resolveMeta(editorAttribute); + ExtendedPluginFQN fqn; + try { + fqn = fqnParser.parsePluginFQN(editorAttribute); + } catch (InfrastructureException e) { + throw new WorkspaceExportException(e.getMessage(), e); + } - ComponentImpl editorComponent = new ComponentImpl(EDITOR_COMPONENT_TYPE, meta.getId()); + ComponentImpl editorComponent = new ComponentImpl(EDITOR_COMPONENT_TYPE, fqn.getId()); editorComponent.setAlias( workspaceConfig .getAttributes() - .getOrDefault(EDITOR_COMPONENT_ALIAS_WORKSPACE_ATTRIBUTE, meta.getId())); + .getOrDefault(EDITOR_COMPONENT_ALIAS_WORKSPACE_ATTRIBUTE, fqn.getId())); editorComponent.setMemoryLimit( workspaceConfig .getAttributes() - .get( - format( - SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, - meta.getPublisher() + "/" + meta.getName()))); + .get(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, fqn.getPublisherAndName()))); devfile.getComponents().add(editorComponent); } } diff --git a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplier.java b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplier.java index d260464bd18..88d80ce7f28 100644 --- a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplier.java +++ b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplier.java @@ -20,12 +20,15 @@ import static org.eclipse.che.api.workspace.shared.Constants.SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE; import static org.eclipse.che.api.workspace.shared.Constants.WORKSPACE_TOOLING_EDITOR_ATTRIBUTE; +import javax.inject.Inject; import org.eclipse.che.api.core.model.workspace.devfile.Component; import org.eclipse.che.api.devfile.server.FileContentProvider; import org.eclipse.che.api.devfile.server.convert.component.ComponentToWorkspaceApplier; -import org.eclipse.che.api.devfile.server.convert.component.plugin.PluginReferenceParser; +import org.eclipse.che.api.devfile.server.exception.DevfileException; import org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl; -import org.eclipse.che.api.workspace.server.wsplugins.model.PluginMeta; +import org.eclipse.che.api.workspace.server.spi.InfrastructureException; +import org.eclipse.che.api.workspace.server.wsplugins.PluginFQNParser; +import org.eclipse.che.api.workspace.server.wsplugins.model.ExtendedPluginFQN; /** * Applies changes on workspace config according to the specified editor component. @@ -34,6 +37,13 @@ */ public class EditorComponentToWorkspaceApplier implements ComponentToWorkspaceApplier { + private final PluginFQNParser fqnParser; + + @Inject + public EditorComponentToWorkspaceApplier(PluginFQNParser fqnParser) { + this.fqnParser = fqnParser; + } + /** * Applies changes on workspace config according to the specified editor component. * @@ -48,7 +58,8 @@ public class EditorComponentToWorkspaceApplier implements ComponentToWorkspaceAp public void apply( WorkspaceConfigImpl workspaceConfig, Component editorComponent, - FileContentProvider contentProvider) { + FileContentProvider contentProvider) + throws DevfileException { checkArgument(workspaceConfig != null, "Workspace config must not be null"); checkArgument(editorComponent != null, "Component must not be null"); checkArgument( @@ -67,14 +78,16 @@ public void apply( .put(EDITOR_COMPONENT_ALIAS_WORKSPACE_ATTRIBUTE, editorComponentAlias); } - PluginMeta meta = PluginReferenceParser.resolveMeta(editorId); + final ExtendedPluginFQN fqn; + try { + fqn = fqnParser.parsePluginFQN(editorId); + } catch (InfrastructureException e) { + throw new DevfileException(e.getMessage(), e); + } if (memoryLimit != null) { workspaceConfig .getAttributes() - .put( - format( - SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, meta.getPublisher() + "/" + meta.getName()), - memoryLimit); + .put(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, fqn.getPublisherAndName()), memoryLimit); } workspaceConfig .getCommands() @@ -84,6 +97,6 @@ public void apply( c.getAttributes() .get(COMPONENT_ALIAS_COMMAND_ATTRIBUTE) .equals(editorComponentAlias)) - .forEach(c -> c.getAttributes().put(PLUGIN_ATTRIBUTE, meta.getId())); + .forEach(c -> c.getAttributes().put(PLUGIN_ATTRIBUTE, fqn.getId())); } } diff --git a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplier.java b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplier.java index 66536ea22b3..00dcc0a3e23 100644 --- a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplier.java +++ b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplier.java @@ -21,12 +21,16 @@ import static org.eclipse.che.api.workspace.shared.Constants.SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE; import static org.eclipse.che.api.workspace.shared.Constants.WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE; +import javax.inject.Inject; import org.eclipse.che.api.core.model.workspace.devfile.Component; import org.eclipse.che.api.devfile.server.FileContentProvider; import org.eclipse.che.api.devfile.server.convert.component.ComponentToWorkspaceApplier; +import org.eclipse.che.api.devfile.server.exception.DevfileException; import org.eclipse.che.api.workspace.server.model.impl.CommandImpl; import org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl; -import org.eclipse.che.api.workspace.server.wsplugins.model.PluginMeta; +import org.eclipse.che.api.workspace.server.spi.InfrastructureException; +import org.eclipse.che.api.workspace.server.wsplugins.PluginFQNParser; +import org.eclipse.che.api.workspace.server.wsplugins.model.ExtendedPluginFQN; import org.eclipse.che.commons.annotation.Nullable; /** @@ -36,6 +40,13 @@ */ public class PluginComponentToWorkspaceApplier implements ComponentToWorkspaceApplier { + private final PluginFQNParser fqnParser; + + @Inject + public PluginComponentToWorkspaceApplier(PluginFQNParser fqnParser) { + this.fqnParser = fqnParser; + } + /** * Applies changes on workspace config according to the specified plugin component. * @@ -50,7 +61,8 @@ public class PluginComponentToWorkspaceApplier implements ComponentToWorkspaceAp public void apply( WorkspaceConfigImpl workspaceConfig, Component pluginComponent, - @Nullable FileContentProvider contentProvider) { + @Nullable FileContentProvider contentProvider) + throws DevfileException { checkArgument(workspaceConfig != null, "Workspace config must not be null"); checkArgument(pluginComponent != null, "Component must not be null"); checkArgument( @@ -75,15 +87,17 @@ public void apply( append(pluginsAliases, pluginComponent.getId() + "=" + pluginComponent.getAlias())); } - PluginMeta meta = PluginReferenceParser.resolveMeta(pluginComponent.getId()); + ExtendedPluginFQN fqn; + try { + fqn = fqnParser.parsePluginFQN(pluginComponent.getId()); + } catch (InfrastructureException e) { + throw new DevfileException(e.getMessage(), e); + } String memoryLimit = pluginComponent.getMemoryLimit(); if (memoryLimit != null) { workspaceConfig .getAttributes() - .put( - format( - SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, meta.getPublisher() + "/" + meta.getName()), - memoryLimit); + .put(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, fqn.getPublisherAndName()), memoryLimit); } for (CommandImpl command : workspaceConfig.getCommands()) { @@ -98,7 +112,7 @@ public void apply( continue; } - command.getAttributes().put(PLUGIN_ATTRIBUTE, meta.getId()); + command.getAttributes().put(PLUGIN_ATTRIBUTE, fqn.getId()); } } diff --git a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginProvisioner.java b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginProvisioner.java index f6014c137cf..cd3aa53711a 100644 --- a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginProvisioner.java +++ b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginProvisioner.java @@ -23,11 +23,15 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import javax.inject.Inject; import org.eclipse.che.api.devfile.server.convert.component.ComponentProvisioner; +import org.eclipse.che.api.devfile.server.exception.WorkspaceExportException; import org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl; -import org.eclipse.che.api.workspace.server.wsplugins.model.PluginMeta; +import org.eclipse.che.api.workspace.server.spi.InfrastructureException; +import org.eclipse.che.api.workspace.server.wsplugins.PluginFQNParser; +import org.eclipse.che.api.workspace.server.wsplugins.model.ExtendedPluginFQN; import org.eclipse.che.api.workspace.shared.Constants; /** @@ -38,6 +42,13 @@ */ public class PluginProvisioner implements ComponentProvisioner { + private final PluginFQNParser fqnParser; + + @Inject + public PluginProvisioner(PluginFQNParser fqnParser) { + this.fqnParser = fqnParser; + } + /** * Provision chePlugin components in {@link DevfileImpl} according to the value of {@link * Constants#WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE} in the specified {@link WorkspaceConfigImpl}. @@ -47,7 +58,8 @@ public class PluginProvisioner implements ComponentProvisioner { * @throws IllegalArgumentException if the specified workspace config or devfile is null */ @Override - public void provision(DevfileImpl devfile, WorkspaceConfigImpl workspaceConfig) { + public void provision(DevfileImpl devfile, WorkspaceConfigImpl workspaceConfig) + throws WorkspaceExportException { checkArgument(workspaceConfig != null, "Workspace config must not be null"); checkArgument(devfile != null, "Workspace config must not be null"); @@ -60,18 +72,20 @@ public void provision(DevfileImpl devfile, WorkspaceConfigImpl workspaceConfig) Map pluginIdToComponentAlias = extractPluginIdToComponentAlias(workspaceConfig); for (String pluginId : pluginsAttribute.split(",")) { - PluginMeta meta = PluginReferenceParser.resolveMeta(pluginId); + final ExtendedPluginFQN fqn; + try { + fqn = fqnParser.parsePluginFQN(pluginId); + } catch (InfrastructureException e) { + throw new WorkspaceExportException(e.getMessage(), e); + } - ComponentImpl pluginComponent = new ComponentImpl(PLUGIN_COMPONENT_TYPE, meta.getId()); + ComponentImpl pluginComponent = new ComponentImpl(PLUGIN_COMPONENT_TYPE, fqn.getId()); - pluginComponent.setAlias(pluginIdToComponentAlias.get(meta.getId())); + pluginComponent.setAlias(pluginIdToComponentAlias.get(fqn.getId())); pluginComponent.setMemoryLimit( workspaceConfig .getAttributes() - .get( - format( - SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, - meta.getPublisher() + "/" + meta.getName()))); + .get(format(SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE, fqn.getPublisherAndName()))); devfile.getComponents().add(pluginComponent); } } diff --git a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginReferenceParser.java b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginReferenceParser.java deleted file mode 100644 index ef740815b4c..00000000000 --- a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginReferenceParser.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2012-2018 Red Hat, Inc. - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - */ -package org.eclipse.che.api.devfile.server.convert.component.plugin; - -import static java.lang.String.format; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.eclipse.che.api.workspace.server.wsplugins.model.PluginMeta; - -/** - * Parses plugin reference in devfile to plugin meta object. Only fields which value are present in - * reference are populated in the object. - * - * @author Alexander Garagatyi - */ -public class PluginReferenceParser { - private static final Pattern PLUGIN_PATTERN = - Pattern.compile("(.*/)?(?[-a-z0-9]+)/(?[-a-z0-9]+)/(?[-.a-z0-9]+)"); - - public static PluginMeta resolveMeta(String ref) { - Matcher matcher = PLUGIN_PATTERN.matcher(ref); - if (!matcher.matches()) { - throw new IllegalArgumentException(format("Plugin reference '%s' is invalid", ref)); - } - - PluginMeta meta = - new PluginMeta() - .publisher(matcher.group("publisher")) - .name(matcher.group("name")) - .version(matcher.group("version")); - meta.id(meta.getPublisher() + "/" + meta.getName() + "/" + meta.getVersion()); - return meta; - } -} diff --git a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/exception/WorkspaceExportException.java b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/exception/WorkspaceExportException.java index 5037b2def9d..2c5c8383d8e 100644 --- a/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/exception/WorkspaceExportException.java +++ b/wsmaster/che-core-api-devfile/src/main/java/org/eclipse/che/api/devfile/server/exception/WorkspaceExportException.java @@ -17,4 +17,8 @@ public class WorkspaceExportException extends Exception { public WorkspaceExportException(String error) { super(error); } + + public WorkspaceExportException(String error, Exception cause) { + super(error, cause); + } } diff --git a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisionerTest.java b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisionerTest.java index 1173d813942..c2d21e270f7 100644 --- a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisionerTest.java +++ b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/DefaultEditorProvisionerTest.java @@ -20,8 +20,10 @@ import static org.testng.Assert.assertTrue; import java.util.List; +import org.eclipse.che.api.devfile.server.exception.DevfileException; import org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl; +import org.eclipse.che.api.workspace.server.wsplugins.PluginFQNParser; import org.testng.annotations.Test; /** @@ -47,10 +49,12 @@ public class DefaultEditorProvisionerTest { private DefaultEditorProvisioner provisioner; + private PluginFQNParser fqnParser = new PluginFQNParser(); + @Test - public void shouldNotProvisionDefaultEditorIfItIsNotConfigured() { + public void shouldNotProvisionDefaultEditorIfItIsNotConfigured() throws DevfileException { // given - provisioner = new DefaultEditorProvisioner(null, new String[] {}); + provisioner = new DefaultEditorProvisioner(null, new String[] {}, fqnParser); DevfileImpl devfile = new DevfileImpl(); // when @@ -61,11 +65,12 @@ public void shouldNotProvisionDefaultEditorIfItIsNotConfigured() { } @Test - public void shouldProvisionDefaultEditorWithPluginsWhenDevfileDoNotHaveAny() { + public void shouldProvisionDefaultEditorWithPluginsWhenDevfileDoNotHaveAny() + throws DevfileException { // given provisioner = new DefaultEditorProvisioner( - EDITOR_REF, new String[] {TERMINAL_PLUGIN_REF, COMMAND_PLUGIN_REF}); + EDITOR_REF, new String[] {TERMINAL_PLUGIN_REF, COMMAND_PLUGIN_REF}, fqnParser); DevfileImpl devfile = new DevfileImpl(); // when @@ -80,9 +85,11 @@ public void shouldProvisionDefaultEditorWithPluginsWhenDevfileDoNotHaveAny() { } @Test - public void shouldProvisionDefaultPluginsIfTheyAreNotSpecifiedAndDefaultEditorIsConfigured() { + public void shouldProvisionDefaultPluginsIfTheyAreNotSpecifiedAndDefaultEditorIsConfigured() + throws DevfileException { // given - provisioner = new DefaultEditorProvisioner(EDITOR_REF, new String[] {TERMINAL_PLUGIN_REF}); + provisioner = + new DefaultEditorProvisioner(EDITOR_REF, new String[] {TERMINAL_PLUGIN_REF}, fqnParser); DevfileImpl devfile = new DevfileImpl(); ComponentImpl defaultEditorWithDifferentVersion = @@ -103,9 +110,11 @@ public void shouldProvisionDefaultPluginsIfTheyAreNotSpecifiedAndDefaultEditorIs @Test public void - shouldProvisionDefaultPluginsIfTheyAreNotSpecifiedAndDefaultEditorFromCustomRegistryIsConfigured() { + shouldProvisionDefaultPluginsIfTheyAreNotSpecifiedAndDefaultEditorFromCustomRegistryIsConfigured() + throws DevfileException { // given - provisioner = new DefaultEditorProvisioner(EDITOR_REF, new String[] {TERMINAL_PLUGIN_REF}); + provisioner = + new DefaultEditorProvisioner(EDITOR_REF, new String[] {TERMINAL_PLUGIN_REF}, fqnParser); DevfileImpl devfile = new DevfileImpl(); ComponentImpl defaultEditorWithDifferentVersion = @@ -127,9 +136,11 @@ public void shouldProvisionDefaultPluginsIfTheyAreNotSpecifiedAndDefaultEditorIs } @Test - public void shouldNotProvisionDefaultPluginsIfCustomEditorIsConfiguredWhichStartWithDefaultId() { + public void shouldNotProvisionDefaultPluginsIfCustomEditorIsConfiguredWhichStartWithDefaultId() + throws DevfileException { // given - provisioner = new DefaultEditorProvisioner(EDITOR_REF, new String[] {TERMINAL_PLUGIN_REF}); + provisioner = + new DefaultEditorProvisioner(EDITOR_REF, new String[] {TERMINAL_PLUGIN_REF}, fqnParser); DevfileImpl devfile = new DevfileImpl(); ComponentImpl editorWithNameSimilarToDefault = @@ -148,9 +159,11 @@ public void shouldNotProvisionDefaultPluginsIfCustomEditorIsConfiguredWhichStart } @Test - public void shouldNotProvisionDefaultPluginsIfDevfileContainsEditorFreeAttribute() { + public void shouldNotProvisionDefaultPluginsIfDevfileContainsEditorFreeAttribute() + throws DevfileException { // given - provisioner = new DefaultEditorProvisioner(EDITOR_REF, new String[] {TERMINAL_PLUGIN_REF}); + provisioner = + new DefaultEditorProvisioner(EDITOR_REF, new String[] {TERMINAL_PLUGIN_REF}, fqnParser); DevfileImpl devfile = new DevfileImpl(); devfile.getAttributes().put(EDITOR_FREE_DEVFILE_ATTRIBUTE, "true"); @@ -165,9 +178,11 @@ public void shouldNotProvisionDefaultPluginsIfDevfileContainsEditorFreeAttribute @Test public void - shouldProvisionDefaultPluginIfDevfileAlreadyContainPluginWithNameWhichStartWithDefaultOne() { + shouldProvisionDefaultPluginIfDevfileAlreadyContainPluginWithNameWhichStartWithDefaultOne() + throws DevfileException { // given - provisioner = new DefaultEditorProvisioner(EDITOR_REF, new String[] {TERMINAL_PLUGIN_REF}); + provisioner = + new DefaultEditorProvisioner(EDITOR_REF, new String[] {TERMINAL_PLUGIN_REF}, fqnParser); DevfileImpl devfile = new DevfileImpl(); ComponentImpl pluginWithNameSimilarToDefault = @@ -187,9 +202,10 @@ public void shouldNotProvisionDefaultPluginsIfDevfileContainsEditorFreeAttribute } @Test - public void shouldNotProvisionDefaultEditorOrDefaultPluginsIfDevfileAlreadyHasNonDefaultEditor() { + public void shouldNotProvisionDefaultEditorOrDefaultPluginsIfDevfileAlreadyHasNonDefaultEditor() + throws DevfileException { // given - provisioner = new DefaultEditorProvisioner(EDITOR_REF, new String[] {}); + provisioner = new DefaultEditorProvisioner(EDITOR_REF, new String[] {}, fqnParser); DevfileImpl devfile = new DevfileImpl(); ComponentImpl nonDefaultEditor = new ComponentImpl(EDITOR_COMPONENT_TYPE, "anypublisher/anyname/v" + EDITOR_VERSION); @@ -205,9 +221,10 @@ public void shouldNotProvisionDefaultEditorOrDefaultPluginsIfDevfileAlreadyHasNo } @Test - public void shouldNonProvisionDefaultEditorIfDevfileAlreadyContainsSuchButWithDifferentVersion() { + public void shouldNonProvisionDefaultEditorIfDevfileAlreadyContainsSuchButWithDifferentVersion() + throws DevfileException { // given - provisioner = new DefaultEditorProvisioner(EDITOR_REF, new String[] {}); + provisioner = new DefaultEditorProvisioner(EDITOR_REF, new String[] {}, fqnParser); DevfileImpl devfile = new DevfileImpl(); ComponentImpl myTheiaEditor = new ComponentImpl( @@ -224,9 +241,11 @@ public void shouldNonProvisionDefaultEditorIfDevfileAlreadyContainsSuchButWithDi } @Test - public void shouldNotProvisionDefaultPluginIfDevfileAlreadyContainsSuchButWithDifferentVersion() { + public void shouldNotProvisionDefaultPluginIfDevfileAlreadyContainsSuchButWithDifferentVersion() + throws DevfileException { // given - provisioner = new DefaultEditorProvisioner(EDITOR_REF, new String[] {TERMINAL_PLUGIN_REF}); + provisioner = + new DefaultEditorProvisioner(EDITOR_REF, new String[] {TERMINAL_PLUGIN_REF}, fqnParser); DevfileImpl devfile = new DevfileImpl(); ComponentImpl myTerminal = new ComponentImpl( @@ -244,11 +263,11 @@ public void shouldNotProvisionDefaultPluginIfDevfileAlreadyContainsSuchButWithDi } @Test - public void shouldGenerateDefaultPluginNameIfIdIsNotUnique() { + public void shouldGenerateDefaultPluginNameIfIdIsNotUnique() throws DevfileException { // given provisioner = new DefaultEditorProvisioner( - EDITOR_REF, new String[] {EDITOR_PUBLISHER + "/" + "my-plugin/v2.0"}); + EDITOR_REF, new String[] {EDITOR_PUBLISHER + "/" + "my-plugin/v2.0"}, fqnParser); DevfileImpl devfile = new DevfileImpl(); ComponentImpl myPlugin = new ComponentImpl( diff --git a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentProvisionerTest.java b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentProvisionerTest.java index 79ed5f5331b..7c211594a38 100644 --- a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentProvisionerTest.java +++ b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentProvisionerTest.java @@ -18,9 +18,11 @@ import static org.eclipse.che.api.workspace.shared.Constants.WORKSPACE_TOOLING_EDITOR_ATTRIBUTE; import static org.testng.Assert.assertEquals; +import org.eclipse.che.api.devfile.server.exception.WorkspaceExportException; import org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl; +import org.eclipse.che.api.workspace.server.wsplugins.PluginFQNParser; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -28,14 +30,15 @@ public class EditorComponentProvisionerTest { private EditorComponentProvisioner editorComponentProvisioner; + private PluginFQNParser fqnParser = new PluginFQNParser(); @BeforeMethod public void setUp() { - editorComponentProvisioner = new EditorComponentProvisioner(); + editorComponentProvisioner = new EditorComponentProvisioner(fqnParser); } @Test - public void shouldProvisionCheEditorComponent() { + public void shouldProvisionCheEditorComponent() throws WorkspaceExportException { // given WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl(); String editorId = "eclipse/super-editor/0.0.1"; @@ -59,7 +62,8 @@ public void shouldProvisionCheEditorComponent() { } @Test - public void shouldUseEditorIdAsComponentNameIfAliasIsMissingDuringEditorComponentProvisioning() { + public void shouldUseEditorIdAsComponentNameIfAliasIsMissingDuringEditorComponentProvisioning() + throws WorkspaceExportException { // given WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl(); workspaceConfig diff --git a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplierTest.java b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplierTest.java index 070a70b6251..dcc2ac3c80b 100644 --- a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplierTest.java +++ b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/editor/EditorComponentToWorkspaceApplierTest.java @@ -20,9 +20,11 @@ import static org.eclipse.che.api.workspace.shared.Constants.WORKSPACE_TOOLING_EDITOR_ATTRIBUTE; import static org.testng.Assert.assertEquals; +import org.eclipse.che.api.devfile.server.exception.DevfileException; import org.eclipse.che.api.workspace.server.model.impl.CommandImpl; import org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl; +import org.eclipse.che.api.workspace.server.wsplugins.PluginFQNParser; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -30,14 +32,16 @@ public class EditorComponentToWorkspaceApplierTest { private EditorComponentToWorkspaceApplier editorComponentApplier; + private PluginFQNParser fqnParser = new PluginFQNParser(); @BeforeMethod public void setUp() { - editorComponentApplier = new EditorComponentToWorkspaceApplier(); + editorComponentApplier = new EditorComponentToWorkspaceApplier(fqnParser); } @Test - public void shouldProvisionWorkspaceEditorAttributeDuringCheEditorComponentApplying() { + public void shouldProvisionWorkspaceEditorAttributeDuringCheEditorComponentApplying() + throws DevfileException { String editorId = "eclipse/super-editor/0.0.1"; // given WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl(); @@ -62,7 +66,8 @@ public void shouldProvisionWorkspaceEditorAttributeDuringCheEditorComponentApply } @Test - public void shouldProvisionPluginCommandAttributesDuringCheEditorComponentApplying() { + public void shouldProvisionPluginCommandAttributesDuringCheEditorComponentApplying() + throws DevfileException { // given ComponentImpl superPluginComponent = new ComponentImpl(); superPluginComponent.setAlias("editor"); @@ -84,7 +89,8 @@ public void shouldProvisionPluginCommandAttributesDuringCheEditorComponentApplyi } @Test - public void shouldProvisionPluginCommandAttributeWhenIdIsURLToCustomPluginRegistry() { + public void shouldProvisionPluginCommandAttributeWhenIdIsURLToCustomPluginRegistry() + throws DevfileException { // given ComponentImpl superPluginComponent = new ComponentImpl(); superPluginComponent.setAlias("editor"); diff --git a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplierTest.java b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplierTest.java index abf2f9697a3..73fbc0a2444 100644 --- a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplierTest.java +++ b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginComponentToWorkspaceApplierTest.java @@ -21,9 +21,11 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; +import org.eclipse.che.api.devfile.server.exception.DevfileException; import org.eclipse.che.api.workspace.server.model.impl.CommandImpl; import org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl; +import org.eclipse.che.api.workspace.server.wsplugins.PluginFQNParser; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -31,14 +33,16 @@ public class PluginComponentToWorkspaceApplierTest { private PluginComponentToWorkspaceApplier pluginComponentApplier; + private PluginFQNParser fqnParser = new PluginFQNParser(); @BeforeMethod public void setUp() { - pluginComponentApplier = new PluginComponentToWorkspaceApplier(); + pluginComponentApplier = new PluginComponentToWorkspaceApplier(fqnParser); } @Test - public void shouldProvisionPluginWorkspaceAttributeDuringChePluginComponentApplying() { + public void shouldProvisionPluginWorkspaceAttributeDuringChePluginComponentApplying() + throws DevfileException { String superPluginId = "eclipse/super-plugin/0.0.1"; // given @@ -78,7 +82,8 @@ public void shouldProvisionPluginWorkspaceAttributeDuringChePluginComponentApply } @Test - public void shouldProvisionPluginCommandAttributesDuringChePluginComponentApplying() { + public void shouldProvisionPluginCommandAttributesDuringChePluginComponentApplying() + throws DevfileException { // given ComponentImpl superPluginComponent = new ComponentImpl(); superPluginComponent.setAlias("super-plugin"); @@ -100,7 +105,8 @@ public void shouldProvisionPluginCommandAttributesDuringChePluginComponentApplyi } @Test - public void shouldProvisionPluginCommandAttributeWhenIdIsURLToCustomPluginRegistry() { + public void shouldProvisionPluginCommandAttributeWhenIdIsURLToCustomPluginRegistry() + throws DevfileException { // given ComponentImpl superPluginComponent = new ComponentImpl(); superPluginComponent.setAlias("super-plugin"); diff --git a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginProvisionerTest.java b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginProvisionerTest.java index f931107da55..6a7d2793da4 100644 --- a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginProvisionerTest.java +++ b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/convert/component/plugin/PluginProvisionerTest.java @@ -19,9 +19,11 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNull; +import org.eclipse.che.api.devfile.server.exception.WorkspaceExportException; import org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl; +import org.eclipse.che.api.workspace.server.wsplugins.PluginFQNParser; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -29,14 +31,15 @@ public class PluginProvisionerTest { private PluginProvisioner pluginComponentProvisioner; + private PluginFQNParser fqnParser = new PluginFQNParser(); @BeforeMethod public void setUp() { - pluginComponentProvisioner = new PluginProvisioner(); + pluginComponentProvisioner = new PluginProvisioner(fqnParser); } @Test - public void shouldProvisionChePluginComponent() { + public void shouldProvisionChePluginComponent() throws WorkspaceExportException { // given WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl(); workspaceConfig @@ -72,7 +75,8 @@ public void shouldProvisionChePluginComponent() { } @Test - public void shouldSetAliasOnComponentIfAliasIsMissingInWorkspaceConfig() { + public void shouldSetAliasOnComponentIfAliasIsMissingInWorkspaceConfig() + throws WorkspaceExportException { // given WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl(); workspaceConfig diff --git a/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/DefaultFactoryParameterResolverTest.java b/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/DefaultFactoryParameterResolverTest.java index 68fecaebc5d..412c40db80b 100644 --- a/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/DefaultFactoryParameterResolverTest.java +++ b/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/DefaultFactoryParameterResolverTest.java @@ -40,6 +40,7 @@ import org.eclipse.che.api.factory.server.urlfactory.URLFactoryBuilder; import org.eclipse.che.api.workspace.server.WorkspaceManager; import org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl; +import org.eclipse.che.api.workspace.server.wsplugins.PluginFQNParser; import org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesRecipeParser; import org.mockito.Mock; import org.mockito.testng.MockitoTestNGListener; @@ -60,6 +61,7 @@ public class DefaultFactoryParameterResolverTest { @Mock private URLFetcher urlFetcher; @Mock private KubernetesRecipeParser kubernetesRecipeParser; + private PluginFQNParser fqnParser = new PluginFQNParser(); @Test public void shouldResolveRelativeFiles() throws Exception { @@ -92,7 +94,7 @@ public void shouldResolveRelativeFiles() throws Exception { new CommandConverter(), componentProvisioners, appliers, - new DefaultEditorProvisioner(null, new String[] {}), + new DefaultEditorProvisioner(null, new String[] {}, fqnParser), new URLFetcher()); WorkspaceManager workspaceManager = mock(WorkspaceManager.class); diff --git a/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/Constants.java b/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/Constants.java index fb3f3320b62..6ea6185a8de 100644 --- a/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/Constants.java +++ b/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/Constants.java @@ -120,8 +120,8 @@ public final class Constants { /** * Template for workspace attribute key that sets sidecar limit in a plugin. %s should be replaced * with pluginPublisher/pluginName. When plugin provides several sidecars this property sets the - * same limit for each sidecar, so is not that useful in such a case. - * Value format see {@link KubernetesSize} + * same limit for each sidecar, so is not that useful in such a case. Value format see {@link + * KubernetesSize} */ public static final String SIDECAR_MEMORY_LIMIT_ATTR_TEMPLATE = "sidecar.%s.memory_limit"; diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java index feb3cbed378..bff4be959a3 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParser.java @@ -48,11 +48,15 @@ public class PluginFQNParser { private static final String NAME_PATTERN = "[-a-z0-9]+"; private static final String VERSION_PATTERN = "[-.a-z0-9]+"; private static final String ID_PATTERN = - "(?" + PUBLISHER_PATTERN + ")/(?" + NAME_PATTERN + ")/(?" - + VERSION_PATTERN + ")"; + "(?" + + PUBLISHER_PATTERN + + ")/(?" + + NAME_PATTERN + + ")/(?" + + VERSION_PATTERN + + ")"; private static final Pattern PLUGIN_PATTERN = - Pattern.compile( - "((?" + REGISTRY_PATTERN + ")/)?(?" + ID_PATTERN + ")"); + Pattern.compile("((?" + REGISTRY_PATTERN + ")/)?(?" + ID_PATTERN + ")"); /** * Parses a workspace attributes map into a collection of {@link PluginFQN}. diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/ExtendedPluginFQN.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/ExtendedPluginFQN.java index c1e112758a3..01f436c4d95 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/ExtendedPluginFQN.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/ExtendedPluginFQN.java @@ -11,8 +11,6 @@ */ package org.eclipse.che.api.workspace.server.wsplugins.model; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; import java.net.URI; import java.util.Objects; @@ -22,7 +20,6 @@ * @author Oleksandr Garagatyi * @see PluginFQN */ -@JsonInclude(Include.NON_NULL) public class ExtendedPluginFQN extends PluginFQN { private String name; @@ -60,6 +57,10 @@ public void setVersion(String version) { this.version = version; } + public String getPublisherAndName() { + return publisher + "/" + name; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -72,9 +73,9 @@ public boolean equals(Object o) { return false; } ExtendedPluginFQN that = (ExtendedPluginFQN) o; - return Objects.equals(getName(), that.getName()) && - Objects.equals(getVersion(), that.getVersion()) && - Objects.equals(getPublisher(), that.getPublisher()); + return Objects.equals(getName(), that.getName()) + && Objects.equals(getVersion(), that.getVersion()) + && Objects.equals(getPublisher(), that.getPublisher()); } @Override @@ -84,8 +85,8 @@ public int hashCode() { @Override public String toString() { - return String - .format("{id:%s, registry:%s, publisher:%s, name:%s, version:%s}", getId(), getRegistry(), - getPublisher(), getName(), getVersion()); + return String.format( + "{id:%s, registry:%s, publisher:%s, name:%s, version:%s}", + getId(), getRegistry(), getPublisher(), getName(), getVersion()); } } diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/PluginFQN.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/PluginFQN.java index cf7fc11463e..ae4aeb6290a 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/PluginFQN.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/PluginFQN.java @@ -62,8 +62,8 @@ public boolean equals(Object obj) { return false; } PluginFQN other = (PluginFQN) obj; - return Objects.equals(getId(), other.getId()) && Objects - .equals(getRegistry(), other.getRegistry()); + return Objects.equals(getId(), other.getId()) + && Objects.equals(getRegistry(), other.getRegistry()); } @Override diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java index b0c66b2adb2..576f0332818 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java @@ -126,15 +126,15 @@ public void shouldDetectDuplicatedPluginsIfTheyArePrefixedOrSuffixedWithEmptySpa @DataProvider(name = "invalidAttributeStringProvider") public static Object[][] invalidAttributeStringProvider() { - return new Object[][]{ - {formatPlugin("http://bad registry url", "testplugin/1.0")}, - {formatPlugin("http://testregistry:8080", "bad:pluginname/1.0")}, - {formatPlugin("http://testregistry:8080", "/version")}, - {formatPlugin("http://testregistry:8080", "id/")}, - {formatPlugin("http://testregistry:8080", "name/version")}, - {formatPlugin("http://testregistry:8080", "id:version")}, - {formatPlugin("http://testregistry:8080", "publisher/name:version")}, - {formatPlugin("http://testregistry:8080", "")} + return new Object[][] { + {formatPlugin("http://bad registry url", "testplugin/1.0")}, + {formatPlugin("http://testregistry:8080", "bad:pluginname/1.0")}, + {formatPlugin("http://testregistry:8080", "/version")}, + {formatPlugin("http://testregistry:8080", "id/")}, + {formatPlugin("http://testregistry:8080", "name/version")}, + {formatPlugin("http://testregistry:8080", "id:version")}, + {formatPlugin("http://testregistry:8080", "publisher/name:version")}, + {formatPlugin("http://testregistry:8080", "")} }; } @@ -148,74 +148,90 @@ public static Object[][] validAttributesProvider() { PluginFQN pathRegistry = new PluginFQN( URI.create("http://registry/multiple/path/"), "publisher/pluginpathregistry/3.0"); - return new AttributeParsingTestCase[][]{ - { - new AttributeParsingTestCase("Test plugin with registry", - ImmutableList.of(basicEditor, withRegistry), - createAttributes(formatPlugin(basicEditor), formatPlugins(withRegistry))) - }, - { - new AttributeParsingTestCase("Test plugin with https registry", - ImmutableList.of( - new PluginFQN(URI.create("https://registry:8080"), "publisher/editor/ver")), - createAttributes(null, formatPlugin( + return new AttributeParsingTestCase[][] { + { + new AttributeParsingTestCase( + "Test plugin with registry", + ImmutableList.of(basicEditor, withRegistry), + createAttributes(formatPlugin(basicEditor), formatPlugins(withRegistry))) + }, + { + new AttributeParsingTestCase( + "Test plugin with https registry", + ImmutableList.of( + new PluginFQN(URI.create("https://registry:8080"), "publisher/editor/ver")), + createAttributes( + null, + formatPlugin( new PluginFQN(URI.create("https://registry:8080"), "publisher/editor/ver")))) - }, - { - new AttributeParsingTestCase("Test plugin with registry containing path", - ImmutableList.of(new PluginFQN(URI.create("https://registry:8080/some/path/v3"), - "publisher/editor/ver")), - createAttributes(null, formatPlugin( - new PluginFQN(URI.create("https://registry:8080/some/path/v3"), - "publisher/editor/ver")))) - }, - { - new AttributeParsingTestCase("Test plugin without registry", - ImmutableList.of(basicEditor, noRegistry), - createAttributes(formatPlugin(basicEditor), formatPlugins(noRegistry))) - }, - { - new AttributeParsingTestCase("Test plugin with multi-level path in registry", - ImmutableList.of(basicEditor, pathRegistry), - createAttributes(formatPlugin(basicEditor), formatPlugins(pathRegistry))) - }, - { - new AttributeParsingTestCase("Test attributes with no editor field", - ImmutableList.of(withRegistry), - createAttributes(null, formatPlugins(withRegistry))) - }, - { - new AttributeParsingTestCase("Test attributes with empty editor field", - ImmutableList.of(withRegistry), - createAttributes("", formatPlugins(withRegistry))) - }, - { - new AttributeParsingTestCase("Test attributes with no plugin field", - ImmutableList.of(basicEditor), - createAttributes(formatPlugin(basicEditor), (String[]) null)) - }, - { - new AttributeParsingTestCase("Test attributes with empty plugin field", - ImmutableList.of(basicEditor), - createAttributes(formatPlugin(basicEditor), "")) - }, - { - new AttributeParsingTestCase("Test attributes with no plugin or editor field", - Collections.emptyList(), - createAttributes(null, (String[]) null)) - }, - { - new AttributeParsingTestCase("Test attributes with empty plugin and editor field", - Collections.emptyList(), - createAttributes("", "")) - }, - { - new AttributeParsingTestCase("Test multiple plugins and an editor", - ImmutableList.of(basicEditor, withRegistry, noRegistry, pathRegistry), - createAttributes( - formatPlugin(basicEditor), - formatPlugins(withRegistry, noRegistry, pathRegistry))) - }, + }, + { + new AttributeParsingTestCase( + "Test plugin with registry containing path", + ImmutableList.of( + new PluginFQN( + URI.create("https://registry:8080/some/path/v3"), "publisher/editor/ver")), + createAttributes( + null, + formatPlugin( + new PluginFQN( + URI.create("https://registry:8080/some/path/v3"), "publisher/editor/ver")))) + }, + { + new AttributeParsingTestCase( + "Test plugin without registry", + ImmutableList.of(basicEditor, noRegistry), + createAttributes(formatPlugin(basicEditor), formatPlugins(noRegistry))) + }, + { + new AttributeParsingTestCase( + "Test plugin with multi-level path in registry", + ImmutableList.of(basicEditor, pathRegistry), + createAttributes(formatPlugin(basicEditor), formatPlugins(pathRegistry))) + }, + { + new AttributeParsingTestCase( + "Test attributes with no editor field", + ImmutableList.of(withRegistry), + createAttributes(null, formatPlugins(withRegistry))) + }, + { + new AttributeParsingTestCase( + "Test attributes with empty editor field", + ImmutableList.of(withRegistry), + createAttributes("", formatPlugins(withRegistry))) + }, + { + new AttributeParsingTestCase( + "Test attributes with no plugin field", + ImmutableList.of(basicEditor), + createAttributes(formatPlugin(basicEditor), (String[]) null)) + }, + { + new AttributeParsingTestCase( + "Test attributes with empty plugin field", + ImmutableList.of(basicEditor), + createAttributes(formatPlugin(basicEditor), "")) + }, + { + new AttributeParsingTestCase( + "Test attributes with no plugin or editor field", + Collections.emptyList(), + createAttributes(null, (String[]) null)) + }, + { + new AttributeParsingTestCase( + "Test attributes with empty plugin and editor field", + Collections.emptyList(), + createAttributes("", "")) + }, + { + new AttributeParsingTestCase( + "Test multiple plugins and an editor", + ImmutableList.of(basicEditor, withRegistry, noRegistry, pathRegistry), + createAttributes( + formatPlugin(basicEditor), formatPlugins(withRegistry, noRegistry, pathRegistry))) + }, }; } @@ -223,63 +239,82 @@ public static Object[][] validAttributesProvider() { // (String plugin, ExtendedPluginFQN expectedPlugin) @DataProvider(name = "validPluginStringProvider") public static Object[][] validPluginStringProvider() { - return new Object[][]{ - { - "http://registry:8080/publisher/editor/ver", - new ExtendedPluginFQN(URI.create("http://registry:8080"), "publisher/editor/ver", - "publisher", "editor", "ver") - }, - { - "https://registry:8080/publisher/editor/ver", - new ExtendedPluginFQN(URI.create("https://registry:8080"), "publisher/editor/ver", - "publisher", "editor", "ver") - }, - { - "https://che-registry.com.ua/publisher/editor/ver", - new ExtendedPluginFQN(URI.create("https://che-registry.com.ua"), "publisher/editor/ver", - "publisher", "editor", "ver") - }, - { - "https://che-registry.com.ua/plugins/publisher/editor/ver", - new ExtendedPluginFQN(URI.create("https://che-registry.com.ua/plugins"), - "publisher/editor/ver", - "publisher", "editor", "ver") - }, - { - "https://che-registry.com.ua/plugins/v3/publisher/editor/ver", - new ExtendedPluginFQN(URI.create("https://che-registry.com.ua/plugins/v3"), - "publisher/editor/ver", - "publisher", "editor", "ver") - }, - { - "https://che-registry.com.ua/some/long/path/publisher/editor/ver", - new ExtendedPluginFQN(URI.create("https://che-registry.com.ua/some/long/path"), - "publisher/editor/ver", - "publisher", "editor", "ver") - }, - { + return new Object[][] { + { + "http://registry:8080/publisher/editor/ver", + new ExtendedPluginFQN( + URI.create("http://registry:8080"), "publisher/editor/ver", - new ExtendedPluginFQN(null, "publisher/editor/ver", "publisher", "editor", "ver") - }, - { - "publisher/editor/1.12.1", - new ExtendedPluginFQN(null, "publisher/editor/1.12.1", "publisher", "editor", "1.12.1") - }, - { - "publisher/editor/v2.12.x", - new ExtendedPluginFQN(null, "publisher/editor/v2.12.x", "publisher", "editor", - "v2.12.x") - }, - { - "publisher/che-theia/next", - new ExtendedPluginFQN(null, "publisher/che-theia/next", "publisher", "che-theia", - "next") - }, - { - "publisher/che-theia/2.12-latest", - new ExtendedPluginFQN(null, "publisher/che-theia/2.12-latest", "publisher", "che-theia", - "2.12-latest") - }, + "publisher", + "editor", + "ver") + }, + { + "https://registry:8080/publisher/editor/ver", + new ExtendedPluginFQN( + URI.create("https://registry:8080"), + "publisher/editor/ver", + "publisher", + "editor", + "ver") + }, + { + "https://che-registry.com.ua/publisher/editor/ver", + new ExtendedPluginFQN( + URI.create("https://che-registry.com.ua"), + "publisher/editor/ver", + "publisher", + "editor", + "ver") + }, + { + "https://che-registry.com.ua/plugins/publisher/editor/ver", + new ExtendedPluginFQN( + URI.create("https://che-registry.com.ua/plugins"), + "publisher/editor/ver", + "publisher", + "editor", + "ver") + }, + { + "https://che-registry.com.ua/plugins/v3/publisher/editor/ver", + new ExtendedPluginFQN( + URI.create("https://che-registry.com.ua/plugins/v3"), + "publisher/editor/ver", + "publisher", + "editor", + "ver") + }, + { + "https://che-registry.com.ua/some/long/path/publisher/editor/ver", + new ExtendedPluginFQN( + URI.create("https://che-registry.com.ua/some/long/path"), + "publisher/editor/ver", + "publisher", + "editor", + "ver") + }, + { + "publisher/editor/ver", + new ExtendedPluginFQN(null, "publisher/editor/ver", "publisher", "editor", "ver") + }, + { + "publisher/editor/1.12.1", + new ExtendedPluginFQN(null, "publisher/editor/1.12.1", "publisher", "editor", "1.12.1") + }, + { + "publisher/editor/v2.12.x", + new ExtendedPluginFQN(null, "publisher/editor/v2.12.x", "publisher", "editor", "v2.12.x") + }, + { + "publisher/che-theia/next", + new ExtendedPluginFQN(null, "publisher/che-theia/next", "publisher", "che-theia", "next") + }, + { + "publisher/che-theia/2.12-latest", + new ExtendedPluginFQN( + null, "publisher/che-theia/2.12-latest", "publisher", "che-theia", "2.12-latest") + }, }; } @@ -323,8 +358,8 @@ private static class AttributeParsingTestCase { List expectedPlugins; Map attributes; - public AttributeParsingTestCase(String description, List expectedPlugins, - Map attributes) { + public AttributeParsingTestCase( + String description, List expectedPlugins, Map attributes) { this.description = description; this.expectedPlugins = expectedPlugins; this.attributes = attributes; From 389b214f339ec9de22a29133fb2c409f56f0b08f Mon Sep 17 00:00:00 2001 From: Oleksandr Garagatyi Date: Fri, 26 Apr 2019 13:22:52 +0300 Subject: [PATCH 12/19] fixup! Move fqn parsing for devfile to PLuginFQNParser --- .../wsplugins/brokerphases/BrokerEnvironmentFactory.java | 1 - .../wsplugins/brokerphases/BrokerEnvironmentFactoryTest.java | 1 - 2 files changed, 2 deletions(-) diff --git a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactory.java b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactory.java index ab68daedd72..18e1ea768d9 100644 --- a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactory.java +++ b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactory.java @@ -167,7 +167,6 @@ private Container newContainer( runtimeId.getWorkspaceId(), MoreObjects.firstNonNull(runtimeId.getEnvName(), ""), runtimeId.getOwnerId()), - "--download-metas", "--registry-address", Strings.nullToEmpty(pluginRegistryUrl)) .withImagePullPolicy(brokerPullPolicy) diff --git a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactoryTest.java b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactoryTest.java index 789f13ea860..8ae7b619f87 100644 --- a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactoryTest.java +++ b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactoryTest.java @@ -117,7 +117,6 @@ public void testInitBrokerContainer() throws Exception { String.format( "%s:%s:%s", runtimeId.getWorkspaceId(), runtimeId.getEnvName(), runtimeId.getOwnerId()), - "--download-metas", "--registry-address", DEFAULT_REGISTRY }); From 36f769b4f8de2eb2361764a72217a1d8e6fb57aa Mon Sep 17 00:00:00 2001 From: Oleksandr Garagatyi Date: Fri, 26 Apr 2019 13:38:05 +0300 Subject: [PATCH 13/19] fixup! fixup! Move fqn parsing for devfile to PLuginFQNParser --- ide/che-core-ide-stacks/src/main/resources/stacks.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ide/che-core-ide-stacks/src/main/resources/stacks.json b/ide/che-core-ide-stacks/src/main/resources/stacks.json index ea3b7421010..d7cc037e007 100644 --- a/ide/che-core-ide-stacks/src/main/resources/stacks.json +++ b/ide/che-core-ide-stacks/src/main/resources/stacks.json @@ -284,7 +284,7 @@ "projects": [], "attributes": { "plugins": "eclipse/che-machine-exec-plugin/0.0.1", - "editor": "eclipse/theia/1.0.0" + "editor": "eclipse/che-theia/1.0.0" }, "commands": [], "links": [] @@ -358,7 +358,7 @@ "projects": [], "attributes": { "plugins": "eclipse/che-machine-exec-plugin/0.0.1", - "editor": "eclipse/theia/1.0.0" + "editor": "eclipse/che-theia/1.0.0" }, "commands": [], "links": [] @@ -431,7 +431,7 @@ "projects": [], "attributes": { "plugins": "eclipse/che-machine-exec-plugin/0.0.1", - "editor": "eclipse/theia/1.0.0" + "editor": "eclipse/che-theia/1.0.0" }, "commands": [ { From 0010dedd363b7c255c8ac2f01ffabbcd1d31191e Mon Sep 17 00:00:00 2001 From: Oleksandr Garagatyi Date: Fri, 26 Apr 2019 15:16:08 +0300 Subject: [PATCH 14/19] fixup! fixup! fixup! Move fqn parsing for devfile to PLuginFQNParser --- .../api/workspace/server/wsplugins/PluginFQNParserTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java index 576f0332818..d44bc89f0df 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/wsplugins/PluginFQNParserTest.java @@ -354,9 +354,9 @@ private static Map createAttributes(String editor, String... plu */ private static class AttributeParsingTestCase { - String description; - List expectedPlugins; - Map attributes; + private String description; + private List expectedPlugins; + private Map attributes; public AttributeParsingTestCase( String description, List expectedPlugins, Map attributes) { From 830bd8105701f1ee15e1b8b7b40e9c84b5b111f3 Mon Sep 17 00:00:00 2001 From: Oleksandr Garagatyi Date: Fri, 26 Apr 2019 17:03:58 +0300 Subject: [PATCH 15/19] Fix devfile validation Signed-off-by: Oleksandr Garagatyi --- .../cypress/fixtures/workspace/che-7-preview.json | 4 ++-- dashboard/.devfile | 4 ++-- devfile.yaml | 4 ++-- wsmaster/che-core-api-devfile/README.md | 12 ++++++------ .../src/main/resources/schema/devfile.json | 2 +- .../validator/DevfileIntegrityValidatorTest.java | 2 +- .../server/validator/DevfileSchemaValidatorTest.java | 4 ++-- .../src/test/resources/devfile.yaml | 4 ++-- .../command/devfile_missing_command_actions.yaml | 2 +- .../command/devfile_missing_command_name.yaml | 2 +- .../devfile_component_with_undeclared_field.yaml | 2 +- .../component/devfile_missing_component_type.yaml | 2 +- .../schema_test/devfile/devfile_missing_name.yaml | 2 +- .../devfile/devfile_missing_spec_version.yaml | 2 +- .../devfile/devfile_with_undeclared_field.yaml | 2 +- ...evfile_editor_component_with_custom_registry.yaml | 6 +++--- ...component_with_indistinctive_field_reference.yaml | 2 +- ..._editor_component_with_multiple_colons_in_id.yaml | 2 +- .../devfile_editor_component_without_version.yaml | 2 +- .../devfile_editor_plugins.yaml | 6 +++--- ...plugins_components_with_invalid_memory_limit.yaml | 2 +- ..._editor_plugins_components_with_memory_limit.yaml | 6 +++--- ...nshift_component_with_indistinctive_field_id.yaml | 2 +- .../src/test/resources/workspace_config.json | 12 ++++++------ .../server/urlfactory/URLFactoryBuilderTest.java | 4 ++-- .../workspace/server/spi/tck/WorkspaceDaoTest.java | 6 +++--- .../eclipse/che/core/db/jpa/TestObjectsFactory.java | 2 +- 27 files changed, 51 insertions(+), 51 deletions(-) diff --git a/cypress-tests/cypress/fixtures/workspace/che-7-preview.json b/cypress-tests/cypress/fixtures/workspace/che-7-preview.json index 07326536001..d40e310118c 100644 --- a/cypress-tests/cypress/fixtures/workspace/che-7-preview.json +++ b/cypress-tests/cypress/fixtures/workspace/che-7-preview.json @@ -28,8 +28,8 @@ "commands": [], "name": "wksp-ncvb", "attributes": { - "editor": "org.eclipse.che.editor.theia:1.0.0", - "plugins": "che-machine-exec-plugin:0.0.1" + "editor": "eclipse/che-theia/1.0.0", + "plugins": "eclipse/che-machine-exec-plugin/0.0.1" }, "links": [] } diff --git a/dashboard/.devfile b/dashboard/.devfile index 4ffb8aa7b4d..86f0c3c0a53 100644 --- a/dashboard/.devfile +++ b/dashboard/.devfile @@ -8,10 +8,10 @@ projects: tools: - name: theia-editor type: cheEditor - id: org.eclipse.che.editor.theia:master + id: eclipse/che-theia/master - name: exec-plugin type: chePlugin - id: che-machine-exec-plugin:0.0.1 + id: eclipse/che-machine-exec-plugin/0.0.1 - name: dash-dev type: dockerimage image: 'eclipse/che-dashboard-dev:nightly' diff --git a/devfile.yaml b/devfile.yaml index 2840327f4e5..8995bbd010c 100644 --- a/devfile.yaml +++ b/devfile.yaml @@ -8,10 +8,10 @@ projects: components: - name: theia-editor type: cheEditor - id: org.eclipse.che.editor.theia:1.0.0 + id: eclipse/che-theia/1.0.0 - name: exec-plugin type: chePlugin - id: che-machine-exec-plugin:0.0.1 + id: eclipse/che-machine-exec-plugin/0.0.1 - name: che-dev type: kubernetes reference: .che-dev.yaml diff --git a/wsmaster/che-core-api-devfile/README.md b/wsmaster/che-core-api-devfile/README.md index 92c570899f0..36c0c13429a 100644 --- a/wsmaster/che-core-api-devfile/README.md +++ b/wsmaster/che-core-api-devfile/README.md @@ -33,10 +33,10 @@ projects: components: - alias: theia-editor type: cheEditor - id: org.eclipse.che.editor.theia:1.0.0 + id: eclipse/che-theia/1.0.0 - alias: exec-plugin type: chePlugin - id: che-machine-exec-plugin:0.0.1 + id: eclipse/che-machine-exec-plugin/0.0.1 ``` For the detailed explanation of all devfile components assignment and possible values, please see the following resources: @@ -108,7 +108,7 @@ Devfile can only contain one component with `cheEditor` type. components: - alias: theia-editor type: cheEditor - id: org.eclipse.che.editor.theia:1.0.0 + id: eclipse/che-theia/1.0.0 ``` If it is missing then a default editor will be provided along with its default plugins. @@ -125,7 +125,7 @@ It is allowed to have several `chePlugin` components. components: - alias: exec-plugin type: chePlugin - id: che-machine-exec-plugin:0.0.1 + id: eclipse/che-machine-exec-plugin/0.0.1 ``` Both types above using composite id, which is colon-separated id and version of plugin from Che Plugin registry. @@ -136,7 +136,7 @@ For each of types above it is also possible to specify container(s) memory limit components: - alias: exec-plugin type: chePlugin - id: che-machine-exec-plugin:0.0.1 + id: eclipse/che-machine-exec-plugin/0.0.1 memoryLimit: 256M ``` This limit will be apllied to each container of given plugin. @@ -300,4 +300,4 @@ attributes: - [NodeJS simple "Hello World" example](https://che.openshift.io/f?url=https://raw.githubusercontent.com/redhat-developer/devfile/master/samples/web-nodejs-sample/devfile.yaml) - [NodeJS Application with Mongo DB example](https://che.openshift.io/f?url=https://raw.githubusercontent.com/redhat-developer/devfile/master/samples/web-nodejs-with-db-sample/devfile.yaml) - [Java Spring-Petclinic example](https://che.openshift.io/f?url=https://raw.githubusercontent.com/redhat-developer/devfile/master/samples/web-java-spring-petclinic/devfile.yaml) - - [Theia frontend plugin example](https://che.openshift.io/f?url=https://raw.githubusercontent.com/redhat-developer/devfile/master/samples/theia-hello-world-frontend-plugin/devfile.yaml) \ No newline at end of file + - [Theia frontend plugin example](https://che.openshift.io/f?url=https://raw.githubusercontent.com/redhat-developer/devfile/master/samples/theia-hello-world-frontend-plugin/devfile.yaml) diff --git a/wsmaster/che-core-api-devfile/src/main/resources/schema/devfile.json b/wsmaster/che-core-api-devfile/src/main/resources/schema/devfile.json index 3219d41b0f0..86812a16dec 100644 --- a/wsmaster/che-core-api-devfile/src/main/resources/schema/devfile.json +++ b/wsmaster/che-core-api-devfile/src/main/resources/schema/devfile.json @@ -221,7 +221,7 @@ "id": { "type": "string", "description": "Describes the component id. It has the following format: [{REGISTRY_URL}/]{plugin/editor ID}:{plugin/editor VERSION}, where `{REGISTRY_URL}/` is an optional part.", - "pattern": "^((https?://)[a-zA-Z0-9_\\-\\./]+)?[a-zA-Z0-9_\\-\\.]{1,}:[a-zA-Z0-9_\\-\\.]{1,}$", + "pattern": "^((https?://)[a-zA-Z0-9_\\-./]+/)?[a-z0-9_\\-.]+/[a-z0-9_\\-.]+/[a-z0-9_\\-.]+$", "examples": [ "org.eclipse.che.maven-jdk8:1.0.0", "https://che-plugin-registry.openshift.io/org.eclipse.che.maven-jdk8:1.0.0" diff --git a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/validator/DevfileIntegrityValidatorTest.java b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/validator/DevfileIntegrityValidatorTest.java index d5003740a93..684e8d5675e 100644 --- a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/validator/DevfileIntegrityValidatorTest.java +++ b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/validator/DevfileIntegrityValidatorTest.java @@ -80,7 +80,7 @@ public void shouldThrowExceptionOnDuplicateComponentAlias() throws Exception { @Test( expectedExceptions = DevfileFormatException.class, expectedExceptionsMessageRegExp = - "Multiple editor components found: 'org.eclipse.chetheia:0.0.3', 'editor-2'") + "Multiple editor components found: 'eclipse/che-theia/0.0.3', 'editor-2'") public void shouldThrowExceptionOnMultipleEditors() throws Exception { DevfileImpl broken = new DevfileImpl(initialDevfile); ComponentImpl component = new ComponentImpl(); diff --git a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/validator/DevfileSchemaValidatorTest.java b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/validator/DevfileSchemaValidatorTest.java index 2310025aac4..53886cbb9f6 100644 --- a/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/validator/DevfileSchemaValidatorTest.java +++ b/wsmaster/che-core-api-devfile/src/test/java/org/eclipse/che/api/devfile/server/validator/DevfileSchemaValidatorTest.java @@ -145,7 +145,7 @@ public Object[][] invalidDevfiles() { { "editor_plugin_component/devfile_editor_component_without_version.yaml", "Devfile schema validation failed. Error: " - + "/devfile/components/0/id ECMA 262 regex \"^((https?://)[a-zA-Z0-9_\\-\\./]+)?[a-zA-Z0-9_\\-\\.]{1,}:[a-zA-Z0-9_\\-\\.]{1,}$\" does not match input string \"org.eclipse.theia\"" + + "/devfile/components/0/id ECMA 262 regex \"^((https?://)[a-zA-Z0-9_\\-./]+/)?[a-z0-9_\\-.]+/[a-z0-9_\\-.]+/[a-z0-9_\\-.]+$\" does not match input string \"eclipse/theia\"" }, { "editor_plugin_component/devfile_editor_plugins_components_with_invalid_memory_limit.yaml", @@ -154,7 +154,7 @@ public Object[][] invalidDevfiles() { { "editor_plugin_component/devfile_editor_component_with_multiple_colons_in_id.yaml", "Devfile schema validation failed. Error: " - + "/devfile/components/0/id ECMA 262 regex \"^((https?://)[a-zA-Z0-9_\\-\\./]+)?[a-zA-Z0-9_\\-\\.]{1,}:[a-zA-Z0-9_\\-\\.]{1,}$\" does not match input string \"org.eclipse.theia:dev:v1\"" + + "/devfile/components/0/id ECMA 262 regex \"^((https?://)[a-zA-Z0-9_\\-./]+/)?[a-z0-9_\\-.]+/[a-z0-9_\\-.]+/[a-z0-9_\\-.]+$\" does not match input string \"eclipse/theia/dev:v1\"" }, // kubernetes/openshift component model testing { diff --git a/wsmaster/che-core-api-devfile/src/test/resources/devfile.yaml b/wsmaster/che-core-api-devfile/src/test/resources/devfile.yaml index 862f7771316..56ef26b750b 100644 --- a/wsmaster/che-core-api-devfile/src/test/resources/devfile.yaml +++ b/wsmaster/che-core-api-devfile/src/test/resources/devfile.yaml @@ -21,9 +21,9 @@ projects: components: - alias: mvn-stack type: chePlugin - id: org.eclipse.chemaven-jdk8:1.0.0 + id: eclipse/chemaven-jdk8/1.0.0 - type: cheEditor - id: org.eclipse.chetheia:0.0.3 + id: eclipse/che-theia/0.0.3 - alias: jdt.ls type: chePlugin id: org.eclipse.chetheia-jdtls:0.0.3 diff --git a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/command/devfile_missing_command_actions.yaml b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/command/devfile_missing_command_actions.yaml index 2e9dc24b090..a5af2cb58b4 100644 --- a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/command/devfile_missing_command_actions.yaml +++ b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/command/devfile_missing_command_actions.yaml @@ -16,6 +16,6 @@ name: petclinic-dev-environment components: - name: theia type: cheEditor - id: org.eclipse.chetheia:0.0.3 + id: eclipse/chetheia/0.0.3 commands: - name: build diff --git a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/command/devfile_missing_command_name.yaml b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/command/devfile_missing_command_name.yaml index bbcbbcd7a60..7b4b37de8c2 100644 --- a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/command/devfile_missing_command_name.yaml +++ b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/command/devfile_missing_command_name.yaml @@ -16,7 +16,7 @@ name: petclinic-dev-environment components: - name: theia type: cheEditor - id: org.eclipse.chetheia:0.0.3 + id: eclipse/chetheia/0.0.3 commands: - actions: - type: exec diff --git a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/component/devfile_component_with_undeclared_field.yaml b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/component/devfile_component_with_undeclared_field.yaml index baf987d9d92..e0557c40bef 100644 --- a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/component/devfile_component_with_undeclared_field.yaml +++ b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/component/devfile_component_with_undeclared_field.yaml @@ -16,5 +16,5 @@ name: petclinic-dev-environment components: - type: chePlugin alias: maven - id: org.eclipse.chemaven-jdk8:1.0.0 + id: eclipse/chemaven-jdk8/1.0.0 unknown: blah-blah diff --git a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/component/devfile_missing_component_type.yaml b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/component/devfile_missing_component_type.yaml index d7396205f0b..3ab16e803ff 100644 --- a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/component/devfile_missing_component_type.yaml +++ b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/component/devfile_missing_component_type.yaml @@ -15,4 +15,4 @@ specVersion: 0.0.1 name: petclinic-dev-environment components: - alias: maven - id: org.eclipse.chemaven-jdk8:1.0.0 + id: eclipse/chemaven-jdk8/1.0.0 diff --git a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/devfile/devfile_missing_name.yaml b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/devfile/devfile_missing_name.yaml index e0419936555..8afe3ba423f 100644 --- a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/devfile/devfile_missing_name.yaml +++ b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/devfile/devfile_missing_name.yaml @@ -13,4 +13,4 @@ --- specVersion: 0.0.1 components: - - id: org.eclipse.chemaven-jdk8:1.0.0 + - id: eclipse/chemaven-jdk8/1.0.0 diff --git a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/devfile/devfile_missing_spec_version.yaml b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/devfile/devfile_missing_spec_version.yaml index b8c08f95f35..3718294feb0 100644 --- a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/devfile/devfile_missing_spec_version.yaml +++ b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/devfile/devfile_missing_spec_version.yaml @@ -13,4 +13,4 @@ --- name: petclinic-dev-environment components: - - id: org.eclipse.chemaven-jdk8:1.0.0 + - id: eclipse/chemaven-jdk8/1.0.0 diff --git a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/devfile/devfile_with_undeclared_field.yaml b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/devfile/devfile_with_undeclared_field.yaml index 43087f2b49c..b25e8d34191 100644 --- a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/devfile/devfile_with_undeclared_field.yaml +++ b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/devfile/devfile_with_undeclared_field.yaml @@ -16,4 +16,4 @@ name: petclinic-dev-environment unknown: blah-blah components: - type: chePlugin - id: org.eclipse.chemaven-jdk8:1.0.0 + id: eclipse/chemaven-jdk8/1.0.0 diff --git a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_component_with_custom_registry.yaml b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_component_with_custom_registry.yaml index 42969372635..dc62c65427e 100644 --- a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_component_with_custom_registry.yaml +++ b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_component_with_custom_registry.yaml @@ -14,8 +14,8 @@ specVersion: 0.0.1 name: terminal-sample components: - type: chePlugin - id: https://raw.githubusercontent.com/eclipse/che-plugin-registry/master/terminal-sample:0.0.1 + id: https://raw.githubusercontent.com/eclipse/che-plugin-registry/master/publisher/terminal-sample/0.0.1 - type: chePlugin - id: http://raw.githubusercontent.com/eclipse/che-plugin-registry/master/terminal-sample:0.0.1 + id: http://raw.githubusercontent.com/eclipse/che-plugin-registry/master/publisher/terminal-sample/0.0.1 - type: cheEditor - id: https://che-plugin-registry.openshift.io/org.eclipse.theia-ide:0.0.1 + id: https://che-plugin-registry.openshift.io/eclipse/theia-ide/0.0.1 diff --git a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_component_with_indistinctive_field_reference.yaml b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_component_with_indistinctive_field_reference.yaml index a2f9ef125e8..b7ae3b08d26 100644 --- a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_component_with_indistinctive_field_reference.yaml +++ b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_component_with_indistinctive_field_reference.yaml @@ -15,5 +15,5 @@ specVersion: 0.0.1 name: petclinic-dev-environment components: - type: cheEditor - id: org.eclipse.theia:0.0.3 + id: eclipse/theia/0.0.3 reference: petclinic.yaml diff --git a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_component_with_multiple_colons_in_id.yaml b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_component_with_multiple_colons_in_id.yaml index 37ae12309a2..6b90b2954c6 100644 --- a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_component_with_multiple_colons_in_id.yaml +++ b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_component_with_multiple_colons_in_id.yaml @@ -15,4 +15,4 @@ specVersion: 0.0.1 name: petclinic-dev-environment components: - type: cheEditor - id: org.eclipse.theia:dev:v1 + id: eclipse/theia/dev:v1 diff --git a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_component_without_version.yaml b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_component_without_version.yaml index 6c6e8f005fc..f8a1c9f318b 100644 --- a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_component_without_version.yaml +++ b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_component_without_version.yaml @@ -15,4 +15,4 @@ specVersion: 0.0.1 name: petclinic-dev-environment components: - type: cheEditor - id: org.eclipse.theia + id: eclipse/theia diff --git a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_plugins.yaml b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_plugins.yaml index f2a72cd69ca..297fe359e12 100644 --- a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_plugins.yaml +++ b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_plugins.yaml @@ -20,12 +20,12 @@ projects: location: 'git@github.com:spring-projects/spring-petclinic.git' components: - type: cheEditor - id: org.eclipse.chetheia:0.0.3 + id: eclipse/chetheia/0.0.3 - alias: mvn-stack type: chePlugin - id: org.eclipse.chemaven-jdk8:1.0.0 + id: eclipse/chemaven-jdk8/1.0.0 - type: chePlugin - id: org.eclipse.chetheia-jdtls:0.0.3 + id: eclipse/chetheia-jdtls/0.0.3 commands: - name: build actions: diff --git a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_plugins_components_with_invalid_memory_limit.yaml b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_plugins_components_with_invalid_memory_limit.yaml index 349cb4a3ab9..cb4ec04d1a5 100644 --- a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_plugins_components_with_invalid_memory_limit.yaml +++ b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_plugins_components_with_invalid_memory_limit.yaml @@ -14,5 +14,5 @@ specVersion: 0.0.1 name: terminal-sample components: - type: chePlugin - id: terminal-sample:0.0.1 + id: publisher/terminal-sample/0.0.1 memoryLimit: 0 diff --git a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_plugins_components_with_memory_limit.yaml b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_plugins_components_with_memory_limit.yaml index fcabf281b8e..759ce4a5d8a 100644 --- a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_plugins_components_with_memory_limit.yaml +++ b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/editor_plugin_component/devfile_editor_plugins_components_with_memory_limit.yaml @@ -14,12 +14,12 @@ specVersion: 0.0.1 name: terminal-sample components: - type: chePlugin - id: terminal-sample:0.0.1 + id: check/terminal-sample/0.0.1 memoryLimit: 256G - type: chePlugin - id: org.eclipse.chemaven-jdk8:1.0.0 + id: eclipse/chemaven-jdk8/1.0.0 memoryLimit: 108M - alias: theia type: cheEditor - id: org.eclipse.theia:0.0.3 + id: eclipse/theia/0.0.3 memoryLimit: 1048M diff --git a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/kubernetes_openshift_component/devfile_openshift_component_with_indistinctive_field_id.yaml b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/kubernetes_openshift_component/devfile_openshift_component_with_indistinctive_field_id.yaml index 70c842ee007..b0cd178a7fd 100644 --- a/wsmaster/che-core-api-devfile/src/test/resources/schema_test/kubernetes_openshift_component/devfile_openshift_component_with_indistinctive_field_id.yaml +++ b/wsmaster/che-core-api-devfile/src/test/resources/schema_test/kubernetes_openshift_component/devfile_openshift_component_with_indistinctive_field_id.yaml @@ -21,7 +21,7 @@ components: app.kubernetes.io/name: mysql app.kubernetes.io/component: database app.kubernetes.io/part-of: petclinic - id: org.eclipse.chetheia:0.0.3 + id: eclipse/chetheia/0.0.3 commands: - name: build actions: diff --git a/wsmaster/che-core-api-devfile/src/test/resources/workspace_config.json b/wsmaster/che-core-api-devfile/src/test/resources/workspace_config.json index 7327f51f620..050777736c7 100644 --- a/wsmaster/che-core-api-devfile/src/test/resources/workspace_config.json +++ b/wsmaster/che-core-api-devfile/src/test/resources/workspace_config.json @@ -18,7 +18,7 @@ "name": "build", "type": "exec", "attributes": { - "plugin": "org.eclipse.chemaven-jdk8:1.0.0", + "plugin": "eclipse/chemaven-jdk8/1.0.0", "workingDir": "/projects/spring-petclinic" } }, @@ -27,7 +27,7 @@ "name": "run", "type": "exec", "attributes": { - "plugin": "org.eclipse.chemaven-jdk8:1.0.0", + "plugin": "eclipse/chemaven-jdk8/1.0.0", "runType": "sequential", "workingDir": "/projects/spring-petclinic" } @@ -37,7 +37,7 @@ "name": "other", "type": "exec", "attributes": { - "plugin": "org.eclipse.chetheia-jdtls:0.0.3" + "plugin": "eclipse/chetheia-jdtls/0.0.3" } } ], @@ -54,8 +54,8 @@ }, "name": "petclinic-dev-environment", "attributes": { - "pluginComponentsAliases": "org.eclipse.chemaven-jdk8:1.0.0=mvn-stack,org.eclipse.chetheia:0.0.3=theia-ide,org.eclipse.chetheia-jdtls:0.0.3=jdt.ls", - "editor": "org.eclipse.chetheia:0.0.3", - "plugins": "org.eclipse.chemaven-jdk8:1.0.0,org.eclipse.chetheia-jdtls:0.0.3" + "pluginComponentsAliases": "eclipse/chemaven-jdk8/1.0.0=mvn-stack,eclipse/chetheia/0.0.3=theia-ide,eclipse/chetheia-jdtls/0.0.3=jdt.ls", + "editor": "eclipse/chetheia/0.0.3", + "plugins": "eclipse/chemaven-jdk8/1.0.0,eclipse/chetheia-jdtls/0.0.3" } } diff --git a/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/urlfactory/URLFactoryBuilderTest.java b/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/urlfactory/URLFactoryBuilderTest.java index 446ee29a6b6..8be0b500537 100644 --- a/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/urlfactory/URLFactoryBuilderTest.java +++ b/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/urlfactory/URLFactoryBuilderTest.java @@ -50,8 +50,8 @@ @Listeners(MockitoTestNGListener.class) public class URLFactoryBuilderTest { - private final String defaultEditor = "org.eclipse.che.editor.theia:1.0.0"; - private final String defaultPlugin = "che-machine-exec-plugin:0.0.1"; + private final String defaultEditor = "eclipse/che-theia/1.0.0"; + private final String defaultPlugin = "eclipse/che-machine-exec-plugin/0.0.1"; /** Grab content of URLs */ @Mock private URLFetcher urlFetcher; diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java index 34522c02d78..dcea55f00bd 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java @@ -585,7 +585,7 @@ public void shouldUpdateWorkspaceWithDevfile() throws Exception { new ComponentImpl( "kubernetes", "component3", - "che-theia:0.0.1", + "eclipse/che-theia/0.0.1", "/dev.yaml", null, asList(entrypoint3), @@ -897,7 +897,7 @@ private static DevfileImpl createDevfile(String name) { new ComponentImpl( "kubernetes", "component1", - "che-theia:0.0.1", + "eclipse/che-theia/0.0.1", "/dev.yaml", "refcontent1", asList(entrypoint1, entrypoint2), @@ -915,7 +915,7 @@ private static DevfileImpl createDevfile(String name) { new ComponentImpl( "kubernetes", "component2", - "che-theia:0.0.1", + "eclipse/che-theia/0.0.1", "/dev.yaml", "refcontent2", asList(entrypoint1, entrypoint2), diff --git a/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/TestObjectsFactory.java b/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/TestObjectsFactory.java index 464a897c823..3fc34dd5a60 100644 --- a/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/TestObjectsFactory.java +++ b/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/TestObjectsFactory.java @@ -114,7 +114,7 @@ private static ComponentImpl createDevfileComponent(String name) { return new ComponentImpl( "kubernetes", name, - "che-theia:0.0.1", + "eclipse/che-theia/0.0.1", "/dev.yaml", null, singletonList(createEntrypoint()), From 5f55eb1960c8e5d67af6d12e4a878a4b054a8654 Mon Sep 17 00:00:00 2001 From: Oleksandr Garagatyi Date: Fri, 26 Apr 2019 18:34:52 +0300 Subject: [PATCH 16/19] Do not add plugin name to container name since it exceeds max allowed chars Signed-off-by: Oleksandr Garagatyi --- .../wsplugins/K8sContainerResolver.java | 32 ++++--------------- .../K8sContainerResolverBuilder.java | 8 +---- .../KubernetesPluginsToolingApplier.java | 1 - .../wsplugins/K8sContainerResolverTest.java | 8 ++--- .../KubernetesPluginsToolingApplierTest.java | 8 ++--- 5 files changed, 15 insertions(+), 42 deletions(-) diff --git a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/K8sContainerResolver.java b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/K8sContainerResolver.java index d6a2ea9740e..8a9c7f0415f 100644 --- a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/K8sContainerResolver.java +++ b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/K8sContainerResolver.java @@ -26,6 +26,7 @@ import org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer; import org.eclipse.che.api.workspace.server.wsplugins.model.ChePluginEndpoint; import org.eclipse.che.api.workspace.server.wsplugins.model.EnvVar; +import org.eclipse.che.commons.lang.NameGenerator; import org.eclipse.che.workspace.infrastructure.kubernetes.util.Containers; import org.eclipse.che.workspace.infrastructure.kubernetes.util.KubernetesSize; @@ -39,19 +40,14 @@ public class K8sContainerResolver { static final int MAX_CONTAINER_NAME_LENGTH = 63; // K8S container name limit - private final String pluginName; private final String imagePullPolicy; private final CheContainer cheContainer; private final List containerEndpoints; public K8sContainerResolver( - String pluginName, - String imagePullPolicy, - CheContainer container, - List containerEndpoints) { + String imagePullPolicy, CheContainer container, List containerEndpoints) { this.imagePullPolicy = imagePullPolicy; this.cheContainer = container; - this.pluginName = pluginName; this.containerEndpoints = containerEndpoints; } @@ -64,7 +60,7 @@ public Container resolve() throws InfrastructureException { new ContainerBuilder() .withImage(cheContainer.getImage()) .withImagePullPolicy(imagePullPolicy) - .withName(buildContainerName(pluginName, cheContainer.getName())) + .withName(buildContainerName(cheContainer.getName())) .withEnv(toK8sEnv(cheContainer.getEnv())) .withPorts(getContainerPorts()) .build(); @@ -113,24 +109,8 @@ private List toK8sEnv(List env) .collect(Collectors.toList()); } - private String buildContainerName(String pluginName, String cheContainerName) { - if (pluginName == null) { - return cheContainerName.substring( - 0, min(cheContainerName.length(), MAX_CONTAINER_NAME_LENGTH)); - } - String preliminaryName = (pluginName + "-" + cheContainerName).toLowerCase(); - if (preliminaryName.length() <= MAX_CONTAINER_NAME_LENGTH) { - return preliminaryName; - } - final String limitedContainerName = - cheContainerName.substring(0, min(cheContainerName.length(), 49)); - return (pluginName.substring( - 0, - min( - pluginName.length(), - MAX_CONTAINER_NAME_LENGTH - limitedContainerName.length() - 1)) - + "-" - + limitedContainerName) - .toLowerCase(); + private String buildContainerName(String cheContainerName) { + String uniqueName = NameGenerator.generate(cheContainerName, 3).toLowerCase(); + return uniqueName.substring(0, min(uniqueName.length(), MAX_CONTAINER_NAME_LENGTH)); } } diff --git a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/K8sContainerResolverBuilder.java b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/K8sContainerResolverBuilder.java index b956a4b3054..7fd1379193d 100644 --- a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/K8sContainerResolverBuilder.java +++ b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/K8sContainerResolverBuilder.java @@ -21,7 +21,6 @@ /** @author Oleksandr Garagatyi */ public class K8sContainerResolverBuilder { - private String pluginName; private String imagePullPolicy; private CheContainer container; private List pluginEndpoints; @@ -36,11 +35,6 @@ public K8sContainerResolverBuilder setPluginEndpoints(List pl return this; } - public K8sContainerResolverBuilder setPluginName(String pluginName) { - this.pluginName = pluginName; - return this; - } - public K8sContainerResolverBuilder setImagePullPolicy(String imagePullPolicy) { this.imagePullPolicy = imagePullPolicy; return this; @@ -52,7 +46,7 @@ public K8sContainerResolver build() { } List containerEndpoints = getContainerEndpoints(container.getPorts(), pluginEndpoints); - return new K8sContainerResolver(pluginName, imagePullPolicy, container, containerEndpoints); + return new K8sContainerResolver(imagePullPolicy, container, containerEndpoints); } private List getContainerEndpoints( 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 a7ed7052e5a..5a335fcecd0 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 @@ -193,7 +193,6 @@ private void addSidecar( new K8sContainerResolverBuilder() .setContainer(container) .setImagePullPolicy(sidecarImagePullPolicy) - .setPluginName(chePlugin.getName()) .setPluginEndpoints(chePlugin.getEndpoints()) .build(); List containerEndpoints = k8sContainerResolver.getEndpoints(); diff --git a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/K8sContainerResolverTest.java b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/K8sContainerResolverTest.java index 3d25ecdf1fa..091a0a50b68 100644 --- a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/K8sContainerResolverTest.java +++ b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/K8sContainerResolverTest.java @@ -14,6 +14,7 @@ import static org.eclipse.che.workspace.infrastructure.kubernetes.wsplugins.K8sContainerResolver.MAX_CONTAINER_NAME_LENGTH; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEqualsNoOrder; +import static org.testng.Assert.assertTrue; import com.google.common.collect.ImmutableMap; import io.fabric8.kubernetes.api.model.Container; @@ -37,7 +38,6 @@ /** @author Alexander Garagatyi */ public class K8sContainerResolverTest { private static final String IMAGE = "testImage:tag"; - private static final String PLUGIN_NAME = "test_plugin_name"; private CheContainer cheContainer; private K8sContainerResolver resolver; @@ -47,7 +47,7 @@ public class K8sContainerResolverTest { public void setUp() { cheContainer = new CheContainer(); endpoints = new ArrayList<>(); - resolver = new K8sContainerResolver(PLUGIN_NAME, "Always", cheContainer, endpoints); + resolver = new K8sContainerResolver("Always", cheContainer, endpoints); } @Test @@ -66,13 +66,13 @@ public void shouldSetName() throws Exception { Container container = resolver.resolve(); - assertEquals(container.getName(), (PLUGIN_NAME + "-" + cheContainer.getName()).toLowerCase()); + assertTrue(container.getName().startsWith((cheContainer.getName()).toLowerCase())); } @Test public void shouldLimitNameByMaxAllowedLength() throws Exception { - cheContainer.setName("cheContainerNameWhichIsGreatlySucceedsMaxAllowedLengthByK8S"); + cheContainer.setName("cheContainerNameWhichIsGreatlySucceedsMaxAllowedLengthByKubernetes"); Container container = resolver.resolve(); diff --git a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/KubernetesPluginsToolingApplierTest.java b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/KubernetesPluginsToolingApplierTest.java index b57ffc3318c..dc24b9c3d0e 100644 --- a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/KubernetesPluginsToolingApplierTest.java +++ b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/KubernetesPluginsToolingApplierTest.java @@ -155,7 +155,7 @@ public void shouldProvisionPluginsCommandsToEnvironment() throws Exception { assertEquals(envCommand.getType(), "custom"); assertEquals( envCommand.getAttributes().get(WORKING_DIRECTORY_ATTRIBUTE), pluginCommand.getWorkingDir()); - assertEquals(envCommand.getAttributes().get(MACHINE_NAME_ATTRIBUTE), "some-name-container"); + assertEquals(envCommand.getAttributes().get(MACHINE_NAME_ATTRIBUTE), "container"); } @Test @@ -179,7 +179,7 @@ public void shouldResolveMachineNameForCommandsInEnvironment() throws Exception assertEquals(envCommand.getType(), pluginCommand.getType()); assertEquals(envCommand.getCommandLine(), pluginCommand.getCommandLine()); assertEquals(envCommand.getAttributes().get("plugin"), pluginRef); - assertEquals(envCommand.getAttributes().get(MACHINE_NAME_ATTRIBUTE), "some-name-container"); + assertEquals(envCommand.getAttributes().get(MACHINE_NAME_ATTRIBUTE), "container"); } @Test @@ -277,8 +277,8 @@ public void shouldUsePluginNameAndContainerNameForMachinesNames() throws Excepti // then Map machines = internalEnvironment.getMachines(); assertEquals(machines.size(), 2); - assertTrue(machines.containsKey("plugin1-container1")); - assertTrue(machines.containsKey("plugin2-container2")); + assertTrue(machines.containsKey("container1")); + assertTrue(machines.containsKey("container2")); } @Test( From 78a197ec81851e2f19a2f4aea3430398dcbf02cf Mon Sep 17 00:00:00 2001 From: Oleksandr Garagatyi Date: Fri, 26 Apr 2019 23:10:23 +0300 Subject: [PATCH 17/19] fixup! Do not add plugin name to container name since it exceeds max allowed chars --- .../KubernetesPluginsToolingApplierTest.java | 52 ++++++------------- .../server/wsplugins/model/ChePlugin.java | 6 +++ 2 files changed, 21 insertions(+), 37 deletions(-) diff --git a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/KubernetesPluginsToolingApplierTest.java b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/KubernetesPluginsToolingApplierTest.java index dc24b9c3d0e..51f806d5421 100644 --- a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/KubernetesPluginsToolingApplierTest.java +++ b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/KubernetesPluginsToolingApplierTest.java @@ -28,7 +28,6 @@ import static org.eclipse.che.workspace.infrastructure.kubernetes.server.secure.SecureServerExposerFactoryProvider.SECURE_EXPOSER_IMPL_PROPERTY; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.lenient; -import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import static org.testng.Assert.assertEquals; @@ -53,6 +52,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.regex.Pattern; import java.util.stream.Collectors; import org.eclipse.che.api.core.model.workspace.Warning; import org.eclipse.che.api.core.model.workspace.config.ServerConfig; @@ -84,6 +84,7 @@ /** @author Alexander Garagatyi */ @Listeners(MockitoTestNGListener.class) public class KubernetesPluginsToolingApplierTest { + private static final String TEST_IMAGE = "testImage/test/test"; private static final String TEST_IMAGE_POLICY = "IfNotPresent"; private static final String ENV_VAR = "PLUGINS_ENV_VAR"; @@ -104,7 +105,6 @@ public class KubernetesPluginsToolingApplierTest { @Mock private ProjectsRootEnvVariableProvider projectsRootEnvVariableProvider; private KubernetesEnvironment internalEnvironment; - private List containers; private KubernetesPluginsToolingApplier applier; @BeforeMethod @@ -115,7 +115,7 @@ public void setUp() { TEST_IMAGE_POLICY, MEMORY_LIMIT_MB, false, projectsRootEnvVariableProvider); Map machines = new HashMap<>(); - containers = new ArrayList<>(); + List containers = new ArrayList<>(); containers.add(userContainer); machines.put(USER_MACHINE_NAME, userMachineConfig); @@ -155,7 +155,7 @@ public void shouldProvisionPluginsCommandsToEnvironment() throws Exception { assertEquals(envCommand.getType(), "custom"); assertEquals( envCommand.getAttributes().get(WORKING_DIRECTORY_ATTRIBUTE), pluginCommand.getWorkingDir()); - assertEquals(envCommand.getAttributes().get(MACHINE_NAME_ATTRIBUTE), "container"); + validateContainerNameName(envCommand.getAttributes().get(MACHINE_NAME_ATTRIBUTE), "container"); } @Test @@ -179,7 +179,7 @@ public void shouldResolveMachineNameForCommandsInEnvironment() throws Exception assertEquals(envCommand.getType(), pluginCommand.getType()); assertEquals(envCommand.getCommandLine(), pluginCommand.getCommandLine()); assertEquals(envCommand.getAttributes().get("plugin"), pluginRef); - assertEquals(envCommand.getAttributes().get(MACHINE_NAME_ATTRIBUTE), "container"); + validateContainerNameName(envCommand.getAttributes().get(MACHINE_NAME_ATTRIBUTE), "container"); } @Test @@ -264,21 +264,19 @@ public void shouldNotFillInWarningIfChePluginHasMultiplyContainersAndThereAreNot } @Test - public void shouldUsePluginNameAndContainerNameForMachinesNames() throws Exception { + public void shouldUseContainerNameForMachinesName() throws Exception { // given internalEnvironment.getMachines().clear(); - ChePlugin chePlugin1 = createChePlugin("plugin1", createContainer("container1")); - ChePlugin chePlugin2 = createChePlugin("plugin2", createContainer("container2")); + ChePlugin chePlugin = createChePlugin("plugin1", createContainer("container1")); // when - applier.apply(runtimeIdentity, internalEnvironment, asList(chePlugin1, chePlugin2)); + applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin)); // then Map machines = internalEnvironment.getMachines(); - assertEquals(machines.size(), 2); - assertTrue(machines.containsKey("container1")); - assertTrue(machines.containsKey("container2")); + assertEquals(machines.size(), 1); + validateContainerNameName(machines.keySet().iterator().next(), "container1"); } @Test( @@ -544,31 +542,6 @@ public void shouldAddK8sServicesForChePluginEndpoints() throws Exception { verifyK8sServices(internalEnvironment, endpoint1, endpoint2); } - @Test - public void shouldPopulateWorkspaceWideEnvVarsToAllTheContainers() throws Exception { - // when - Container container = mock(Container.class); - containers.add(container); - List workspaceWideEnvVars = new ArrayList<>(); - // workspaceWideEnvVars.add(); - // workspaceWideEnvVars.add(); - - // when - applier.apply( - runtimeIdentity, - internalEnvironment, - ImmutableList.of(createChePlugin(), createChePlugin(createContainer(), createContainer()))); - - // then - assertEquals(internalEnvironment.getPodsCopy().size(), 1); - Pod pod = internalEnvironment.getPodsCopy().values().iterator().next(); - List actualContainers = pod.getSpec().getContainers(); - assertEquals(actualContainers.size(), 5); - for (Container actualContainer : actualContainers) { - assertTrue(actualContainer.getEnv().containsAll(workspaceWideEnvVars)); - } - } - @Test( expectedExceptions = InfrastructureException.class, expectedExceptionsMessageRegExp = @@ -899,4 +872,9 @@ private void addExpectedServer( serverAttributes.put("internal", Boolean.toString(!isExternal)); servers.put(portName, new ServerConfigImpl(port + "/tcp", protocol, path, serverAttributes)); } + + private void validateContainerNameName(String actual, String prefixExpected) { + Pattern pattern = Pattern.compile(prefixExpected + "\\w{3}"); + assertTrue(pattern.matcher(actual).matches()); + } } diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/ChePlugin.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/ChePlugin.java index 1006af217ed..dfb3e535df0 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/ChePlugin.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/wsplugins/model/ChePlugin.java @@ -35,6 +35,12 @@ public void setEditors(List editors) { this.editors = editors; } + @Override + public ChePlugin workspaceEnv(List workspaceEnv) { + setWorkspaceEnv(workspaceEnv); + return this; + } + @Override public boolean equals(Object o) { if (this == o) { From cdc68ed101fce0a880d0817745a673691470f66e Mon Sep 17 00:00:00 2001 From: Oleksandr Garagatyi Date: Sun, 28 Apr 2019 09:37:27 +0300 Subject: [PATCH 18/19] fixup! Merge branch 'master' into publisher2 --- deploy/openshift/deploy_che.sh | 4 ++-- deploy/openshift/templates/che-plugin-registry.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deploy/openshift/deploy_che.sh b/deploy/openshift/deploy_che.sh index adbbd0ccc7c..03094526092 100755 --- a/deploy/openshift/deploy_che.sh +++ b/deploy/openshift/deploy_che.sh @@ -204,7 +204,7 @@ 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_PLUGIN__REGISTRY__URL="https://che-plugin-registry.openshift.io" +DEFAULT_PLUGIN__REGISTRY__URL="https://che-plugin-registry.openshift.io/v2" export PLUGIN__REGISTRY__URL=${PLUGIN__REGISTRY__URL:-${DEFAULT_PLUGIN__REGISTRY__URL}} DEFAULT_CHE_METRICS_ENABLED="false" @@ -563,7 +563,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'}) - PLUGIN__REGISTRY__URL="${HTTP_PROTOCOL}://${PLUGIN_REGISTRY_ROUTE}" + PLUGIN__REGISTRY__URL="${HTTP_PROTOCOL}://${PLUGIN_REGISTRY_ROUTE}/v2" fi if [ ! -z ${CHE_INFRA_OPENSHIFT_PROJECT} ]; then diff --git a/deploy/openshift/templates/che-plugin-registry.yml b/deploy/openshift/templates/che-plugin-registry.yml index 0b3e690dd0f..e5c47a824c9 100644 --- a/deploy/openshift/templates/che-plugin-registry.yml +++ b/deploy/openshift/templates/che-plugin-registry.yml @@ -45,14 +45,14 @@ objects: - containerPort: 8080 livenessProbe: httpGet: - path: /plugins/ + path: /v2/plugins/ port: 8080 initialDelaySeconds: 30 periodSeconds: 10 timeoutSeconds: 3 readinessProbe: httpGet: - path: /plugins/ + path: /v2/plugins/ port: 8080 initialDelaySeconds: 3 periodSeconds: 10 From 374c779b8932ade5aebde59bb7150dd42685a302 Mon Sep 17 00:00:00 2001 From: Oleksandr Garagatyi Date: Sun, 28 Apr 2019 17:30:52 +0300 Subject: [PATCH 19/19] fixup! fixup! Merge branch 'master' into publisher2 --- .../src/main/resources/stacks.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ide/che-core-ide-stacks/src/main/resources/stacks.json b/ide/che-core-ide-stacks/src/main/resources/stacks.json index d7cc037e007..d8da9e70fac 100644 --- a/ide/che-core-ide-stacks/src/main/resources/stacks.json +++ b/ide/che-core-ide-stacks/src/main/resources/stacks.json @@ -801,9 +801,9 @@ "description": null, "attributes": { "plugins": "eclipse/che-machine-exec-plugin/0.0.1,redhat/java/0.38.0", - "editor": "eclipse/theia/next", + "editor": "eclipse/che-theia/next", "sidecar.redhat/java.memory_limit": "1500Mi", - "sidecar.eclipse/theia.memory_limit": "512Mi" + "sidecar.eclipse/che-theia.memory_limit": "512Mi" }, "commands": [] }, @@ -883,9 +883,9 @@ "description": null, "attributes": { "plugins": "eclipse/che-machine-exec-plugin/0.0.1,redhat/java/0.38.0", - "editor": "eclipse/theia/next", + "editor": "eclipse/che-theia/next", "sidecar.redhat/java.memory_limit": "1500Mi", - "sidecar.eclipse/theia.memory_limit": "512Mi" + "sidecar.eclipse/che-theia.memory_limit": "512Mi" }, "commands": [] }, @@ -2703,9 +2703,9 @@ "defaultEnv": "default", "description": null, "attributes": { - "sidecar.eclipse/theia.memory_limit": "512Mi", + "sidecar.eclipse/che-theia.memory_limit": "512Mi", "sidecar.ms-python/python.memory_limit": "512Mi", - "editor": "eclipse/theia/next", + "editor": "eclipse/che-theia/next", "plugins": "eclipse/che-machine-exec-plugin/0.0.1,ms-python/python/2019.2.5433" }, "links": [] @@ -2770,9 +2770,9 @@ "defaultEnv": "default", "description": null, "attributes": { - "sidecar.eclipse/theia.memory_limit": "512Mi", + "sidecar.eclipse/che-theia.memory_limit": "512Mi", "sidecar.ms-vscode/go.memory_limit": "512Mi", - "editor": "eclipse/theia/next", + "editor": "eclipse/che-theia/next", "plugins": "eclipse/che-machine-exec-plugin/0.0.1,ms-vscode/go/0.9.2" }, "links": []