Rename component "name" to "alias", make it optional and add a new

validation to require the alias when 2 components are otherwise
indistinguishable by their identifying attributes (like image name of
the dockerimage component).

Signed-off-by: Lukas Krejci <lkrejci@redhat.com>
7.20.x
Lukas Krejci 2019-04-16 11:12:00 +02:00
parent d9dc8fb28e
commit 09ccc0db26
57 changed files with 357 additions and 309 deletions

View File

@ -16,8 +16,8 @@ import java.util.Map;
public interface Component {
/** Returns the name of the component. Is mandator and must be unique per components set. */
String getName();
/** Returns the alias of the component. Is optional and must be unique per components set. */
String getAlias();
/**
* Returns type of the component, e.g. whether it is an plugin or editor or other type. It is

View File

@ -204,11 +204,11 @@
</goals>
<configuration>
<target>
<!-- install dependencies -->
<exec dir="${basedir}" executable="yarn" failonerror="true">
<arg value="install" />
<arg value="--ignore-optional" />
</exec>
<!-- install dependencies -->
<exec dir="${basedir}" executable="yarn" failonerror="true">
<arg value="install" />
<arg value="--ignore-optional" />
</exec>
</target>
</configuration>
</execution>

View File

@ -0,0 +1,52 @@
/*
* 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;
import static org.eclipse.che.api.devfile.server.Constants.DOCKERIMAGE_COMPONENT_TYPE;
import static org.eclipse.che.api.devfile.server.Constants.EDITOR_COMPONENT_TYPE;
import static org.eclipse.che.api.devfile.server.Constants.KUBERNETES_COMPONENT_TYPE;
import static org.eclipse.che.api.devfile.server.Constants.OPENSHIFT_COMPONENT_TYPE;
import static org.eclipse.che.api.devfile.server.Constants.PLUGIN_COMPONENT_TYPE;
import org.eclipse.che.api.core.model.workspace.devfile.Component;
/** Utility methods for working with components */
public class Components {
private Components() {}
/**
* Get a name that can be used to identify the component in the devfile. Either the component
* alias is used or, if not defined, the identifying attribute corresponding to the component
* type.
*
* @return
*/
public static String getIdentifiableComponentName(Component component) {
if (component.getAlias() != null) {
return component.getAlias();
}
switch (component.getType()) {
case EDITOR_COMPONENT_TYPE:
case PLUGIN_COMPONENT_TYPE:
return component.getId();
case DOCKERIMAGE_COMPONENT_TYPE:
return component.getImage();
case KUBERNETES_COMPONENT_TYPE:
case OPENSHIFT_COMPONENT_TYPE:
return component.getReference();
default:
return null;
}
}
}

View File

@ -46,10 +46,10 @@ public class Constants {
"pluginComponentsAliases";
/** Workspace config attribute which contains cheEditor component name. */
public static final String EDITOR_COMPONENT_ALIAS_WORKSPACE_ATTRIBUTE = "editorComponentName";
public static final String EDITOR_COMPONENT_ALIAS_WORKSPACE_ATTRIBUTE = "editorComponentAlias";
/** Workspace command attributes that indicates with which component it is associated. */
public static final String COMPONENT_NAME_COMMAND_ATTRIBUTE = "componentName";
public static final String COMPONENT_ALIAS_COMMAND_ATTRIBUTE = "componentAlias";
/**
* {@link Endpoint} attribute name which can identify endpoint as public or internal. Attribute

View File

@ -42,7 +42,7 @@ public class CommandConverter {
org.eclipse.che.api.workspace.server.model.impl.CommandImpl command)
throws WorkspaceExportException {
String componentName =
command.getAttributes().remove(Constants.COMPONENT_NAME_COMMAND_ATTRIBUTE);
command.getAttributes().remove(Constants.COMPONENT_ALIAS_COMMAND_ATTRIBUTE);
if (componentName == null) {
throw new WorkspaceExportException(
format(
@ -96,7 +96,7 @@ public class CommandConverter {
command
.getAttributes()
.put(Constants.COMPONENT_NAME_COMMAND_ATTRIBUTE, commandAction.getComponent());
.put(Constants.COMPONENT_ALIAS_COMMAND_ATTRIBUTE, commandAction.getComponent());
command.getAttributes().putAll(devCommand.getAttributes());

View File

@ -20,18 +20,14 @@ 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.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.che.api.core.model.workspace.devfile.Component;
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.NameGenerator;
import org.eclipse.che.commons.lang.Pair;
/**
@ -71,19 +67,13 @@ public class DefaultEditorProvisioner {
}
List<ComponentImpl> components = devfile.getComponents();
Set<String> componentsNames =
components.stream().map(Component::getName).collect(Collectors.toCollection(HashSet::new));
Optional<ComponentImpl> editorOpt =
components.stream().filter(t -> EDITOR_COMPONENT_TYPE.equals(t.getType())).findFirst();
boolean isDefaultEditorUsed;
if (!editorOpt.isPresent()) {
components.add(
new ComponentImpl(
EDITOR_COMPONENT_TYPE,
findAvailableName(componentsNames, defaultEditorRef),
defaultEditorRef));
components.add(new ComponentImpl(EDITOR_COMPONENT_TYPE, defaultEditorRef));
isDefaultEditorUsed = true;
} else {
Component editor = editorOpt.get();
@ -91,12 +81,11 @@ public class DefaultEditorProvisioner {
}
if (isDefaultEditorUsed) {
provisionDefaultPlugins(components, componentsNames);
provisionDefaultPlugins(components);
}
}
private void provisionDefaultPlugins(
List<ComponentImpl> components, Set<String> componentsNames) {
private void provisionDefaultPlugins(List<ComponentImpl> components) {
Map<String, String> missingPluginsIdToRef = new HashMap<>(defaultPluginsIdToRef);
components
@ -106,27 +95,7 @@ public class DefaultEditorProvisioner {
missingPluginsIdToRef
.values()
.forEach(
pluginRef ->
components.add(
new ComponentImpl(
PLUGIN_COMPONENT_TYPE,
findAvailableName(componentsNames, pluginRef),
pluginRef)));
}
/**
* Returns available name for component with the specified id.
*
* <p>Id without version is used as base name and generated part is added if it is already busy.
*/
private String findAvailableName(Set<String> busyNames, String componentRef) {
String id = getId(componentRef);
String name = id;
while (!busyNames.add(name)) {
name = NameGenerator.generate(id, 5);
}
return name;
.forEach(pluginRef -> components.add(new ComponentImpl(PLUGIN_COMPONENT_TYPE, pluginRef)));
}
private String getId(String reference) {

View File

@ -14,6 +14,7 @@ package org.eclipse.che.api.devfile.server.convert;
import static com.google.common.base.Preconditions.checkArgument;
import static java.lang.String.format;
import static java.util.stream.Collectors.toCollection;
import static org.eclipse.che.api.devfile.server.Components.getIdentifiableComponentName;
import static org.eclipse.che.api.devfile.server.Constants.CURRENT_SPEC_VERSION;
import com.google.common.base.Strings;
@ -142,7 +143,7 @@ public class DevfileConverter {
throw new DevfileException(
String.format(
"Devfile contains component `%s` with type `%s` that can not be converted to workspace",
component.getName(), component.getType()));
getIdentifiableComponentName(component), component.getType()));
}
applier.apply(config, component, contentProvider);
}

View File

@ -96,7 +96,7 @@ public class DockerimageComponentProvisioner implements ComponentProvisioner {
RecipeImpl recipe = environment.getRecipe();
ComponentImpl dockerimageComponent = new ComponentImpl();
dockerimageComponent.setName(environmentName);
dockerimageComponent.setAlias(environmentName);
dockerimageComponent.setImage(recipe.getContent());
dockerimageComponent.setType(DOCKERIMAGE_COMPONENT_TYPE);

View File

@ -109,7 +109,9 @@ public class DockerimageComponentToWorkspaceApplier implements ComponentToWorksp
DOCKERIMAGE_COMPONENT_TYPE.equals(dockerimageComponent.getType()),
format("Plugin must have `%s` type", DOCKERIMAGE_COMPONENT_TYPE));
String machineName = dockerimageComponent.getName();
String componentAlias = dockerimageComponent.getAlias();
String machineName =
componentAlias == null ? toObjectName(dockerimageComponent.getImage()) : componentAlias;
MachineConfigImpl machineConfig = new MachineConfigImpl();
dockerimageComponent
@ -162,9 +164,9 @@ public class DockerimageComponentToWorkspaceApplier implements ComponentToWorksp
.stream()
.filter(
c ->
dockerimageComponent
.getName()
.equals(c.getAttributes().get(Constants.COMPONENT_NAME_COMMAND_ATTRIBUTE)))
c.getAttributes()
.get(Constants.COMPONENT_ALIAS_COMMAND_ATTRIBUTE)
.equals(componentAlias))
.forEach(c -> c.getAttributes().put(MACHINE_NAME_ATTRIBUTE, machineName));
}
@ -246,4 +248,8 @@ public class DockerimageComponentToWorkspaceApplier implements ComponentToWorksp
.endSpec()
.build();
}
public static String toObjectName(String imageName) {
return imageName.replaceAll("/", "-").replaceAll(":", "-");
}
}

View File

