From caae00e21b2fd316560a406f2e1d8ad98edf1dad Mon Sep 17 00:00:00 2001 From: Lukas Krejci Date: Mon, 10 Jun 2019 23:23:45 +0200 Subject: [PATCH] K8s-like devfile naming (#13490) `specVersion` is now `apiVersion` and is bumped to 1.0.0 `name` is now nested under the new `metadata` element. Signed-off-by: Lukas Krejci --- .../core/model/workspace/devfile/Devfile.java | 16 ++-- .../model/workspace/devfile/Metadata.java | 19 +++++ dashboard/devfile.yaml | 5 +- dashboard/src/components/typings/che.d.ts | 5 +- devfile.yaml | 5 +- workspace-loader/devfile.yaml | 5 +- .../DefaultFactoryParameterResolverTest.java | 5 +- .../shared/dto/devfile/DevfileDto.java | 20 ++--- .../shared/dto/devfile/MetadataDto.java | 26 ++++++ .../che-core-api-workspace/README-devfile.md | 20 +++-- .../api/workspace/server/DtoConverter.java | 13 ++- .../workspace/server/devfile/Constants.java | 2 +- .../devfile/convert/DevfileConverter.java | 16 ++-- .../server/model/impl/WorkspaceImpl.java | 2 +- .../model/impl/devfile/DevfileImpl.java | 80 +++++++++++-------- .../model/impl/devfile/MetadataImpl.java | 65 +++++++++++++++ .../src/main/resources/schema/devfile.json | 32 +++++--- .../server/WorkspaceServiceTest.java | 5 +- .../devfile/convert/DevfileConverterTest.java | 16 ++-- .../validator/DevfileSchemaValidatorTest.java | 20 ++++- .../server/jpa/JpaWorkspaceDaoTest.java | 54 +++++++++++++ .../server/spi/tck/WorkspaceDaoTest.java | 5 +- .../src/test/resources/devfile/devfile.yaml | 5 +- ...ion_without_commandline_and_reference.yaml | 5 +- .../devfile_missing_command_actions.yaml | 5 +- .../command/devfile_missing_command_name.yaml | 5 +- .../devfile_multiple_commands_actions.yaml | 5 +- ...vfile_component_with_undeclared_field.yaml | 5 +- .../devfile_missing_component_type.yaml | 5 +- .../devfile_unknown_component_type.yaml | 5 +- .../devfile_without_any_component.yaml | 5 +- ...rsion.yaml => devfile_empty_metadata.yaml} | 3 +- .../devfile/devfile_missing_api_version.yaml | 15 ++++ .../devfile/devfile_missing_metadata.yaml | 14 ++++ .../devfile/devfile_missing_name.yaml | 4 +- .../devfile/devfile_null_metadata.yaml | 15 ++++ .../devfile_with_undeclared_field.yaml | 5 +- .../devfile_dockerimage_component.yaml | 5 +- ...ent_with_indistinctive_field_selector.yaml | 5 +- ...kerimage_component_with_missing_image.yaml | 5 +- ...e_component_with_missing_memory_limit.yaml | 5 +- ...erimage_component_without_entry_point.yaml | 5 +- ...le_editor_component_with_bad_registry.yaml | 5 +- ...editor_component_with_custom_registry.yaml | 5 +- ...ditor_component_with_id_and_reference.yaml | 5 +- ...or_component_with_indistinctive_field.yaml | 5 +- ...file_editor_component_with_missing_id.yaml | 5 +- ..._component_with_multiple_colons_in_id.yaml | 5 +- ..._editor_component_with_registry_in_id.yaml | 5 +- ...file_editor_component_without_version.yaml | 5 +- .../devfile_editor_plugins.yaml | 5 +- ..._components_with_invalid_memory_limit.yaml | 5 +- ..._plugins_components_with_memory_limit.yaml | 5 +- ...vfile_plugin_component_with_reference.yaml | 7 +- ...le_plugin_components_with_preferences.yaml | 5 +- ...bernetes_component_absolute_reference.yaml | 5 +- ...s_component_content_without_reference.yaml | 5 +- ...evfile_kubernetes_component_reference.yaml | 5 +- ...ponent_reference_and_content_as_block.yaml | 5 +- .../devfile_openshift_component.yaml | 5 +- ...t_component_content_without_reference.yaml | 5 +- ...shift_component_reference_and_content.yaml | 5 +- ...ponent_reference_and_content_as_block.yaml | 5 +- ...component_with_indistinctive_field_id.yaml | 5 +- ...issing_reference_and_referenceContent.yaml | 5 +- .../1__devfile_metadata.sql | 14 ++++ .../mysql/1__devfile_metadata.sql | 14 ++++ .../che/core/db/jpa/TestObjectsFactory.java | 10 ++- 68 files changed, 531 insertions(+), 186 deletions(-) create mode 100644 core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/devfile/Metadata.java create mode 100644 wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/dto/devfile/MetadataDto.java create mode 100644 wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/MetadataImpl.java rename wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/{devfile_missing_spec_version.yaml => devfile_empty_metadata.yaml} (91%) create mode 100644 wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_missing_api_version.yaml create mode 100644 wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_missing_metadata.yaml create mode 100644 wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_null_metadata.yaml create mode 100644 wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC2.0/1__devfile_metadata.sql create mode 100644 wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC2.0/mysql/1__devfile_metadata.sql diff --git a/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/devfile/Devfile.java b/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/devfile/Devfile.java index b4acae4aa7..be8b93540f 100644 --- a/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/devfile/Devfile.java +++ b/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/devfile/Devfile.java @@ -17,14 +17,13 @@ import java.util.Map; /** Defines Devfile. */ public interface Devfile { - /** Returns Specification Version. It is required. */ - String getSpecVersion(); + /** Returns the name of the devfile. Shortcut for {@code getMetadata().getName()}. */ + default String getName() { + return getMetadata() == null ? null : getMetadata().getName(); + } - /** - * Returns the name of the devfile. Workspaces created from devfile, will inherit this name. It is - * required. - */ - String getName(); + /** Returns Devfile API Version. It is required. */ + String getApiVersion(); /** * Returns projects configurations which are related to the devfile, when devfile doesn't contain @@ -46,4 +45,7 @@ public interface Devfile { /** Returns devfile attributes. Devfile attributes must not contain null keys or values. */ Map getAttributes(); + + /** Returns the metadata of the devfile. */ + Metadata getMetadata(); } diff --git a/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/devfile/Metadata.java b/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/devfile/Metadata.java new file mode 100644 index 0000000000..46b3a353df --- /dev/null +++ b/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/devfile/Metadata.java @@ -0,0 +1,19 @@ +/* + * 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.core.model.workspace.devfile; + +/** Defines the metadata of a devfile. */ +public interface Metadata { + + /** @return the name of the devfile */ + String getName(); +} diff --git a/dashboard/devfile.yaml b/dashboard/devfile.yaml index afd87855fb..791d190c61 100644 --- a/dashboard/devfile.yaml +++ b/dashboard/devfile.yaml @@ -1,5 +1,6 @@ -specVersion: 0.0.1 -name: dashboard-in-che +apiVersion: 1.0.0 +metadata: + name: dashboard-in-che projects: - name: che source: diff --git a/dashboard/src/components/typings/che.d.ts b/dashboard/src/components/typings/che.d.ts index 32fdad7d40..58530d467d 100755 --- a/dashboard/src/components/typings/che.d.ts +++ b/dashboard/src/components/typings/che.d.ts @@ -333,12 +333,15 @@ declare namespace che { } export interface IWorkspaceDevfile { - specVersion: string; + apiVersion: string; name: string; components: Array; projects?: Array ; commands?: Array ; attributes?: che.IWorkspaceConfigAttributes; + metadata: { + name: string + } } export interface IWorkspaceEnvironment { diff --git a/devfile.yaml b/devfile.yaml index 939cccd197..c31cdcd399 100644 --- a/devfile.yaml +++ b/devfile.yaml @@ -1,5 +1,6 @@ -specVersion: 0.0.1 -name: che-in-che +apiVersion: 1.0.0 +metadata: + name: che-in-che projects: - name: che source: diff --git a/workspace-loader/devfile.yaml b/workspace-loader/devfile.yaml index b2b1b4d660..e466d35950 100644 --- a/workspace-loader/devfile.yaml +++ b/workspace-loader/devfile.yaml @@ -1,5 +1,6 @@ -specVersion: 0.0.1 -name: workspace-loader +apiVersion: 1.0.0 +metadata: + name: workspace-loader projects: - name: che source: 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 0a94195775..71293f52bd 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 @@ -56,8 +56,9 @@ public class DefaultFactoryParameterResolverTest { private static final String DEVFILE = "" - + "specVersion: 0.0.1\n" - + "name: test\n" + + "apiVersion: 1.0.0\n" + + "metadata:\n" + + " name: test\n" + "components:\n" + "- type: kubernetes\n" + " alias: component\n" diff --git a/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/dto/devfile/DevfileDto.java b/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/dto/devfile/DevfileDto.java index 2b7d7fcd0c..a7dd880ece 100644 --- a/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/dto/devfile/DevfileDto.java +++ b/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/dto/devfile/DevfileDto.java @@ -20,18 +20,11 @@ import org.eclipse.che.dto.shared.DTO; @DTO public interface DevfileDto extends Devfile { @Override - String getSpecVersion(); + String getApiVersion(); - void setSpecVersion(String specVersion); + void setApiVersion(String apiVersion); - DevfileDto withSpecVersion(String specVersion); - - @Override - String getName(); - - void setName(String name); - - DevfileDto withName(String name); + DevfileDto withApiVersion(String apiVersion); @Override List getProjects(); @@ -60,4 +53,11 @@ public interface DevfileDto extends Devfile { void setAttributes(Map attributes); DevfileDto withAttributes(Map attributes); + + @Override + MetadataDto getMetadata(); + + void setMetadata(MetadataDto metadata); + + DevfileDto withMetadata(MetadataDto metadata); } diff --git a/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/dto/devfile/MetadataDto.java b/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/dto/devfile/MetadataDto.java new file mode 100644 index 0000000000..c3fa010faf --- /dev/null +++ b/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/dto/devfile/MetadataDto.java @@ -0,0 +1,26 @@ +/* + * 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.shared.dto.devfile; + +import org.eclipse.che.api.core.model.workspace.devfile.Metadata; +import org.eclipse.che.dto.shared.DTO; + +@DTO +public interface MetadataDto extends Metadata { + + @Override + String getName(); + + void setName(String name); + + MetadataDto withName(String name); +} diff --git a/wsmaster/che-core-api-workspace/README-devfile.md b/wsmaster/che-core-api-workspace/README-devfile.md index f7d4ea9b2b..1d1f83f639 100644 --- a/wsmaster/che-core-api-workspace/README-devfile.md +++ b/wsmaster/che-core-api-workspace/README-devfile.md @@ -23,8 +23,9 @@ Example of the minimal devfile with project and standard plugins set (Theia edit ``` --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment projects: - name: petclinic source: @@ -74,8 +75,9 @@ cloned to. As an example, consider this devfile: ```yaml -specVersion: 0.0.1 -name: example-devfile +apiVersion: 1.0.0 +metadata: + name: example-devfile projects: - name: frontend source: @@ -306,8 +308,9 @@ If editor is not specified Devfile then default one will be provided. In case wh Default value is `false` and means that Devfile needs default editor to be provisioned if no one is defined. Example of Devfile without editor ```yaml -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - alias: myApp type: kubernetes @@ -322,8 +325,9 @@ Sometimes it may be needed to disable data persistence for some reasons, like wh To achieve it the `persistVolumes` devfile attribute should be used. Default value is `true`, and in case of `false` `emptyDir` volumes will be used for configured volumes and PVC. Example of Devfile with ephemeral mode enabled ```yaml -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment projects: - name: petclinic source: diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/DtoConverter.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/DtoConverter.java index 38c4fa3f1c..14b5aca272 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/DtoConverter.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/DtoConverter.java @@ -34,6 +34,7 @@ import org.eclipse.che.api.core.model.workspace.devfile.Devfile; import org.eclipse.che.api.core.model.workspace.devfile.Endpoint; import org.eclipse.che.api.core.model.workspace.devfile.Entrypoint; import org.eclipse.che.api.core.model.workspace.devfile.Env; +import org.eclipse.che.api.core.model.workspace.devfile.Metadata; import org.eclipse.che.api.core.model.workspace.devfile.Project; import org.eclipse.che.api.core.model.workspace.devfile.Source; import org.eclipse.che.api.core.model.workspace.runtime.Machine; @@ -63,6 +64,7 @@ import org.eclipse.che.api.workspace.shared.dto.devfile.DevfileVolumeDto; import org.eclipse.che.api.workspace.shared.dto.devfile.EndpointDto; import org.eclipse.che.api.workspace.shared.dto.devfile.EntrypointDto; import org.eclipse.che.api.workspace.shared.dto.devfile.EnvDto; +import org.eclipse.che.api.workspace.shared.dto.devfile.MetadataDto; import org.eclipse.che.api.workspace.shared.dto.devfile.ProjectDto; import org.eclipse.che.api.workspace.shared.dto.devfile.SourceDto; import org.eclipse.che.api.workspace.shared.dto.stack.StackComponentDto; @@ -110,12 +112,12 @@ public final class DtoConverter { List projects = devfile.getProjects().stream().map(DtoConverter::asDto).collect(toList()); return newDto(DevfileDto.class) - .withName(devfile.getName()) - .withSpecVersion(devfile.getSpecVersion()) + .withApiVersion(devfile.getApiVersion()) .withCommands(commands) .withComponents(components) .withProjects(projects) - .withAttributes(devfile.getAttributes()); + .withAttributes(devfile.getAttributes()) + .withMetadata(asDto(devfile.getMetadata())); } private static ProjectDto asDto(Project project) { @@ -416,5 +418,10 @@ public final class DtoConverter { return machineDto; } + /** Converts {@link Metadata} to {@link MetadataDto}. */ + public static MetadataDto asDto(Metadata metadata) { + return newDto(MetadataDto.class).withName(metadata.getName()); + } + private DtoConverter() {} } diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/Constants.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/Constants.java index 31adb9d00d..f0f644755e 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/Constants.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/Constants.java @@ -17,7 +17,7 @@ public class Constants { public static final String SCHEMA_LOCATION = "schema/devfile.json"; - public static final String CURRENT_SPEC_VERSION = "0.0.1"; + public static final String CURRENT_API_VERSION = "1.0.0"; public static final String EDITOR_COMPONENT_TYPE = "cheEditor"; diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/convert/DevfileConverter.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/convert/DevfileConverter.java index 521905b188..e844f1e420 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/convert/DevfileConverter.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/convert/DevfileConverter.java @@ -13,9 +13,10 @@ package org.eclipse.che.api.workspace.server.devfile.convert; import static com.google.common.base.Preconditions.checkArgument; import static java.lang.String.format; +import static java.util.Collections.singleton; import static java.util.stream.Collectors.toCollection; import static org.eclipse.che.api.workspace.server.devfile.Components.getIdentifiableComponentName; -import static org.eclipse.che.api.workspace.server.devfile.Constants.CURRENT_SPEC_VERSION; +import static org.eclipse.che.api.workspace.server.devfile.Constants.CURRENT_API_VERSION; import com.google.common.base.Strings; import java.util.ArrayList; @@ -90,7 +91,7 @@ public class DevfileConverter { } DevfileImpl devfile = new DevfileImpl(); - devfile.setSpecVersion(CURRENT_SPEC_VERSION); + devfile.setApiVersion(CURRENT_API_VERSION); devfile.setName(wsConfig.getName()); // Manage projects @@ -181,12 +182,15 @@ public class DevfileConverter { } private static void validateCurrentVersion(Devfile devFile) throws DevfileFormatException { - if (Strings.isNullOrEmpty(devFile.getSpecVersion())) { - throw new DevfileFormatException("Provided Devfile has no spec version specified"); + if (Strings.isNullOrEmpty(devFile.getApiVersion())) { + throw new DevfileFormatException("Provided Devfile has no API version specified"); } - if (!CURRENT_SPEC_VERSION.equals(devFile.getSpecVersion())) { + if (!CURRENT_API_VERSION.equals(devFile.getApiVersion())) { throw new DevfileFormatException( - format("Provided Devfile has unsupported version '%s'", devFile.getSpecVersion())); + format( + "Provided Devfile has unsupported version '%s'. The following versions are" + + " supported: %s", + devFile.getApiVersion(), singleton(CURRENT_API_VERSION))); } } } diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/WorkspaceImpl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/WorkspaceImpl.java index 84b83e14fa..00c7ed97b6 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/WorkspaceImpl.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/WorkspaceImpl.java @@ -220,7 +220,7 @@ public class WorkspaceImpl implements Workspace { /** Returns the name of workspace. It can be stored by workspace config or devfile. */ public String getName() { if (devfile != null) { - return devfile.getName(); + return devfile.getMetadata().getName(); } else if (config != null) { return config.getName(); } else { diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/DevfileImpl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/DevfileImpl.java index dc8926dbca..86c2078dd3 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/DevfileImpl.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/DevfileImpl.java @@ -22,6 +22,7 @@ import javax.persistence.CascadeType; import javax.persistence.CollectionTable; import javax.persistence.Column; import javax.persistence.ElementCollection; +import javax.persistence.Embedded; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; @@ -33,6 +34,7 @@ import javax.persistence.Table; import org.eclipse.che.api.core.model.workspace.devfile.Command; import org.eclipse.che.api.core.model.workspace.devfile.Component; import org.eclipse.che.api.core.model.workspace.devfile.Devfile; +import org.eclipse.che.api.core.model.workspace.devfile.Metadata; import org.eclipse.che.api.core.model.workspace.devfile.Project; /** @author Sergii Leshchenko */ @@ -45,11 +47,8 @@ public class DevfileImpl implements Devfile { @Column(name = "id") private Long id; - @Column(name = "spec_version", nullable = false) - private String specVersion; - - @Column(name = "name", nullable = false) - private String name; + @Column(name = "api_version", nullable = false) + private String apiVersion; @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER) @JoinColumn(name = "devfile_id") @@ -69,17 +68,18 @@ public class DevfileImpl implements Devfile { @Column(name = "value", columnDefinition = "TEXT") private Map attributes; + @Embedded private MetadataImpl metadata; + public DevfileImpl() {} public DevfileImpl( - String specVersion, - String name, + String apiVersion, List projects, List components, List commands, - Map attributes) { - this.specVersion = specVersion; - this.name = name; + Map attributes, + Metadata metadata) { + this.apiVersion = apiVersion; if (projects != null) { this.projects = projects.stream().map(ProjectImpl::new).collect(toCollection(ArrayList::new)); } @@ -93,34 +93,33 @@ public class DevfileImpl implements Devfile { if (attributes != null) { this.attributes = new HashMap<>(attributes); } + + if (metadata != null) { + this.metadata = new MetadataImpl(metadata); + } } public DevfileImpl(Devfile devfile) { this( - devfile.getSpecVersion(), - devfile.getName(), + devfile.getApiVersion(), devfile.getProjects(), devfile.getComponents(), devfile.getCommands(), - devfile.getAttributes()); + devfile.getAttributes(), + devfile.getMetadata()); } @Override - public String getSpecVersion() { - return specVersion; + public String getApiVersion() { + return apiVersion; } - public void setSpecVersion(String specVersion) { - this.specVersion = specVersion; - } - - @Override - public String getName() { - return name; + public void setApiVersion(String apiVersion) { + this.apiVersion = apiVersion; } public void setName(String name) { - this.name = name; + getMetadata().setName(name); } @Override @@ -171,6 +170,18 @@ public class DevfileImpl implements Devfile { this.attributes = attributes; } + @Override + public MetadataImpl getMetadata() { + if (metadata == null) { + metadata = new MetadataImpl(); + } + return metadata; + } + + public void setMetadata(MetadataImpl metadata) { + this.metadata = metadata; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -181,18 +192,24 @@ public class DevfileImpl implements Devfile { } DevfileImpl devfile = (DevfileImpl) o; return Objects.equals(id, devfile.id) - && Objects.equals(specVersion, devfile.specVersion) - && Objects.equals(name, devfile.name) + && Objects.equals(apiVersion, devfile.apiVersion) && Objects.equals(getProjects(), devfile.getProjects()) && Objects.equals(getComponents(), devfile.getComponents()) && Objects.equals(getCommands(), devfile.getCommands()) - && Objects.equals(getAttributes(), devfile.getAttributes()); + && Objects.equals(getAttributes(), devfile.getAttributes()) + && Objects.equals(getMetadata(), devfile.getMetadata()); } @Override public int hashCode() { return Objects.hash( - id, specVersion, name, getProjects(), getComponents(), getCommands(), getAttributes()); + id, + apiVersion, + getProjects(), + getComponents(), + getCommands(), + getAttributes(), + getMetadata()); } @Override @@ -201,11 +218,8 @@ public class DevfileImpl implements Devfile { + "id='" + id + '\'' - + ", specVersion='" - + specVersion - + '\'' - + ", name='" - + name + + ", apiVersion='" + + apiVersion + '\'' + ", projects=" + projects @@ -215,6 +229,8 @@ public class DevfileImpl implements Devfile { + commands + ", attributes=" + attributes + + ", metadata=" + + metadata + '}'; } } diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/MetadataImpl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/MetadataImpl.java new file mode 100644 index 0000000000..11aefb14b2 --- /dev/null +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/MetadataImpl.java @@ -0,0 +1,65 @@ +/* + * 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.model.impl.devfile; + +import java.util.Objects; +import javax.persistence.Column; +import javax.persistence.Embeddable; +import org.eclipse.che.api.core.model.workspace.devfile.Metadata; + +@Embeddable +public class MetadataImpl implements Metadata { + + @Column(name = "meta_name") + private String name; + + public MetadataImpl() {} + + public MetadataImpl(String name) { + this.name = name; + } + + public MetadataImpl(Metadata metadata) { + this.name = metadata.getName(); + } + + @Override + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MetadataImpl metadata = (MetadataImpl) o; + return name.equals(metadata.name); + } + + @Override + public int hashCode() { + return Objects.hash(name); + } + + @Override + public String toString() { + return "MetadataImpl{'name='" + name + '\'' + '}'; + } +} diff --git a/wsmaster/che-core-api-workspace/src/main/resources/schema/devfile.json b/wsmaster/che-core-api-workspace/src/main/resources/schema/devfile.json index 2c2f91a1e6..3d4838f95e 100644 --- a/wsmaster/che-core-api-workspace/src/main/resources/schema/devfile.json +++ b/wsmaster/che-core-api-workspace/src/main/resources/schema/devfile.json @@ -27,25 +27,33 @@ } }, "required": [ - "specVersion", - "name" + "apiVersion", + "metadata" ], "additionalProperties": false, "properties": { - "specVersion": { + "apiVersion": { "type": "string", - "title": "Devfile Specification Version", + "title": "Devfile API Version", "examples": [ - "0.0.1" + "1.0.0" ] }, - "name": { - "type": "string", - "title": "Devfile Name", - "description": "The name of the devfile. Workspaces created from devfile, will inherit this name", - "examples": [ - "petclinic-dev-environment" - ] + "metadata": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 1, + "title": "Devfile Name", + "description": "The name of the devfile. Workspaces created from devfile, will inherit this name", + "examples": [ + "petclinic-dev-environment" + ] + } + }, + "additionalProperties": false, + "required": ["name"] }, "projects": { "type": "array", diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/WorkspaceServiceTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/WorkspaceServiceTest.java index 4b9902cd49..ca605f3bc1 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/WorkspaceServiceTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/WorkspaceServiceTest.java @@ -86,6 +86,7 @@ import org.eclipse.che.api.workspace.shared.dto.SourceStorageDto; import org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto; import org.eclipse.che.api.workspace.shared.dto.WorkspaceDto; import org.eclipse.che.api.workspace.shared.dto.devfile.DevfileDto; +import org.eclipse.che.api.workspace.shared.dto.devfile.MetadataDto; import org.eclipse.che.api.workspace.shared.dto.devfile.ProjectDto; import org.eclipse.che.api.workspace.shared.dto.devfile.SourceDto; import org.eclipse.che.commons.env.EnvironmentContext; @@ -1354,8 +1355,8 @@ public class WorkspaceServiceTest { private DevfileDtoImpl createDevfileDto() { return (DevfileDtoImpl) newDto(DevfileDto.class) - .withSpecVersion("0.0.1") - .withName("ws") + .withApiVersion("0.0.1") + .withMetadata(newDto(MetadataDto.class).withName("ws")) .withProjects( singletonList( newDto(ProjectDto.class) diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/convert/DevfileConverterTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/convert/DevfileConverterTest.java index 16c9193232..6c3126f1e2 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/convert/DevfileConverterTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/convert/DevfileConverterTest.java @@ -11,7 +11,7 @@ */ package org.eclipse.che.api.workspace.server.devfile.convert; -import static org.eclipse.che.api.workspace.server.devfile.Constants.CURRENT_SPEC_VERSION; +import static org.eclipse.che.api.workspace.server.devfile.Constants.CURRENT_API_VERSION; import static org.eclipse.che.api.workspace.shared.Constants.PERSIST_VOLUMES_ATTRIBUTE; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; @@ -98,7 +98,7 @@ public class DevfileConverterTest { DevfileImpl devfile = devfileConverter.workspaceToDevFile(wsConfig); // then - assertEquals(devfile.getSpecVersion(), CURRENT_SPEC_VERSION); + assertEquals(devfile.getApiVersion(), CURRENT_API_VERSION); } @Test @@ -277,9 +277,9 @@ public class DevfileConverterTest { @Test( expectedExceptions = DevfileFormatException.class, - expectedExceptionsMessageRegExp = "Provided Devfile has no spec version specified") + expectedExceptionsMessageRegExp = "Provided Devfile has no API version specified") public void - shouldThrowAnExceptionIfDevfileSpecVersionIsMissingDuringConvertingDevfileToWorkspaceConfig() + shouldThrowAnExceptionIfDevfileApiVersionIsMissingDuringConvertingDevfileToWorkspaceConfig() throws Exception { // given FileContentProvider fileContentProvider = mock(FileContentProvider.class); @@ -293,14 +293,14 @@ public class DevfileConverterTest { @Test( expectedExceptions = DevfileFormatException.class, expectedExceptionsMessageRegExp = - "Provided Devfile has unsupported version '1\\.0\\.0-non-supported'") + "Provided Devfile has unsupported version '1\\.0\\.0-non-supported'. The following versions are supported: .*") public void - shouldThrowAnExceptionIfDevfileSpecVersionIsNotSupportedDuringConvertingDevfileToWorkspaceConfig() + shouldThrowAnExceptionIfDevfileApiVersionIsNotSupportedDuringConvertingDevfileToWorkspaceConfig() throws Exception { // given FileContentProvider fileContentProvider = mock(FileContentProvider.class); DevfileImpl devfile = new DevfileImpl(); - devfile.setSpecVersion("1.0.0-non-supported"); + devfile.setApiVersion("1.0.0-non-supported"); devfile.setName("petclinic"); // when @@ -334,7 +334,7 @@ public class DevfileConverterTest { private DevfileImpl newDevfile(String name) { DevfileImpl devfile = new DevfileImpl(); - devfile.setSpecVersion(CURRENT_SPEC_VERSION); + devfile.setApiVersion(CURRENT_API_VERSION); devfile.setName(name); return devfile; } diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/validator/DevfileSchemaValidatorTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/validator/DevfileSchemaValidatorTest.java index 4e3385c345..f825e4e6d2 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/validator/DevfileSchemaValidatorTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/validator/DevfileSchemaValidatorTest.java @@ -88,12 +88,24 @@ public class DevfileSchemaValidatorTest { return new Object[][] { // Devfile model testing { - "devfile/devfile_missing_name.yaml", - "The object must have a property whose name is \"name\"." + "devfile/devfile_empty_metadata.yaml", + "(/metadata):The object must have a property whose name is \"name\"." }, { - "devfile/devfile_missing_spec_version.yaml", - "The object must have a property whose name is \"specVersion\"." + "devfile/devfile_null_metadata.yaml", + "(/metadata):The value must be of object type, but actual type is null." + }, + { + "devfile/devfile_missing_metadata.yaml", + "The object must have a property whose name is \"metadata\"." + }, + { + "devfile/devfile_missing_name.yaml", + "(/metadata/something):The object must not have a property whose name is \"something\".(/metadata):The object must have a property whose name is \"name\"." + }, + { + "devfile/devfile_missing_api_version.yaml", + "The object must have a property whose name is \"apiVersion\"." }, { "devfile/devfile_with_undeclared_field.yaml", diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDaoTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDaoTest.java index bf7868c79e..efce708d9d 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDaoTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDaoTest.java @@ -166,6 +166,60 @@ public class JpaWorkspaceDaoTest { assertEquals(result.getConfig().getProjects().get(0).getAttributes().size(), 3); } + @Test(expectedExceptions = IllegalStateException.class) + public void shouldNotSaveDevfileWithoutMetadata() { + final AccountImpl account = new AccountImpl("accountId", "namespace", "test"); + final WorkspaceImpl workspace = createWorkspaceFromDevfile("id", account, "name"); + workspace.getDevfile().setMetadata(null); + + try { + // persist the workspace + manager.getTransaction().begin(); + manager.persist(account); + manager.persist(workspace); + manager.getTransaction().commit(); + } finally { + manager.getTransaction().rollback(); + manager.clear(); + } + } + + @Test(expectedExceptions = IllegalStateException.class) + public void shouldNotSaveDevfileWithoutMetadataName() { + final AccountImpl account = new AccountImpl("accountId", "namespace", "test"); + final WorkspaceImpl workspace = createWorkspaceFromDevfile("id", account, "name"); + workspace.getDevfile().getMetadata().setName(null); + + try { + // persist the workspace + manager.getTransaction().begin(); + manager.persist(account); + manager.persist(workspace); + manager.getTransaction().commit(); + } finally { + manager.getTransaction().rollback(); + manager.clear(); + } + } + + @Test(expectedExceptions = IllegalStateException.class) + public void shouldNotSaveDevfileWithEmptyMetadataName() { + final AccountImpl account = new AccountImpl("accountId", "namespace", "test"); + final WorkspaceImpl workspace = createWorkspaceFromDevfile("id", account, "name"); + workspace.getDevfile().getMetadata().setName(""); + + try { + // persist the workspace + manager.getTransaction().begin(); + manager.persist(account); + manager.persist(workspace); + manager.getTransaction().commit(); + } finally { + manager.getTransaction().rollback(); + manager.clear(); + } + } + private long asLong(String query) { return manager.createQuery(query, Long.class).getSingleResult(); } 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 a6e62b8e99..df2a0cdd8f 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 @@ -58,6 +58,7 @@ import org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.EntrypointImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl; +import org.eclipse.che.api.workspace.server.model.impl.devfile.MetadataImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl; import org.eclipse.che.api.workspace.server.spi.WorkspaceDao; @@ -945,11 +946,11 @@ public class WorkspaceDaoTest { DevfileImpl devfile = new DevfileImpl( "0.0.1", - name, asList(project1, project2), asList(component1, component2), asList(command1, command2), - singletonMap("attribute1", "value1")); + singletonMap("attribute1", "value1"), + new MetadataImpl(name)); return devfile; } diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/devfile.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/devfile.yaml index 56ef26b750..5b773c141e 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/devfile.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/devfile.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment projects: - name: petclinic source: diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/command/devfile_action_without_commandline_and_reference.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/command/devfile_action_without_commandline_and_reference.yaml index b8073a9639..ee57e0938a 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/command/devfile_action_without_commandline_and_reference.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/command/devfile_action_without_commandline_and_reference.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - alias: theia type: cheEditor diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/command/devfile_missing_command_actions.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/command/devfile_missing_command_actions.yaml index e9ca3311a4..d8b24fc4f3 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/command/devfile_missing_command_actions.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/command/devfile_missing_command_actions.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - alias: theia type: cheEditor diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/command/devfile_missing_command_name.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/command/devfile_missing_command_name.yaml index 2a6d7bc48f..86c68a32b8 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/command/devfile_missing_command_name.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/command/devfile_missing_command_name.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - alias: theia type: cheEditor diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/command/devfile_multiple_commands_actions.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/command/devfile_multiple_commands_actions.yaml index 77b5ab537a..ae2d5bf3aa 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/command/devfile_multiple_commands_actions.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/command/devfile_multiple_commands_actions.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - alias: mysql type: openshift diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/component/devfile_component_with_undeclared_field.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/component/devfile_component_with_undeclared_field.yaml index e0557c40be..6ad7c11e7b 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/component/devfile_component_with_undeclared_field.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/component/devfile_component_with_undeclared_field.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - type: chePlugin alias: maven diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/component/devfile_missing_component_type.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/component/devfile_missing_component_type.yaml index 3ab16e803f..529d05bd1f 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/component/devfile_missing_component_type.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/component/devfile_missing_component_type.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - alias: maven id: eclipse/chemaven-jdk8/1.0.0 diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/component/devfile_unknown_component_type.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/component/devfile_unknown_component_type.yaml index abe2a57087..9757351fb5 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/component/devfile_unknown_component_type.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/component/devfile_unknown_component_type.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - alias: maven id: org.eclipse.chemaven-jdk8:1.0.0 diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/component/devfile_without_any_component.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/component/devfile_without_any_component.yaml index 9a097d2a52..b72e2ad691 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/component/devfile_without_any_component.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/component/devfile_without_any_component.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment projects: - name: petclinic source: diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_missing_spec_version.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_empty_metadata.yaml similarity index 91% rename from wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_missing_spec_version.yaml rename to wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_empty_metadata.yaml index 9ac5bcfba4..695519cf82 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_missing_spec_version.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_empty_metadata.yaml @@ -11,4 +11,5 @@ # --- -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: {} diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_missing_api_version.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_missing_api_version.yaml new file mode 100644 index 0000000000..1a3c9d2d7f --- /dev/null +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_missing_api_version.yaml @@ -0,0 +1,15 @@ +# +# 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 +# + +--- +metadata: + name: petclinic-dev-environment diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_missing_metadata.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_missing_metadata.yaml new file mode 100644 index 0000000000..284382b67a --- /dev/null +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_missing_metadata.yaml @@ -0,0 +1,14 @@ +# +# 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 +# + +--- +apiVersion: 1.0.0 diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_missing_name.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_missing_name.yaml index c40a2db79e..0ef3a29b39 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_missing_name.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_missing_name.yaml @@ -11,4 +11,6 @@ # --- -specVersion: 0.0.1 +apiVersion: 1.0.0 +metadata: + something: else diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_null_metadata.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_null_metadata.yaml new file mode 100644 index 0000000000..b0045a8e45 --- /dev/null +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_null_metadata.yaml @@ -0,0 +1,15 @@ +# +# 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 +# + +--- +apiVersion: 1.0.0 +metadata: diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_with_undeclared_field.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_with_undeclared_field.yaml index 3d7cc64ea9..76aec9e819 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_with_undeclared_field.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_with_undeclared_field.yaml @@ -11,6 +11,7 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment unknown: blah-blah diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/dockerimage_component/devfile_dockerimage_component.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/dockerimage_component/devfile_dockerimage_component.yaml index 9a524275be..1aef3f3517 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/dockerimage_component/devfile_dockerimage_component.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/dockerimage_component/devfile_dockerimage_component.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - type: dockerimage image: eclipe/maven-jdk8:latest diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/dockerimage_component/devfile_dockerimage_component_with_indistinctive_field_selector.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/dockerimage_component/devfile_dockerimage_component_with_indistinctive_field_selector.yaml index 93f3bbc603..c4fbc0a9f3 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/dockerimage_component/devfile_dockerimage_component_with_indistinctive_field_selector.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/dockerimage_component/devfile_dockerimage_component_with_indistinctive_field_selector.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - type: dockerimage image: eclipe/maven-jdk8:latest diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/dockerimage_component/devfile_dockerimage_component_with_missing_image.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/dockerimage_component/devfile_dockerimage_component_with_missing_image.yaml index 336542ddcd..80b1aee0a6 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/dockerimage_component/devfile_dockerimage_component_with_missing_image.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/dockerimage_component/devfile_dockerimage_component_with_missing_image.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - type: dockerimage memoryLimit: 1G diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/dockerimage_component/devfile_dockerimage_component_with_missing_memory_limit.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/dockerimage_component/devfile_dockerimage_component_with_missing_memory_limit.yaml index 28ecb24897..93e34a5b44 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/dockerimage_component/devfile_dockerimage_component_with_missing_memory_limit.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/dockerimage_component/devfile_dockerimage_component_with_missing_memory_limit.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - type: dockerimage image: org.eclipse.cheubuntu-jdk:latest diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/dockerimage_component/devfile_dockerimage_component_without_entry_point.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/dockerimage_component/devfile_dockerimage_component_without_entry_point.yaml index 68cbdbc19f..db52e43234 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/dockerimage_component/devfile_dockerimage_component_without_entry_point.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/dockerimage_component/devfile_dockerimage_component_without_entry_point.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - type: dockerimage image: eclipe/maven-jdk8:latest diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_bad_registry.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_bad_registry.yaml index a57e1346bd..0efd236a3b 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_bad_registry.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_bad_registry.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - type: cheEditor id: eclipse/theia/dev diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_custom_registry.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_custom_registry.yaml index 520fd61b29..6c9d44a245 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_custom_registry.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_custom_registry.yaml @@ -10,8 +10,9 @@ # Red Hat, Inc. - initial API and implementation # -specVersion: 0.0.1 -name: terminal-sample +apiVersion: 1.0.0 +metadata: + name: terminal-sample components: - type: cheEditor registryUrl: https://che-plugin-registry.openshift.io/ diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_id_and_reference.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_id_and_reference.yaml index 1d67574bb1..7dcefe4378 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_id_and_reference.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_id_and_reference.yaml @@ -10,8 +10,9 @@ # Red Hat, Inc. - initial API and implementation # -specVersion: 0.0.1 -name: terminal-sample +apiVersion: 1.0.0 +metadata: + name: terminal-sample components: - type: cheEditor reference: https://gist.githubusercontent.com/sleshchenko/e132bd9d37e8cf8f2c0a2b4929ecda3e/raw/9c28962cc3a24dcaf357b5716d98068734f51165/meta.yaml diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_indistinctive_field.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_indistinctive_field.yaml index f178a87e73..3b2938a131 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_indistinctive_field.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_indistinctive_field.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - type: cheEditor id: eclipse/theia/0.0.3 diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_missing_id.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_missing_id.yaml index 3a349e3993..8de03bccfd 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_missing_id.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_missing_id.yaml @@ -11,7 +11,8 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - type: cheEditor diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_multiple_colons_in_id.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_multiple_colons_in_id.yaml index 6b90b2954c..d9337f2128 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_multiple_colons_in_id.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_multiple_colons_in_id.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - type: cheEditor id: eclipse/theia/dev:v1 diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_registry_in_id.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_registry_in_id.yaml index f8f2aefd0e..07c2e4383b 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_registry_in_id.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_with_registry_in_id.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - type: cheEditor id: https://myregistry.com/eclipse/theia/dev:v1 diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_without_version.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_without_version.yaml index f8a1c9f318..5ff2b3ad8e 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_without_version.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_component_without_version.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - type: cheEditor id: eclipse/theia diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_plugins.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_plugins.yaml index 297fe359e1..e3f373fdbd 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_plugins.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_plugins.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment projects: - name: petclinic source: diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_plugins_components_with_invalid_memory_limit.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_plugins_components_with_invalid_memory_limit.yaml index cb4ec04d1a..4d915f2bd5 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_plugins_components_with_invalid_memory_limit.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_plugins_components_with_invalid_memory_limit.yaml @@ -10,8 +10,9 @@ # Red Hat, Inc. - initial API and implementation # -specVersion: 0.0.1 -name: terminal-sample +apiVersion: 1.0.0 +metadata: + name: terminal-sample components: - type: chePlugin id: publisher/terminal-sample/0.0.1 diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_plugins_components_with_memory_limit.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_plugins_components_with_memory_limit.yaml index 759ce4a5d8..f816d9e662 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_plugins_components_with_memory_limit.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_editor_plugins_components_with_memory_limit.yaml @@ -10,8 +10,9 @@ # Red Hat, Inc. - initial API and implementation # -specVersion: 0.0.1 -name: terminal-sample +apiVersion: 1.0.0 +metadata: + name: terminal-sample components: - type: chePlugin id: check/terminal-sample/0.0.1 diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_plugin_component_with_reference.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_plugin_component_with_reference.yaml index 663779bf34..6a509b5046 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_plugin_component_with_reference.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_plugin_component_with_reference.yaml @@ -10,8 +10,9 @@ # Red Hat, Inc. - initial API and implementation # -specVersion: 0.0.1 -name: terminal-sample +apiVersion: 1.0.0 +metadata: + name: terminal-sample components: - type: chePlugin - reference: https://raw.githubusercontent.com/eclipse/che-plugin-registry/myplugin/meta.yaml \ No newline at end of file + reference: https://raw.githubusercontent.com/eclipse/che-plugin-registry/myplugin/meta.yaml diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_plugin_components_with_preferences.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_plugin_components_with_preferences.yaml index 7f8d2579f1..a43b91b214 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_plugin_components_with_preferences.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/editor_plugin_component/devfile_plugin_components_with_preferences.yaml @@ -10,8 +10,9 @@ # Red Hat, Inc. - initial API and implementation # -specVersion: 0.0.1 -name: terminal-sample +apiVersion: 1.0.0 +metadata: + name: terminal-sample components: - type: chePlugin id: check/terminal-sample/0.0.1 diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_kubernetes_component_absolute_reference.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_kubernetes_component_absolute_reference.yaml index eb1b6be12c..9e5676ff30 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_kubernetes_component_absolute_reference.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_kubernetes_component_absolute_reference.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - alias: mysql type: kubernetes diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_kubernetes_component_content_without_reference.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_kubernetes_component_content_without_reference.yaml index 445a6ec872..fdd96e6348 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_kubernetes_component_content_without_reference.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_kubernetes_component_content_without_reference.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - alias: mysql type: kubernetes diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_kubernetes_component_reference.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_kubernetes_component_reference.yaml index bb0ceda869..6fb4fdb81f 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_kubernetes_component_reference.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_kubernetes_component_reference.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - alias: mysql type: kubernetes diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_kubernetes_component_reference_and_content_as_block.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_kubernetes_component_reference_and_content_as_block.yaml index 1de872d35e..62e0511da2 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_kubernetes_component_reference_and_content_as_block.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_kubernetes_component_reference_and_content_as_block.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - type: kubernetes reference: petclinic.yaml diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_openshift_component.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_openshift_component.yaml index 84f1a42afd..396916d9aa 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_openshift_component.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_openshift_component.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - alias: mysql type: openshift diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_openshift_component_content_without_reference.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_openshift_component_content_without_reference.yaml index 4678537547..c4db2ee0da 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_openshift_component_content_without_reference.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_openshift_component_content_without_reference.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - alias: mysql type: openshift diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_openshift_component_reference_and_content.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_openshift_component_reference_and_content.yaml index e14d0586d3..0129a1fbbe 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_openshift_component_reference_and_content.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_openshift_component_reference_and_content.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - type: openshift referenceContent: it is supposed to be a content of the file specified in the local field diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_openshift_component_reference_and_content_as_block.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_openshift_component_reference_and_content_as_block.yaml index 3527513f35..a5cf206ae7 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_openshift_component_reference_and_content_as_block.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_openshift_component_reference_and_content_as_block.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - type: openshift referenceContent: | diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_openshift_component_with_indistinctive_field_id.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_openshift_component_with_indistinctive_field_id.yaml index b0cd178a7f..7b06b46bb4 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_openshift_component_with_indistinctive_field_id.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_openshift_component_with_indistinctive_field_id.yaml @@ -11,8 +11,9 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - alias: mysql type: openshift diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_openshift_component_with_missing_reference_and_referenceContent.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_openshift_component_with_missing_reference_and_referenceContent.yaml index 2aa29ebe4b..8600119af9 100644 --- a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_openshift_component_with_missing_reference_and_referenceContent.yaml +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/kubernetes_openshift_component/devfile_openshift_component_with_missing_reference_and_referenceContent.yaml @@ -11,7 +11,8 @@ # --- -specVersion: 0.0.1 -name: petclinic-dev-environment +apiVersion: 1.0.0 +metadata: + name: petclinic-dev-environment components: - type: openshift diff --git a/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC2.0/1__devfile_metadata.sql b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC2.0/1__devfile_metadata.sql new file mode 100644 index 0000000000..524971fb40 --- /dev/null +++ b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC2.0/1__devfile_metadata.sql @@ -0,0 +1,14 @@ +-- +-- Copyright (c) 2012-2019 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 +-- + +ALTER TABLE devfile RENAME COLUMN spec_version TO api_version; +ALTER TABLE devfile RENAME COLUMN name TO meta_name; diff --git a/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC2.0/mysql/1__devfile_metadata.sql b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC2.0/mysql/1__devfile_metadata.sql new file mode 100644 index 0000000000..043fa73136 --- /dev/null +++ b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.0.0-beta8.0-RC2.0/mysql/1__devfile_metadata.sql @@ -0,0 +1,14 @@ +-- +-- Copyright (c) 2012-2019 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 +-- + +ALTER TABLE devfile CHANGE spec_version api_version VARCHAR(255) NOT NULL; +ALTER TABLE devfile CHANGE name meta_name VARCHAR(255) NOT NULL; 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 f31f8c3b98..403f41f00b 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 @@ -23,6 +23,7 @@ import java.util.Map; import org.eclipse.che.account.shared.model.Account; import org.eclipse.che.account.spi.AccountImpl; import org.eclipse.che.api.core.model.workspace.WorkspaceStatus; +import org.eclipse.che.api.core.model.workspace.devfile.Metadata; import org.eclipse.che.api.core.model.workspace.runtime.MachineStatus; import org.eclipse.che.api.core.model.workspace.runtime.ServerStatus; import org.eclipse.che.api.ssh.server.model.impl.SshPairImpl; @@ -43,6 +44,7 @@ import org.eclipse.che.api.workspace.server.model.impl.devfile.ActionImpl; 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.model.impl.devfile.EntrypointImpl; +import org.eclipse.che.api.workspace.server.model.impl.devfile.MetadataImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl; import org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl; import org.eclipse.che.api.workspace.server.model.impl.stack.StackComponentImpl; @@ -102,12 +104,12 @@ public final class TestObjectsFactory { public static DevfileImpl createDevfile(String id) { return new DevfileImpl( "0.0.1", - id + "name", asList(createDevfileProject(id + "-project1"), createDevfileProject(id + "-project2")), asList( createDevfileComponent(id + "-component1"), createDevfileComponent(id + "-component2")), asList(createDevfileCommand(id + "-command1"), createDevfileCommand(id + "-command2")), - singletonMap("attribute1", "value1")); + singletonMap("attribute1", "value1"), + createMetadata(id + "name")); } private static ComponentImpl createDevfileComponent(String name) { @@ -263,5 +265,9 @@ public final class TestObjectsFactory { ImmutableMap.of("key", "value")))); } + public static Metadata createMetadata(String name) { + return new MetadataImpl(name); + } + private TestObjectsFactory() {} }