@ -44,13 +44,13 @@ public class EditorComponentProvisioner implements ComponentProvisioner {
return;
}
ComponentImpl editorComponent =
new ComponentImpl(
EDITOR_COMPONENT_TYPE,
workspaceConfig
.getAttributes()
.getOrDefault(EDITOR_COMPONENT_ALIAS_WORKSPACE_ATTRIBUTE, editorAttribute),
editorAttribute);
ComponentImpl editorComponent = new ComponentImpl(EDITOR_COMPONENT_TYPE, editorAttribute);
editorComponent.setAlias(
workspaceConfig
.getAttributes()
.getOrDefault(EDITOR_COMPONENT_ALIAS_WORKSPACE_ATTRIBUTE, editorAttribute));
devfile.getComponents().add(editorComponent);
}
}

View File

@ -14,7 +14,7 @@ package org.eclipse.che.api.devfile.server.convert.component.editor;
import static com.google.common.base.Preconditions.checkArgument;
import static java.lang.String.format;
import static org.eclipse.che.api.core.model.workspace.config.Command.PLUGIN_ATTRIBUTE;
import static org.eclipse.che.api.devfile.server.Constants.COMPONENT_NAME_COMMAND_ATTRIBUTE;
import static org.eclipse.che.api.devfile.server.Constants.COMPONENT_ALIAS_COMMAND_ATTRIBUTE;
import static org.eclipse.che.api.devfile.server.Constants.EDITOR_COMPONENT_ALIAS_WORKSPACE_ATTRIBUTE;
import static org.eclipse.che.api.devfile.server.Constants.EDITOR_COMPONENT_TYPE;
import static org.eclipse.che.api.workspace.shared.Constants.WORKSPACE_TOOLING_EDITOR_ATTRIBUTE;
@ -52,14 +52,16 @@ public class EditorComponentToWorkspaceApplier implements ComponentToWorkspaceAp
EDITOR_COMPONENT_TYPE.equals(editorComponent.getType()),
format("Plugin must have `%s` type", EDITOR_COMPONENT_TYPE));
String editorComponentName = editorComponent.getName();
String editorComponentAlias = editorComponent.getAlias();
String editorId = editorComponent.getId();
workspaceConfig.getAttributes().put(WORKSPACE_TOOLING_EDITOR_ATTRIBUTE, editorId);
workspaceConfig
.getAttributes()
.put(EDITOR_COMPONENT_ALIAS_WORKSPACE_ATTRIBUTE, editorComponentName);
if (editorComponentAlias != null) {
workspaceConfig
.getAttributes()
.put(EDITOR_COMPONENT_ALIAS_WORKSPACE_ATTRIBUTE, editorComponentAlias);
}
String editorIdVersion = resolveIdAndVersion(editorComponent.getId());
workspaceConfig
@ -67,7 +69,9 @@ public class EditorComponentToWorkspaceApplier implements ComponentToWorkspaceAp
.stream()
.filter(
c ->
c.getAttributes().get(COMPONENT_NAME_COMMAND_ATTRIBUTE).equals(editorComponentName))
c.getAttributes()
.get(COMPONENT_ALIAS_COMMAND_ATTRIBUTE)
.equals(editorComponentAlias))
.forEach(c -> c.getAttributes().put(PLUGIN_ATTRIBUTE, editorIdVersion));
}

View File

@ -17,6 +17,7 @@ import static java.lang.String.format;
import static java.util.Collections.emptyMap;
import static java.util.stream.Collectors.toList;
import static org.eclipse.che.api.core.model.workspace.config.Command.MACHINE_NAME_ATTRIBUTE;
import static org.eclipse.che.api.devfile.server.Components.getIdentifiableComponentName;
import static org.eclipse.che.api.devfile.server.Constants.KUBERNETES_COMPONENT_TYPE;
import static org.eclipse.che.api.devfile.server.Constants.OPENSHIFT_COMPONENT_TYPE;
@ -122,20 +123,24 @@ public class KubernetesComponentToWorkspaceApplier implements ComponentToWorkspa
format(
"Fetching content of file `%s` specified in `reference` field of component `%s` is not supported. "
+ "Please provide its content in `referenceContent` field. Cause: %s",
recipeComponent.getReference(), recipeComponent.getName(), e.getMessage()),
recipeComponent.getReference(),
getIdentifiableComponentName(recipeComponent),
e.getMessage()),
e);
} catch (IOException e) {
throw new DevfileException(
format(
"Error during recipe content retrieval for component '%s' with type '%s': %s",
recipeComponent.getName(), recipeComponent.getType(), e.getMessage()),
getIdentifiableComponentName(recipeComponent),
recipeComponent.getType(),
e.getMessage()),
e);
}
if (isNullOrEmpty(recipeFileContent)) {
throw new DevfileException(
format(
"The reference file '%s' defined in component '%s' is empty.",
recipeComponent.getReference(), recipeComponent.getName()));
recipeComponent.getReference(), getIdentifiableComponentName(recipeComponent)));
}
return recipeFileContent;
}
@ -154,9 +159,9 @@ public class KubernetesComponentToWorkspaceApplier implements ComponentToWorkspa
.stream()
.filter(
c ->
component
.getName()
.equals(c.getAttributes().get(Constants.COMPONENT_NAME_COMMAND_ATTRIBUTE)))
c.getAttributes()
.get(Constants.COMPONENT_ALIAS_COMMAND_ATTRIBUTE)
.equals(component.getAlias()))
.collect(toList());
if (componentCommands.isEmpty()) {
return;
@ -201,7 +206,9 @@ public class KubernetesComponentToWorkspaceApplier implements ComponentToWorkspa
throw new DevfileRecipeFormatException(
format(
"Error occurred during parsing list from file %s for component '%s': %s",
k8sComponent.getReference(), k8sComponent.getName(), e.getMessage()),
k8sComponent.getReference(),
getIdentifiableComponentName(k8sComponent),
e.getMessage()),
e);
}
}

View File

@ -15,7 +15,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Strings.isNullOrEmpty;
import static java.lang.String.format;
import static org.eclipse.che.api.core.model.workspace.config.Command.PLUGIN_ATTRIBUTE;
import static org.eclipse.che.api.devfile.server.Constants.COMPONENT_NAME_COMMAND_ATTRIBUTE;
import static org.eclipse.che.api.devfile.server.Constants.COMPONENT_ALIAS_COMMAND_ATTRIBUTE;
import static org.eclipse.che.api.devfile.server.Constants.PLUGINS_COMPONENTS_ALIASES_WORKSPACE_ATTRIBUTE;
import static org.eclipse.che.api.devfile.server.Constants.PLUGIN_COMPONENT_TYPE;
import static org.eclipse.che.api.workspace.shared.Constants.WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE;
@ -65,22 +65,24 @@ public class PluginComponentToWorkspaceApplier implements ComponentToWorkspaceAp
String pluginsAliases =
workspaceConfig.getAttributes().get(PLUGINS_COMPONENTS_ALIASES_WORKSPACE_ATTRIBUTE);
workspaceConfig
.getAttributes()
.put(
PLUGINS_COMPONENTS_ALIASES_WORKSPACE_ATTRIBUTE,
append(pluginsAliases, pluginComponent.getId() + "=" + pluginComponent.getName()));
if (pluginComponent.getAlias() != null) {
workspaceConfig
.getAttributes()
.put(
PLUGINS_COMPONENTS_ALIASES_WORKSPACE_ATTRIBUTE,
append(pluginsAliases, pluginComponent.getId() + "=" + pluginComponent.getAlias()));
}
String pluginIdVersion = resolveIdAndVersion(pluginComponent.getId());
for (CommandImpl command : workspaceConfig.getCommands()) {
String commandComponent = command.getAttributes().get(COMPONENT_NAME_COMMAND_ATTRIBUTE);
String commandComponent = command.getAttributes().get(COMPONENT_ALIAS_COMMAND_ATTRIBUTE);
if (commandComponent == null) {
// command does not have component information
continue;
}
if (!commandComponent.equals(pluginComponent.getName())) {
if (!commandComponent.equals(pluginComponent.getAlias())) {
continue;
}

View File

@ -54,19 +54,17 @@ public class PluginProvisioner implements ComponentProvisioner {
return;
}
Map<String, String> pluginIdToComponentName = extractPluginIdToComponentName(workspaceConfig);
Map<String, String> pluginIdToComponentAlias = extractPluginIdToComponentAlias(workspaceConfig);
for (String pluginId : pluginsAttribute.split(",")) {
ComponentImpl pluginComponent =
new ComponentImpl(
PLUGIN_COMPONENT_TYPE,
pluginIdToComponentName.getOrDefault(pluginId, pluginId),
pluginId);
ComponentImpl pluginComponent = new ComponentImpl(PLUGIN_COMPONENT_TYPE, pluginId);
pluginComponent.setAlias(pluginIdToComponentAlias.get(pluginId));
devfile.getComponents().add(pluginComponent);
}
}
private Map<String, String> extractPluginIdToComponentName(WorkspaceConfigImpl wsConfig) {
private Map<String, String> extractPluginIdToComponentAlias(WorkspaceConfigImpl wsConfig) {
String aliasesAttribute =
wsConfig.getAttributes().get(PLUGINS_COMPONENTS_ALIASES_WORKSPACE_ATTRIBUTE);
if (isNullOrEmpty(aliasesAttribute)) {

View File

@ -12,6 +12,7 @@
package org.eclipse.che.api.devfile.server.validator;
import static java.lang.String.format;
import static org.eclipse.che.api.devfile.server.Components.getIdentifiableComponentName;
import static org.eclipse.che.api.devfile.server.Constants.DOCKERIMAGE_COMPONENT_TYPE;
import static org.eclipse.che.api.devfile.server.Constants.EDITOR_COMPONENT_TYPE;
import static org.eclipse.che.api.devfile.server.Constants.KUBERNETES_COMPONENT_TYPE;
@ -23,6 +24,7 @@ import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.client.utils.Serialization;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@ -85,8 +87,8 @@ public class DevfileIntegrityValidator {
*/
public void validateDevfile(Devfile devfile) throws DevfileFormatException {
validateProjects(devfile);
Set<String> componentNames = validateComponents(devfile);
validateCommands(devfile, componentNames);
Set<String> knownAliases = validateComponents(devfile);
validateCommands(devfile, knownAliases);
}
/**
@ -111,20 +113,36 @@ public class DevfileIntegrityValidator {
}
private Set<String> validateComponents(Devfile devfile) throws DevfileFormatException {
Set<String> existingNames = new HashSet<>();
Set<String> definedAliases = new HashSet<>();
Component editorComponent = null;
Map<String, Set<String>> idsPerComponentType = new HashMap<>();
for (Component component : devfile.getComponents()) {
if (!existingNames.add(component.getName())) {
if (component.getAlias() != null && !definedAliases.add(component.getAlias())) {
throw new DevfileFormatException(
format("Duplicate component name found:'%s'", component.getName()));
format("Duplicate component alias found:'%s'", component.getAlias()));
}
if (!idsPerComponentType
.computeIfAbsent(component.getType(), __ -> new HashSet<>())
.add(getIdentifiableComponentName(component))) {
throw new DevfileFormatException(
format(
"There are multiple components '%s' of type '%s' that cannot be uniquely"
+ " identified. Please add aliases that would distinguish the components.",
getIdentifiableComponentName(component), component.getType()));
}
switch (component.getType()) {
case EDITOR_COMPONENT_TYPE:
if (editorComponent != null) {
throw new DevfileFormatException(
format(
"Multiple editor components found: '%s', '%s'",
editorComponent.getName(), component.getName()));
getIdentifiableComponentName(editorComponent),
getIdentifiableComponentName(component)));
}
editorComponent = component;
break;
@ -140,13 +158,13 @@ public class DevfileIntegrityValidator {
throw new DevfileFormatException(
format(
"Unsupported component '%s' type provided:'%s'",
component.getName(), component.getType()));
getIdentifiableComponentName(component), component.getType()));
}
}
return existingNames;
return definedAliases;
}
private void validateCommands(Devfile devfile, Set<String> componentNames)
private void validateCommands(Devfile devfile, Set<String> knownAliases)
throws DevfileFormatException {
Set<String> existingNames = new HashSet<>();
for (Command command : devfile.getCommands()) {
@ -169,10 +187,10 @@ public class DevfileIntegrityValidator {
}
Action action = command.getActions().get(0);
if (!componentNames.contains(action.getComponent())) {
if (!knownAliases.contains(action.getComponent())) {
throw new DevfileFormatException(
format(
"Command '%s' has action that refers to non-existing components '%s'",
"Command '%s' has action that refers to a component with unknown alias '%s'",
command.getName(), action.getComponent()));
}
}
@ -229,7 +247,7 @@ public class DevfileIntegrityValidator {
throw new DevfileException(
format(
"The selector of the component %s filters out all objects from the list.",
component.getName()));
component.getAlias()));
}
return content;
@ -252,7 +270,7 @@ public class DevfileIntegrityValidator {
throw new DevfileFormatException(
format(
"Component %s contains an entry point that doesn't match any container:\n%s",
component.getName(), toYAML(ep)));
component.getAlias(), toYAML(ep)));
}
}
}

View File

@ -128,7 +128,6 @@
"items": {
"type": "object",
"required": [
"name",
"type"
],
"dependencies": {
@ -146,7 +145,7 @@
"chePlugin"
]
},
"name": {},
"alias": {},
"id": {}
},
"required": [
@ -162,7 +161,7 @@
"openshift"
]
},
"name": {},
"alias": {},
"reference": {},
"referenceContent": {},
"selector": {},
@ -180,7 +179,7 @@
"dockerimage"
]
},
"name": {},
"alias": {},
"image": {},
"memoryLimit": {},
"mountSources": {},
@ -198,8 +197,8 @@
}
],
"properties": {
"name": {
"description": "Describes the name of the component. Should be unique per components set.",
"alias": {
"description": "The name using which other places of this devfile (like commands) can refer to this component.",
"type": "string",
"examples": [
"mvn-stack"

View File

@ -12,7 +12,7 @@
package org.eclipse.che.api.devfile.server.convert;
import static org.eclipse.che.api.core.model.workspace.config.Command.WORKING_DIRECTORY_ATTRIBUTE;
import static org.eclipse.che.api.devfile.server.Constants.COMPONENT_NAME_COMMAND_ATTRIBUTE;
import static org.eclipse.che.api.devfile.server.Constants.COMPONENT_ALIAS_COMMAND_ATTRIBUTE;
import static org.eclipse.che.api.devfile.server.Constants.EXEC_ACTION_TYPE;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
@ -42,7 +42,7 @@ public class CommandConverterTest {
org.eclipse.che.api.workspace.server.model.impl.CommandImpl workspaceCommand =
new org.eclipse.che.api.workspace.server.model.impl.CommandImpl(
"build", "mvn clean install", "custom");
workspaceCommand.getAttributes().put(COMPONENT_NAME_COMMAND_ATTRIBUTE, "dockerimageComponent");
workspaceCommand.getAttributes().put(COMPONENT_ALIAS_COMMAND_ATTRIBUTE, "dockerimageComponent");
workspaceCommand.getAttributes().put(WORKING_DIRECTORY_ATTRIBUTE, "/tmp");
workspaceCommand.getAttributes().put("anotherAttribute", "value");
@ -100,7 +100,7 @@ public class CommandConverterTest {
assertEquals(workspaceCommand.getAttributes().get("attr"), "value");
assertEquals(workspaceCommand.getAttributes().get(WORKING_DIRECTORY_ATTRIBUTE), "/tmp");
assertEquals(
workspaceCommand.getAttributes().get(COMPONENT_NAME_COMMAND_ATTRIBUTE),
workspaceCommand.getAttributes().get(COMPONENT_ALIAS_COMMAND_ATTRIBUTE),
"dockerimageComponent");
assertEquals(workspaceCommand.getCommandLine(), "mvn clean install");
}

View File

@ -15,7 +15,6 @@ 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 static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
@ -73,17 +72,11 @@ public class DefaultEditorProvisionerTest {
// then
List<ComponentImpl> 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, DEFAULT_EDITOR_ID, DEFAULT_EDITOR_REF)));
components.contains(new ComponentImpl(PLUGIN_COMPONENT_TYPE, DEFAULT_COMMAND_PLUGIN_REF)));
assertTrue(
components.contains(
new ComponentImpl(
PLUGIN_COMPONENT_TYPE, DEFAULT_COMMAND_PLUGIN_ID, DEFAULT_COMMAND_PLUGIN_REF)));
assertTrue(
components.contains(
new ComponentImpl(
PLUGIN_COMPONENT_TYPE, DEFAULT_TERMINAL_PLUGIN_ID, DEFAULT_TERMINAL_PLUGIN_REF)));
components.contains(new ComponentImpl(PLUGIN_COMPONENT_TYPE, DEFAULT_TERMINAL_PLUGIN_REF)));
}
@Test
@ -95,7 +88,7 @@ public class DefaultEditorProvisionerTest {
DevfileImpl devfile = new DevfileImpl();
ComponentImpl defaultEditorWithDifferentVersion =
new ComponentImpl(EDITOR_COMPONENT_TYPE, "my-editor", DEFAULT_EDITOR_ID + ":latest");
new ComponentImpl(EDITOR_COMPONENT_TYPE, DEFAULT_EDITOR_ID + ":latest");
devfile.getComponents().add(defaultEditorWithDifferentVersion);
// when
@ -108,9 +101,7 @@ public class DefaultEditorProvisionerTest {
assertTrue(components.contains(defaultEditorWithDifferentVersion));
assertTrue(
components.contains(
new ComponentImpl(
PLUGIN_COMPONENT_TYPE, DEFAULT_TERMINAL_PLUGIN_ID, DEFAULT_TERMINAL_PLUGIN_REF)));
components.contains(new ComponentImpl(PLUGIN_COMPONENT_TYPE, DEFAULT_TERMINAL_PLUGIN_REF)));
}
@Test
@ -124,9 +115,7 @@ public class DefaultEditorProvisionerTest {
DevfileImpl devfile = new DevfileImpl();
ComponentImpl defaultEditorWithDifferentVersion =
new ComponentImpl(
EDITOR_COMPONENT_TYPE,
"my-editor",
"https://my-custom-registry/" + DEFAULT_EDITOR_ID + ":latest");
EDITOR_COMPONENT_TYPE, "https://my-custom-registry/" + DEFAULT_EDITOR_ID + ":latest");
devfile.getComponents().add(defaultEditorWithDifferentVersion);
// when
@ -139,9 +128,7 @@ public class DefaultEditorProvisionerTest {
assertTrue(components.contains(defaultEditorWithDifferentVersion));
assertTrue(
components.contains(
new ComponentImpl(
PLUGIN_COMPONENT_TYPE, DEFAULT_TERMINAL_PLUGIN_ID, DEFAULT_TERMINAL_PLUGIN_REF)));
components.contains(new ComponentImpl(PLUGIN_COMPONENT_TYPE, DEFAULT_TERMINAL_PLUGIN_REF)));
}
@Test
@ -153,8 +140,7 @@ public class DefaultEditorProvisionerTest {
DevfileImpl devfile = new DevfileImpl();
ComponentImpl editorWithNameSimilarToDefault =
new ComponentImpl(
EDITOR_COMPONENT_TYPE, "my-editor", DEFAULT_EDITOR_ID + "-dev:dev-version");
new ComponentImpl(EDITOR_COMPONENT_TYPE, DEFAULT_EDITOR_ID + "-dev:dev-version");
devfile.getComponents().add(editorWithNameSimilarToDefault);
// when
@ -195,8 +181,7 @@ public class DefaultEditorProvisionerTest {
DevfileImpl devfile = new DevfileImpl();
ComponentImpl pluginWithNameSimilarToDefault =
new ComponentImpl(
PLUGIN_COMPONENT_TYPE, "my-plugin", DEFAULT_TERMINAL_PLUGIN_ID + "-dummy:latest");
new ComponentImpl(PLUGIN_COMPONENT_TYPE, DEFAULT_TERMINAL_PLUGIN_ID + "-dummy:latest");
devfile.getComponents().add(pluginWithNameSimilarToDefault);
// when
@ -205,13 +190,9 @@ public class DefaultEditorProvisionerTest {
// then
List<ComponentImpl> 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, DEFAULT_EDITOR_ID, DEFAULT_EDITOR_REF)));
assertTrue(
components.contains(
new ComponentImpl(
PLUGIN_COMPONENT_TYPE, DEFAULT_TERMINAL_PLUGIN_ID, DEFAULT_TERMINAL_PLUGIN_REF)));
components.contains(new ComponentImpl(PLUGIN_COMPONENT_TYPE, DEFAULT_TERMINAL_PLUGIN_REF)));
assertTrue(components.contains(pluginWithNameSimilarToDefault));
}
@ -221,7 +202,7 @@ public class DefaultEditorProvisionerTest {
defaultEditorProvisioner = new DefaultEditorProvisioner(DEFAULT_EDITOR_REF, new String[] {});
DevfileImpl devfile = new DevfileImpl();
ComponentImpl nonDefaultEditor =
new ComponentImpl(EDITOR_COMPONENT_TYPE, "editor", "any:v" + DEFAULT_EDITOR_VERSION);
new ComponentImpl(EDITOR_COMPONENT_TYPE, "any:v" + DEFAULT_EDITOR_VERSION);
devfile.getComponents().add(nonDefaultEditor);
// when
@ -239,8 +220,7 @@ public class DefaultEditorProvisionerTest {
defaultEditorProvisioner = new DefaultEditorProvisioner(DEFAULT_EDITOR_REF, new String[] {});
DevfileImpl devfile = new DevfileImpl();
ComponentImpl myTheiaEditor =
new ComponentImpl(
EDITOR_COMPONENT_TYPE, "my-custom-theia", DEFAULT_EDITOR_REF + ":my-custom");
new ComponentImpl(EDITOR_COMPONENT_TYPE, DEFAULT_EDITOR_REF + ":my-custom");
devfile.getComponents().add(myTheiaEditor);
// when
@ -253,15 +233,14 @@ public class DefaultEditorProvisionerTest {
}
@Test
public void shouldNonProvisionDefaultPluginIfDevfileAlreadyContainsSuchButWithDifferentVersion() {
public void shouldNotProvisionDefaultPluginIfDevfileAlreadyContainsSuchButWithDifferentVersion() {
// given
defaultEditorProvisioner =
new DefaultEditorProvisioner(
DEFAULT_EDITOR_REF, new String[] {DEFAULT_TERMINAL_PLUGIN_REF});
DevfileImpl devfile = new DevfileImpl();
ComponentImpl myTerminal =
new ComponentImpl(
PLUGIN_COMPONENT_TYPE, "my-terminal", DEFAULT_TERMINAL_PLUGIN_ID + ":my-custom");
new ComponentImpl(PLUGIN_COMPONENT_TYPE, DEFAULT_TERMINAL_PLUGIN_ID + ":my-custom");
devfile.getComponents().add(myTerminal);
// when
@ -270,9 +249,7 @@ public class DefaultEditorProvisionerTest {
// then
List<ComponentImpl> components = devfile.getComponents();
assertEquals(components.size(), 2);
assertTrue(
components.contains(
new ComponentImpl(EDITOR_COMPONENT_TYPE, DEFAULT_EDITOR_ID, DEFAULT_EDITOR_REF)));
assertTrue(components.contains(new ComponentImpl(EDITOR_COMPONENT_TYPE, DEFAULT_EDITOR_REF)));
assertTrue(components.contains(myTerminal));
}
@ -282,8 +259,7 @@ public class DefaultEditorProvisionerTest {
defaultEditorProvisioner =
new DefaultEditorProvisioner(DEFAULT_EDITOR_REF, new String[] {"my-plugin:v2.0"});
DevfileImpl devfile = new DevfileImpl();
ComponentImpl myPlugin =
new ComponentImpl(PLUGIN_COMPONENT_TYPE, "my-plugin", "my-custom-plugin:v0.0.3");
ComponentImpl myPlugin = new ComponentImpl(PLUGIN_COMPONENT_TYPE, "my-custom-plugin:v0.0.3");
devfile.getComponents().add(myPlugin);
// when
@ -292,14 +268,11 @@ public class DefaultEditorProvisionerTest {
// then
List<ComponentImpl> components = devfile.getComponents();
assertEquals(components.size(), 3);
assertTrue(
components.contains(
new ComponentImpl(EDITOR_COMPONENT_TYPE, DEFAULT_EDITOR_ID, DEFAULT_EDITOR_REF)));
assertTrue(components.contains(new ComponentImpl(EDITOR_COMPONENT_TYPE, DEFAULT_EDITOR_REF)));
assertTrue(components.contains(myPlugin));
ComponentImpl defaultPlugin = findByRef(components, "my-plugin:v2.0");
assertNotNull(defaultPlugin);
assertNotEquals("my-plugin", defaultPlugin.getName());
assertTrue(defaultPlugin.getName().startsWith("my-plugin"));
assertNull(defaultPlugin.getAlias());
}
private ComponentImpl findById(List<ComponentImpl> components, String id) {

View File

@ -112,7 +112,7 @@ public class DockerimageComponentProvisionerTest {
// then
assertEquals(devfile.getComponents().size(), 1);
ComponentImpl dockerimageComponent = devfile.getComponents().get(0);
assertEquals(dockerimageComponent.getName(), "dockerEnv");
assertEquals(dockerimageComponent.getAlias(), "dockerEnv");
assertEquals(dockerimageComponent.getImage(), "eclipse/ubuntu_jdk8:latest");
}
@ -147,7 +147,7 @@ public class DockerimageComponentProvisionerTest {
// then
assertEquals(devfile.getComponents().size(), 1);
ComponentImpl dockerimageComponent = devfile.getComponents().get(0);
assertEquals(dockerimageComponent.getName(), "dockerEnv");
assertEquals(dockerimageComponent.getAlias(), "dockerEnv");
assertEquals(dockerimageComponent.getId(), "eclipse/ubuntu_jdk8:latest");
}

View File

@ -87,7 +87,7 @@ public class DockerimageComponentToWorkspaceApplierTest {
// given
ComponentImpl dockerimageComponent = new ComponentImpl();
dockerimageComponent.setType(DOCKERIMAGE_COMPONENT_TYPE);
dockerimageComponent.setName("jdk");
dockerimageComponent.setAlias("jdk");
dockerimageComponent.setImage("eclipse/ubuntu_jdk8:latest");
dockerimageComponent.setMemoryLimit("1G");
@ -124,11 +124,54 @@ public class DockerimageComponentToWorkspaceApplierTest {
assertEquals(container.getImage(), "eclipse/ubuntu_jdk8:latest");
}
@Test
public void shouldProvisionK8sEnvironmentWithMachineConfigFromSpecifiedDockerimageWithoutAlias()
throws Exception {
ComponentImpl dockerimageComponent = new ComponentImpl();
dockerimageComponent.setType(DOCKERIMAGE_COMPONENT_TYPE);
dockerimageComponent.setImage("eclipse/ubuntu_jdk8:latest");
dockerimageComponent.setMemoryLimit("1G");
// when
dockerimageComponentApplier.apply(workspaceConfig, dockerimageComponent, null);
// then
verify(k8sEnvProvisioner)
.provision(
eq(workspaceConfig),
eq(KubernetesEnvironment.TYPE),
objectsCaptor.capture(),
machinesCaptor.capture());
MachineConfigImpl machineConfig = machinesCaptor.getValue().get("eclipse-ubuntu_jdk8-latest");
assertNotNull(machineConfig);
List<HasMetadata> objects = objectsCaptor.getValue();
assertEquals(objects.size(), 1);
assertTrue(objects.get(0) instanceof Deployment);
Deployment deployment = (Deployment) objects.get(0);
PodTemplateSpec podTemplate = deployment.getSpec().getTemplate();
ObjectMeta podMeta = podTemplate.getMetadata();
assertEquals(podMeta.getName(), "eclipse-ubuntu_jdk8-latest");
Map<String, String> deploymentSelector = deployment.getSpec().getSelector().getMatchLabels();
assertFalse(deploymentSelector.isEmpty());
assertTrue(podMeta.getLabels().entrySet().containsAll(deploymentSelector.entrySet()));
Map<String, String> annotations = podMeta.getAnnotations();
assertEquals(
annotations.get(String.format(MACHINE_NAME_ANNOTATION_FMT, "eclipse-ubuntu_jdk8-latest")),
"eclipse-ubuntu_jdk8-latest");
Container container = podTemplate.getSpec().getContainers().get(0);
assertEquals(container.getName(), "eclipse-ubuntu_jdk8-latest");
assertEquals(container.getImage(), "eclipse/ubuntu_jdk8:latest");
}
@Test
public void shouldProvisionSpecifiedEnvVars() throws Exception {
// given
ComponentImpl dockerimageComponent = new ComponentImpl();
dockerimageComponent.setName("jdk");
dockerimageComponent.setAlias("jdk");
dockerimageComponent.setType(DOCKERIMAGE_COMPONENT_TYPE);
dockerimageComponent.setImage("eclipse/ubuntu_jdk8:latest");
dockerimageComponent.setMemoryLimit("1G");
@ -162,7 +205,7 @@ public class DockerimageComponentToWorkspaceApplierTest {
public void shouldProvisionContainerWithMemoryLimitSpecified() throws Exception {
// given
ComponentImpl dockerimageComponent = new ComponentImpl();
dockerimageComponent.setName("jdk");
dockerimageComponent.setAlias("jdk");
dockerimageComponent.setType(DOCKERIMAGE_COMPONENT_TYPE);
dockerimageComponent.setImage("eclipse/ubuntu_jdk8:latest");
dockerimageComponent.setMemoryLimit("1G");
@ -205,7 +248,7 @@ public class DockerimageComponentToWorkspaceApplierTest {
"secure",
"false"));
ComponentImpl dockerimageComponent = new ComponentImpl();
dockerimageComponent.setName("jdk");
dockerimageComponent.setAlias("jdk");
dockerimageComponent.setType(DOCKERIMAGE_COMPONENT_TYPE);
dockerimageComponent.setImage("eclipse/ubuntu_jdk8:latest");
dockerimageComponent.setMemoryLimit("1G");
@ -253,7 +296,7 @@ public class DockerimageComponentToWorkspaceApplierTest {
DISCOVERABLE_ENDPOINT_ATTRIBUTE,
"true"));
ComponentImpl dockerimageComponent = new ComponentImpl();
dockerimageComponent.setName("jdk");
dockerimageComponent.setAlias("jdk");
dockerimageComponent.setType(DOCKERIMAGE_COMPONENT_TYPE);
dockerimageComponent.setImage("eclipse/ubuntu_jdk8:latest");
dockerimageComponent.setMemoryLimit("1G");
@ -294,7 +337,7 @@ public class DockerimageComponentToWorkspaceApplierTest {
// given
EndpointImpl endpoint = new EndpointImpl("jdk-ls", 4923, emptyMap());
ComponentImpl dockerimageComponent = new ComponentImpl();
dockerimageComponent.setName("jdk");
dockerimageComponent.setAlias("jdk");
dockerimageComponent.setType(DOCKERIMAGE_COMPONENT_TYPE);
dockerimageComponent.setImage("eclipse/ubuntu_jdk8:latest");
dockerimageComponent.setMemoryLimit("1G");
@ -321,7 +364,7 @@ public class DockerimageComponentToWorkspaceApplierTest {
public void shouldProvisionMachineConfigWithConfiguredVolumes() throws Exception {
// given
ComponentImpl dockerimageComponent = new ComponentImpl();
dockerimageComponent.setName("jdk");
dockerimageComponent.setAlias("jdk");
dockerimageComponent.setType(DOCKERIMAGE_COMPONENT_TYPE);
dockerimageComponent.setImage("eclipse/ubuntu_jdk8:latest");
dockerimageComponent.setMemoryLimit("1G");
@ -349,7 +392,7 @@ public class DockerimageComponentToWorkspaceApplierTest {
public void shouldProvisionMachineConfigWithMountSources() throws Exception {
// given
ComponentImpl dockerimageComponent = new ComponentImpl();
dockerimageComponent.setName("jdk");
dockerimageComponent.setAlias("jdk");
dockerimageComponent.setType(DOCKERIMAGE_COMPONENT_TYPE);
dockerimageComponent.setImage("eclipse/ubuntu_jdk8:latest");
dockerimageComponent.setMemoryLimit("1G");
@ -377,7 +420,7 @@ public class DockerimageComponentToWorkspaceApplierTest {
public void shouldProvisionMachineConfigWithoutSourcesByDefault() throws Exception {
// given
ComponentImpl dockerimageComponent = new ComponentImpl();
dockerimageComponent.setName("jdk");
dockerimageComponent.setAlias("jdk");
dockerimageComponent.setType(DOCKERIMAGE_COMPONENT_TYPE);
dockerimageComponent.setImage("eclipse/ubuntu_jdk8:latest");
dockerimageComponent.setMemoryLimit("1G");
@ -404,7 +447,7 @@ public class DockerimageComponentToWorkspaceApplierTest {
List<String> args = Arrays.asList("-r", "f");
ComponentImpl dockerimageComponent = new ComponentImpl();
dockerimageComponent.setName("jdk");
dockerimageComponent.setAlias("jdk");
dockerimageComponent.setType(DOCKERIMAGE_COMPONENT_TYPE);
dockerimageComponent.setImage("eclipse/ubuntu_jdk8:latest");
dockerimageComponent.setMemoryLimit("1G");

View File

@ -48,7 +48,7 @@ public class EditorComponentProvisionerTest {
// then
assertEquals(devfile.getComponents().size(), 1);
ComponentImpl editorComponent = devfile.getComponents().get(0);
assertEquals(editorComponent.getName(), "editor");
assertEquals(editorComponent.getAlias(), "editor");
assertEquals(editorComponent.getType(), EDITOR_COMPONENT_TYPE);
assertEquals(editorComponent.getId(), "org.eclipse.che.super-editor:0.0.1");
}
@ -69,6 +69,6 @@ public class EditorComponentProvisionerTest {
// then
assertEquals(devfile.getComponents().size(), 1);
ComponentImpl editorComponent = devfile.getComponents().get(0);
assertEquals(editorComponent.getName(), "org.eclipse.che.super-editor:0.0.1");
assertEquals(editorComponent.getAlias(), "org.eclipse.che.super-editor:0.0.1");
}
}

View File

@ -12,7 +12,7 @@
package org.eclipse.che.api.devfile.server.convert.component.editor;
import static org.eclipse.che.api.core.model.workspace.config.Command.PLUGIN_ATTRIBUTE;
import static org.eclipse.che.api.devfile.server.Constants.COMPONENT_NAME_COMMAND_ATTRIBUTE;
import static org.eclipse.che.api.devfile.server.Constants.COMPONENT_ALIAS_COMMAND_ATTRIBUTE;
import static org.eclipse.che.api.devfile.server.Constants.EDITOR_COMPONENT_ALIAS_WORKSPACE_ATTRIBUTE;
import static org.eclipse.che.api.devfile.server.Constants.EDITOR_COMPONENT_TYPE;
import static org.eclipse.che.api.workspace.shared.Constants.WORKSPACE_TOOLING_EDITOR_ATTRIBUTE;
@ -41,7 +41,7 @@ public class EditorComponentToWorkspaceApplierTest {
WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl();
ComponentImpl editorComponent = new ComponentImpl();
editorComponent.setType(EDITOR_COMPONENT_TYPE);
editorComponent.setName("editor");
editorComponent.setAlias("editor");
editorComponent.setId("org.eclipse.che.super-editor:0.0.1");
// when
@ -60,13 +60,13 @@ public class EditorComponentToWorkspaceApplierTest {
throws Exception {
// given
ComponentImpl superPluginComponent = new ComponentImpl();
superPluginComponent.setName("editor");
superPluginComponent.setAlias("editor");
superPluginComponent.setId("org.eclipse.che.super-editor:0.0.1");
superPluginComponent.setType(EDITOR_COMPONENT_TYPE);
WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl();
CommandImpl command = new CommandImpl();
command.getAttributes().put(COMPONENT_NAME_COMMAND_ATTRIBUTE, "editor");
command.getAttributes().put(COMPONENT_ALIAS_COMMAND_ATTRIBUTE, "editor");
workspaceConfig.getCommands().add(command);
// when
@ -83,14 +83,14 @@ public class EditorComponentToWorkspaceApplierTest {
throws Exception {
// given
ComponentImpl superPluginComponent = new ComponentImpl();
superPluginComponent.setName("editor");
superPluginComponent.setAlias("editor");
superPluginComponent.setId(
"https://custom-plugin.registry/plugins/org.eclipse.che.super-editor:0.0.1");
superPluginComponent.setType(EDITOR_COMPONENT_TYPE);
WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl();
CommandImpl command = new CommandImpl();
command.getAttributes().put(COMPONENT_NAME_COMMAND_ATTRIBUTE, "editor");
command.getAttributes().put(COMPONENT_ALIAS_COMMAND_ATTRIBUTE, "editor");
workspaceConfig.getCommands().add(command);
// when

View File

@ -17,7 +17,7 @@ import static java.util.Collections.emptyMap;
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
import static org.eclipse.che.api.core.model.workspace.config.Command.MACHINE_NAME_ATTRIBUTE;
import static org.eclipse.che.api.devfile.server.Constants.COMPONENT_NAME_COMMAND_ATTRIBUTE;
import static org.eclipse.che.api.devfile.server.Constants.COMPONENT_ALIAS_COMMAND_ATTRIBUTE;
import static org.eclipse.che.api.devfile.server.Constants.KUBERNETES_COMPONENT_TYPE;
import static org.eclipse.che.api.devfile.server.Constants.OPENSHIFT_COMPONENT_TYPE;
import static org.mockito.ArgumentMatchers.any;
@ -90,7 +90,7 @@ public class KubernetesComponentToWorkspaceApplierTest {
ComponentImpl component = new ComponentImpl();
component.setType(KUBERNETES_COMPONENT_TYPE);
component.setReference(REFERENCE_FILENAME);
component.setName(COMPONENT_NAME);
component.setAlias(COMPONENT_NAME);
// when
applier.apply(
@ -115,7 +115,7 @@ public class KubernetesComponentToWorkspaceApplierTest {
ComponentImpl component = new ComponentImpl();
component.setType(KUBERNETES_COMPONENT_TYPE);
component.setReference(REFERENCE_FILENAME);
component.setName(COMPONENT_NAME);
component.setAlias(COMPONENT_NAME);
// when
applier.apply(workspaceConfig, component, s -> "some_non_yaml_content");
@ -130,7 +130,7 @@ public class KubernetesComponentToWorkspaceApplierTest {
ComponentImpl component = new ComponentImpl();
component.setType(KUBERNETES_COMPONENT_TYPE);
component.setReference(REFERENCE_FILENAME);
component.setName(COMPONENT_NAME);
component.setAlias(COMPONENT_NAME);
// when
applier.apply(
@ -150,7 +150,7 @@ public class KubernetesComponentToWorkspaceApplierTest {
ComponentImpl component = new ComponentImpl();
component.setType(KUBERNETES_COMPONENT_TYPE);
component.setReference(REFERENCE_FILENAME);
component.setName(COMPONENT_NAME);
component.setAlias(COMPONENT_NAME);
// when
applier.apply(workspaceConfig, component, s -> yamlRecipeContent);
@ -172,7 +172,7 @@ public class KubernetesComponentToWorkspaceApplierTest {
component.setType(KUBERNETES_COMPONENT_TYPE);
component.setReference(REFERENCE_FILENAME);
component.setReferenceContent(yamlRecipeContent);
component.setName(COMPONENT_NAME);
component.setAlias(COMPONENT_NAME);
applier.apply(workspaceConfig, component, new URLFileContentProvider(null, null));
@ -193,7 +193,7 @@ public class KubernetesComponentToWorkspaceApplierTest {
ComponentImpl component = new ComponentImpl();
component.setType(OPENSHIFT_COMPONENT_TYPE);
component.setReference(REFERENCE_FILENAME);
component.setName(COMPONENT_NAME);
component.setAlias(COMPONENT_NAME);
// when
applier.apply(workspaceConfig, component, s -> yamlRecipeContent);
@ -216,7 +216,7 @@ public class KubernetesComponentToWorkspaceApplierTest {
ComponentImpl component = new ComponentImpl();
component.setType(OPENSHIFT_COMPONENT_TYPE);
component.setReference(REFERENCE_FILENAME);
component.setName(COMPONENT_NAME);
component.setAlias(COMPONENT_NAME);
component.setSelector(selector);
doReturn(toK8SList(yamlRecipeContent).getItems()).when(k8sRecipeParser).parse(anyString());
@ -248,10 +248,10 @@ public class KubernetesComponentToWorkspaceApplierTest {
ComponentImpl component = new ComponentImpl();
component.setType(OPENSHIFT_COMPONENT_TYPE);
component.setReference(REFERENCE_FILENAME);
component.setName(COMPONENT_NAME);
component.setAlias(COMPONENT_NAME);
component.setSelector(selector);
CommandImpl command = new CommandImpl();
command.getAttributes().put(COMPONENT_NAME_COMMAND_ATTRIBUTE, COMPONENT_NAME);
command.getAttributes().put(COMPONENT_ALIAS_COMMAND_ATTRIBUTE, COMPONENT_NAME);
workspaceConfig.getCommands().add(command);
// when
@ -273,10 +273,10 @@ public class KubernetesComponentToWorkspaceApplierTest {
ComponentImpl component = new ComponentImpl();
component.setType(OPENSHIFT_COMPONENT_TYPE);
component.setReference(REFERENCE_FILENAME);
component.setName(COMPONENT_NAME);
component.setAlias(COMPONENT_NAME);
CommandImpl command = new CommandImpl();
command.getAttributes().put(COMPONENT_NAME_COMMAND_ATTRIBUTE, COMPONENT_NAME);
command.getAttributes().put(COMPONENT_ALIAS_COMMAND_ATTRIBUTE, COMPONENT_NAME);
workspaceConfig.getCommands().add(command);
// when
@ -297,7 +297,7 @@ public class KubernetesComponentToWorkspaceApplierTest {
ComponentImpl component = new ComponentImpl();
component.setType(KUBERNETES_COMPONENT_TYPE);
component.setReference(REFERENCE_FILENAME);
component.setName(COMPONENT_NAME);
component.setAlias(COMPONENT_NAME);
EntrypointImpl entrypoint = new EntrypointImpl();
entrypoint.setParentName("petclinic");

View File

@ -12,7 +12,7 @@
package org.eclipse.che.api.devfile.server.convert.component.plugin;
import static org.eclipse.che.api.core.model.workspace.config.Command.PLUGIN_ATTRIBUTE;
import static org.eclipse.che.api.devfile.server.Constants.COMPONENT_NAME_COMMAND_ATTRIBUTE;
import static org.eclipse.che.api.devfile.server.Constants.COMPONENT_ALIAS_COMMAND_ATTRIBUTE;
import static org.eclipse.che.api.devfile.server.Constants.PLUGINS_COMPONENTS_ALIASES_WORKSPACE_ATTRIBUTE;
import static org.eclipse.che.api.devfile.server.Constants.PLUGIN_COMPONENT_TYPE;
import static org.eclipse.che.api.workspace.shared.Constants.WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE;
@ -40,12 +40,12 @@ public class PluginComponentToWorkspaceApplierTest {
throws Exception {
// given
ComponentImpl superPluginComponent = new ComponentImpl();
superPluginComponent.setName("super-plugin");
superPluginComponent.setAlias("super-plugin");
superPluginComponent.setId("org.eclipse.che.super-plugin:0.0.1");
superPluginComponent.setType(PLUGIN_COMPONENT_TYPE);
ComponentImpl customPluginComponent = new ComponentImpl();
customPluginComponent.setName("custom");
customPluginComponent.setAlias("custom");
customPluginComponent.setId("custom-plugin:v1");
customPluginComponent.setType(PLUGIN_COMPONENT_TYPE);
@ -73,13 +73,13 @@ public class PluginComponentToWorkspaceApplierTest {
throws Exception {
// given
ComponentImpl superPluginComponent = new ComponentImpl();
superPluginComponent.setName("super-plugin");
superPluginComponent.setAlias("super-plugin");
superPluginComponent.setId("org.eclipse.che.super-plugin:0.0.1");
superPluginComponent.setType(PLUGIN_COMPONENT_TYPE);
WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl();
CommandImpl command = new CommandImpl();
command.getAttributes().put(COMPONENT_NAME_COMMAND_ATTRIBUTE, "super-plugin");
command.getAttributes().put(COMPONENT_ALIAS_COMMAND_ATTRIBUTE, "super-plugin");
workspaceConfig.getCommands().add(command);
// when
@ -96,14 +96,14 @@ public class PluginComponentToWorkspaceApplierTest {
throws Exception {
// given
ComponentImpl superPluginComponent = new ComponentImpl();
superPluginComponent.setName("super-plugin");
superPluginComponent.setAlias("super-plugin");
superPluginComponent.setId(
"https://custom-plugin.registry/plugins/org.eclipse.che.super-plugin:0.0.1");
superPluginComponent.setType(PLUGIN_COMPONENT_TYPE);
WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl();
CommandImpl command = new CommandImpl();
command.getAttributes().put(COMPONENT_NAME_COMMAND_ATTRIBUTE, "super-plugin");
command.getAttributes().put(COMPONENT_ALIAS_COMMAND_ATTRIBUTE, "super-plugin");
workspaceConfig.getCommands().add(command);
// when

View File

@ -15,6 +15,7 @@ import static org.eclipse.che.api.devfile.server.Constants.PLUGINS_COMPONENTS_AL
import static org.eclipse.che.api.devfile.server.Constants.PLUGIN_COMPONENT_TYPE;
import static org.eclipse.che.api.workspace.shared.Constants.WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull;
import org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl;
import org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl;
@ -54,19 +55,18 @@ public class PluginProvisionerTest {
// then
assertEquals(devfile.getComponents().size(), 2);
ComponentImpl superPluginComponent = devfile.getComponents().get(0);
assertEquals(superPluginComponent.getName(), "super-plugin");
assertEquals(superPluginComponent.getAlias(), "super-plugin");
assertEquals(superPluginComponent.getId(), "org.eclipse.che.super-plugin:0.0.1");
assertEquals(superPluginComponent.getType(), PLUGIN_COMPONENT_TYPE);
ComponentImpl customPluginComponent = devfile.getComponents().get(1);
assertEquals(customPluginComponent.getName(), "custom");
assertEquals(customPluginComponent.getAlias(), "custom");
assertEquals(customPluginComponent.getId(), "custom-plugin:v1");
assertEquals(customPluginComponent.getType(), PLUGIN_COMPONENT_TYPE);
}
@Test
public void shouldUsePluginIdAsComponentNameIfAliasIsMissingDuringProvisioningChePluginComponent()
throws Exception {
public void shouldSetAliasOnComponentIfAliasIsMissingInWorkspaceConfig() throws Exception {
// given
WorkspaceConfigImpl workspaceConfig = new WorkspaceConfigImpl();
workspaceConfig
@ -80,7 +80,7 @@ public class PluginProvisionerTest {
// then
assertEquals(devfile.getComponents().size(), 1);
ComponentImpl superPluginComponent = devfile.getComponents().get(0);
assertEquals(superPluginComponent.getName(), "org.eclipse.che.super-plugin:0.0.1");
assertNull(superPluginComponent.getAlias());
assertEquals(superPluginComponent.getId(), "org.eclipse.che.super-plugin:0.0.1");
assertEquals(superPluginComponent.getType(), PLUGIN_COMPONENT_TYPE);
}

View File

@ -11,6 +11,7 @@
*/
package org.eclipse.che.api.devfile.server.validator;
import static org.eclipse.che.api.devfile.server.Constants.DOCKERIMAGE_COMPONENT_TYPE;
import static org.eclipse.che.api.devfile.server.Constants.EDITOR_COMPONENT_TYPE;
import static org.eclipse.che.api.devfile.server.Constants.KUBERNETES_COMPONENT_TYPE;
import static org.eclipse.che.api.devfile.server.Constants.OPENSHIFT_COMPONENT_TYPE;
@ -66,11 +67,11 @@ public class DevfileIntegrityValidatorTest {
@Test(
expectedExceptions = DevfileFormatException.class,
expectedExceptionsMessageRegExp = "Duplicate component name found:'mvn-stack'")
expectedExceptionsMessageRegExp = "Duplicate component alias found:'mvn-stack'")
public void shouldThrowExceptionOnDuplicateComponentName() throws Exception {
DevfileImpl broken = new DevfileImpl(initialDevfile);
ComponentImpl component = new ComponentImpl();
component.setName(initialDevfile.getComponents().get(0).getName());
component.setAlias(initialDevfile.getComponents().get(0).getAlias());
broken.getComponents().add(component);
// when
integrityValidator.validateDevfile(broken);
@ -78,11 +79,12 @@ public class DevfileIntegrityValidatorTest {
@Test(
expectedExceptions = DevfileFormatException.class,
expectedExceptionsMessageRegExp = "Multiple editor components found: 'theia-ide', 'editor-2'")
expectedExceptionsMessageRegExp =
"Multiple editor components found: 'org.eclipse.chetheia:0.0.3', 'editor-2'")
public void shouldThrowExceptionOnMultipleEditors() throws Exception {
DevfileImpl broken = new DevfileImpl(initialDevfile);
ComponentImpl component = new ComponentImpl();
component.setName("editor-2");
component.setAlias("editor-2");
component.setType(EDITOR_COMPONENT_TYPE);
broken.getComponents().add(component);
// when
@ -128,7 +130,7 @@ public class DevfileIntegrityValidatorTest {
@Test(
expectedExceptions = DevfileFormatException.class,
expectedExceptionsMessageRegExp =
"Command 'build' has action that refers to non-existing components 'no_such_component'")
"Command 'build' has action that refers to a component with unknown alias 'no_such_component'")
public void shouldThrowExceptionOnUnexistingCommandActionComponent() throws Exception {
DevfileImpl broken = new DevfileImpl(initialDevfile);
broken.getCommands().get(0).getActions().clear();
@ -239,4 +241,31 @@ public class DevfileIntegrityValidatorTest {
// then
// no exception is thrown
}
@Test(
expectedExceptions = DevfileFormatException.class,
expectedExceptionsMessageRegExp =
"There are multiple components 'dockerimage:latest' of type 'dockerimage' that cannot be"
+ " uniquely identified. Please add aliases that would distinguish the components.")
public void shouldRequireAliasWhenDockerImageComponentsHaveSameImage() throws Exception {
// given
DevfileImpl devfile = new DevfileImpl(initialDevfile);
ComponentImpl docker1 = new ComponentImpl();
docker1.setType(DOCKERIMAGE_COMPONENT_TYPE);
docker1.setImage("dockerimage:latest");
ComponentImpl docker2 = new ComponentImpl();
docker2.setType(DOCKERIMAGE_COMPONENT_TYPE);
docker2.setImage("dockerimage:latest");
devfile.getComponents().add(docker1);
devfile.getComponents().add(docker2);
// when
integrityValidator.validateDevfile(devfile);
// then
// exception is thrown
}
}

View File

@ -15,7 +15,6 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
import java.io.IOException;
import java.util.regex.Pattern;
import org.eclipse.che.api.devfile.server.exception.DevfileFormatException;
import org.eclipse.che.api.devfile.server.schema.DevfileSchemaProvider;
import org.testng.annotations.BeforeClass;
@ -27,16 +26,13 @@ public class DevfileSchemaValidatorTest {
private DevfileSchemaValidator schemaValidator;
private static final Pattern TEST =
Pattern.compile("https?://[a-zA-Z0-9_\\-\\./]+[a-zA-Z0-9_\\-\\.]{1,}:[a-zA-Z0-9_\\-\\.]{1,}");
@BeforeClass
public void setUp() {
schemaValidator = new DevfileSchemaValidator(new DevfileSchemaProvider());
}
@Test(dataProvider = "validDevfiles")
public void shouldNotThrowExceptionOnValidationValidDevfile(String resourceFilePath)
public void shouldNotThrowExceptionOnValidationOfValidDevfile(String resourceFilePath)
throws Exception {
schemaValidator.validateBySchema(getResource(resourceFilePath));
}
@ -63,7 +59,7 @@ public class DevfileSchemaValidatorTest {
}
@Test(dataProvider = "invalidDevfiles")
public void shouldThrowExceptionOnValidationNonValidDevfile(
public void shouldThrowExceptionOnValidationOfNonValidDevfile(
String resourceFilePath, String expectedMessageRegexp) throws Exception {
try {
schemaValidator.validateBySchema(getResource(resourceFilePath));
@ -94,10 +90,6 @@ public class DevfileSchemaValidatorTest {
"Devfile schema validation failed. Error: /devfile object instance has properties which are not allowed by the schema: [\"unknown\"]"
},
// component model testing
{
"component/devfile_missing_component_name.yaml",
"Devfile schema validation failed. Error: /devfile/components/0 object has missing required properties ([\"name\"])"
},
{
"component/devfile_missing_component_type.yaml",
"Devfile schema validation failed. Error: /devfile/components/0 object has missing required properties ([\"type\"])"

View File

@ -19,17 +19,15 @@ projects:
type: git
location: 'git@github.com:spring-projects/spring-petclinic.git'
components:
- name: mvn-stack
- alias: mvn-stack
type: chePlugin
id: org.eclipse.chemaven-jdk8:1.0.0
- name: theia-ide
type: cheEditor
- type: cheEditor
id: org.eclipse.chetheia:0.0.3
- name: jdt.ls
- alias: jdt.ls
type: chePlugin
id: org.eclipse.chetheia-jdtls:0.0.3
- name: os-recipe
type: openshift
- type: openshift
reference: petclinic.yaml
selector:
app.kubernetes.io/name: mysql

View File

@ -15,6 +15,6 @@ specVersion: 0.0.1
name: petclinic-dev-environment
components:
- type: chePlugin
name: maven
alias: maven
id: org.eclipse.chemaven-jdk8:1.0.0
unknown: blah-blah

View File

@ -1,18 +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
#
---
specVersion: 0.0.1
name: petclinic-dev-environment
components:
- type: chePlugin
id: org.eclipse.chemaven-jdk8:1.0.0

View File

@ -14,5 +14,5 @@
specVersion: 0.0.1
name: petclinic-dev-environment
components:
- name: maven
- alias: maven
id: org.eclipse.chemaven-jdk8:1.0.0

View File

@ -13,7 +13,6 @@
---
specVersion: 0.0.1
name: petclinic-dev-environment
projects:
projects:
- name: petclinic
source:

View File

@ -13,5 +13,4 @@
---
specVersion: 0.0.1
components:
- name: maven
id: org.eclipse.chemaven-jdk8:1.0.0
- id: org.eclipse.chemaven-jdk8:1.0.0

View File

@ -13,5 +13,4 @@
---
name: petclinic-dev-environment
components:
- name: maven
id: org.eclipse.chemaven-jdk8:1.0.0
- id: org.eclipse.chemaven-jdk8:1.0.0

View File

@ -15,6 +15,5 @@ specVersion: 0.0.1
name: petclinic-dev-environment
unknown: blah-blah
components:
- name: maven
type: chePlugin
- type: chePlugin
id: org.eclipse.chemaven-jdk8:1.0.0

View File

@ -14,8 +14,7 @@
specVersion: 0.0.1
name: petclinic-dev-environment
components:
- name: maven
type: dockerimage
- type: dockerimage
image: eclipe/maven-jdk8:latest
volumes:
- name: maven-repo

View File

@ -14,8 +14,7 @@
specVersion: 0.0.1
name: petclinic-dev-environment
components:
- name: maven
type: dockerimage
- type: dockerimage
image: eclipe/maven-jdk8:latest
volumes:
- name: maven-repo

View File

@ -14,6 +14,5 @@
specVersion: 0.0.1
name: petclinic-dev-environment
components:
- name: maven
type: dockerimage
- type: dockerimage
memoryLimit: 1G

View File

@ -14,6 +14,5 @@
specVersion: 0.0.1
name: petclinic-dev-environment
components:
- name: maven
type: dockerimage
- type: dockerimage
image: org.eclipse.cheubuntu-jdk:latest

View File

@ -14,8 +14,7 @@
specVersion: 0.0.1
name: petclinic-dev-environment
components:
- name: maven
type: dockerimage
- type: dockerimage
image: eclipe/maven-jdk8:latest
volumes:
- name: maven-repo

View File

@ -13,12 +13,9 @@
specVersion: 0.0.1
name: terminal-sample
components:
- name: terminal-sample-plugin
type: chePlugin
- type: chePlugin
id: https://raw.githubusercontent.com/eclipse/che-plugin-registry/master/terminal-sample:0.0.1
- name: terminal-sample-plugin2
type: chePlugin
- type: chePlugin
id: http://raw.githubusercontent.com/eclipse/che-plugin-registry/master/terminal-sample:0.0.1
- name: theia
type: cheEditor
- type: cheEditor
id: https://che-plugin-registry.openshift.io/org.eclipse.theia-ide:0.0.1

View File

@ -14,7 +14,6 @@
specVersion: 0.0.1
name: petclinic-dev-environment
components:
- name: theia-ide
type: cheEditor
- type: cheEditor
id: org.eclipse.theia:0.0.3
reference: petclinic.yaml

View File

@ -14,5 +14,4 @@
specVersion: 0.0.1
name: petclinic-dev-environment
components:
- name: theia-ide
type: cheEditor
- type: cheEditor

View File

@ -14,6 +14,5 @@
specVersion: 0.0.1
name: petclinic-dev-environment
components:
- name: theia-ide
type: cheEditor
- type: cheEditor
id: org.eclipse.theia:dev:v1

View File

@ -14,6 +14,5 @@
specVersion: 0.0.1
name: petclinic-dev-environment
components:
- name: theia-ide
type: cheEditor
- type: cheEditor
id: org.eclipse.theia

View File

@ -19,14 +19,12 @@ projects:
type: git
location: 'git@github.com:spring-projects/spring-petclinic.git'
components:
- name: theia-ide
type: cheEditor
- type: cheEditor
id: org.eclipse.chetheia:0.0.3
- name: mvn-stack
- alias: mvn-stack
type: chePlugin
id: org.eclipse.chemaven-jdk8:1.0.0
- name: jdt.ls
type: chePlugin
- type: chePlugin
id: org.eclipse.chetheia-jdtls:0.0.3
commands:
- name: build

View File

@ -14,7 +14,7 @@
specVersion: 0.0.1
name: petclinic-dev-environment
components:
- name: mysql
- alias: mysql
type: kubernetes
reference: https://github.com/redhat-developer/devfile/blob/master/samples/web-nodejs-with-db-sample/mongo-db.yaml
selector:

View File

@ -14,7 +14,7 @@
specVersion: 0.0.1
name: petclinic-dev-environment
components:
- name: mysql
- alias: mysql
type: kubernetes
referenceContent: petclinic.yaml
selector:

View File

@ -14,7 +14,7 @@
specVersion: 0.0.1
name: petclinic-dev-environment
components:
- name: mysql
- alias: mysql
type: kubernetes
reference: petclinic.yaml
selector:

View File

@ -14,8 +14,7 @@
specVersion: 0.0.1
name: petclinic-dev-environment
components:
- name: mysql
type: kubernetes
- type: kubernetes
reference: petclinic.yaml
referenceContent: |
kind: List

View File

@ -14,7 +14,7 @@
specVersion: 0.0.1
name: petclinic-dev-environment
components:
- name: mysql
- alias: mysql
type: openshift
reference: petclinic.yaml
selector:

View File

@ -14,7 +14,7 @@
specVersion: 0.0.1
name: petclinic-dev-environment
components:
- name: mysql
- alias: mysql
type: openshift
referenceContent: this is content of file that is supposed to be in local field but it is missing
selector:

View File

@ -14,8 +14,7 @@
specVersion: 0.0.1
name: petclinic-dev-environment
components:
- name: mysql
type: openshift
- type: openshift
referenceContent: it is supposed to be a content of the file specified in the local field
reference: petclinic.yaml
selector:

View File

@ -14,8 +14,7 @@
specVersion: 0.0.1
name: petclinic-dev-environment
components:
- name: mysql
type: openshift
- type: openshift
referenceContent: |
kind: List
items:

View File

@ -14,7 +14,7 @@
specVersion: 0.0.1
name: petclinic-dev-environment
components:
- name: mysql
- alias: mysql
type: openshift
reference: petclinic.yaml
selector:

View File

@ -14,5 +14,4 @@
specVersion: 0.0.1
name: petclinic-dev-environment
components:
- name: mysql
type: openshift
- type: openshift

View File

@ -27,7 +27,7 @@ import org.eclipse.che.api.core.model.workspace.devfile.Volume;
/** @author Sergii Leshchenko */
public class ComponentImpl implements Component {
private String name;
private String alias;
private String type;
private String id;
private String reference;
@ -45,20 +45,17 @@ public class ComponentImpl implements Component {
public ComponentImpl() {}
public ComponentImpl(String type, String name, String id) {
this.name = name;
public ComponentImpl(String type, String id) {
this.type = type;
this.id = id;
}
public ComponentImpl(
String type,
String name,
String reference,
String referenceContent,
Map<String, String> selector,
List<? extends Entrypoint> entrypoints) {
this.name = name;
this.type = type;
this.reference = reference;
this.referenceContent = referenceContent;
@ -73,7 +70,7 @@ public class ComponentImpl implements Component {
public ComponentImpl(
String type,
String name,
String alias,
String image,
String memoryLimit,
boolean mountSources,
@ -82,7 +79,7 @@ public class ComponentImpl implements Component {
List<? extends Volume> volumes,
List<? extends Env> env,
List<? extends Endpoint> endpoints) {
this.name = name;
this.alias = alias;
this.type = type;
this.image = image;
this.memoryLimit = memoryLimit;
@ -103,7 +100,7 @@ public class ComponentImpl implements Component {
public ComponentImpl(
String type,
String name,
String alias,
String id,
String reference,
String referenceContent,
@ -116,7 +113,7 @@ public class ComponentImpl implements Component {
List<? extends Volume> volumes,
List<? extends Env> env,
List<? extends Endpoint> endpoints) {
this.name = name;
this.alias = alias;
this.type = type;
this.id = id;
this.reference = reference;
@ -145,7 +142,7 @@ public class ComponentImpl implements Component {
public ComponentImpl(Component component) {
this(
component.getType(),
component.getName(),
component.getAlias(),
component.getId(),
component.getReference(),
component.getReferenceContent(),
@ -161,12 +158,12 @@ public class ComponentImpl implements Component {
}
@Override
public String getName() {
return name;
public String getAlias() {
return alias;
}
public void setName(String name) {
this.name = name;
public void setAlias(String alias) {
this.alias = alias;
}
@Override
@ -326,7 +323,7 @@ public class ComponentImpl implements Component {
}
ComponentImpl component = (ComponentImpl) o;
return getMountSources() == component.getMountSources()
&& Objects.equals(getName(), component.getName())
&& Objects.equals(getAlias(), component.getAlias())
&& Objects.equals(getType(), component.getType())
&& Objects.equals(getId(), component.getId())
&& Objects.equals(getReference(), component.getReference())
@ -346,7 +343,7 @@ public class ComponentImpl implements Component {
public int hashCode() {
return Objects.hash(
getName(),
getAlias(),
getType(),
getId(),
getReference(),
@ -366,8 +363,8 @@ public class ComponentImpl implements Component {
@Override
public String toString() {
return "ComponentImpl{"
+ "name='"
+ name
+ "alias='"
+ alias
+ '\''
+ ", type='"
+ type