diff --git a/devfile-support/samples/custom-devfile.yaml b/devfile-support/samples/custom-devfile.yaml index 869b38603..e982121cb 100644 --- a/devfile-support/samples/custom-devfile.yaml +++ b/devfile-support/samples/custom-devfile.yaml @@ -1,5 +1,6 @@ -name: "my-devfile" schemaVersion: "2.0.0-beta" +metadata: + name: "my-devfile" projects: - name: "my-project" custom: diff --git a/devfile-support/samples/nodejs-stack.devfile.yaml b/devfile-support/samples/nodejs-stack.devfile.yaml index bef5b8eb9..ffe2fd178 100644 --- a/devfile-support/samples/nodejs-stack.devfile.yaml +++ b/devfile-support/samples/nodejs-stack.devfile.yaml @@ -1,5 +1,6 @@ schemaVersion: 2.0.0 -name: nodejs-stack +metadata: + name: nodejs-stack projects: - name: project git: diff --git a/devfile-support/samples/petclinic-devfile.yaml b/devfile-support/samples/petclinic-devfile.yaml new file mode 100644 index 000000000..615a24f2a --- /dev/null +++ b/devfile-support/samples/petclinic-devfile.yaml @@ -0,0 +1,60 @@ +schemaVersion: 2.0.0 +metadata: + name: petclinic-dev-environment +projects: + - name: petclinic + source: + type: git + location: 'git@github.com:spring-projects/spring-petclinic.git' +components: + - alias: mvn-stack + type: dockerimage + image: maven:3.5.4-jdk-8 + command: ['/bin/sh', '-c'] + args: ['tail -f /dev/null'] + volumes: + - name: maven-repo + containerPath: /root/.m2 + endpoints: + - name: spring-boot + port: 8080 + attributes: + path: /api + protocol: http + public: true + env: + - name: TERM + value: xterm + mountSources: true + memoryLimit: 500M + - alias: mysql + type: kubernetes + reference: petclinic.yaml + selector: + app.kubernetes.io/name: mysql + app.kubernetes.io/component: database + app.kubernetes.io/part-of: petclinic + - alias: theia-ide + type: cheEditor + id: eclipse/theia:0.0.3 + - alias: jdt.ls + type: chePlugin + id: eclipse/theia-jdtls:0.0.3 +commands: + - name: build + actions: + - type: exec + component: mvn-stack + command: mvn package + workdir: /projects/spring-petclinic + - name: run + attributes: + runType: sequential + actions: + - type: start + component: mysql + timeout: 20s + - type: exec + component: mvn-stack + command: mvn spring-boot:run + workdir: /projects/spring-petclinic \ No newline at end of file diff --git a/devfile-support/samples/sample-devfile.yaml b/devfile-support/samples/sample-devfile.yaml index e177b6482..fc401da2f 100644 --- a/devfile-support/samples/sample-devfile.yaml +++ b/devfile-support/samples/sample-devfile.yaml @@ -1,5 +1,6 @@ -name: "devfile example" schemaVersion: "2.0.0" +metadata: + name: "devfile example" projects: - name: "my-project" custom: diff --git a/devfile-support/samples/simple-devfile.yaml b/devfile-support/samples/simple-devfile.yaml index 548d1c523..fcdb088f5 100644 --- a/devfile-support/samples/simple-devfile.yaml +++ b/devfile-support/samples/simple-devfile.yaml @@ -1,5 +1,6 @@ -name: "myDevile" schemaVersion: "2.0.0" +metadata: + name: "myDevile" projects: - name: "devworkspace-spec" git: diff --git a/devfile-support/samples/with-nodejs-parent.devfile.yaml b/devfile-support/samples/with-nodejs-parent.devfile.yaml index f7344d656..d89211b3c 100644 --- a/devfile-support/samples/with-nodejs-parent.devfile.yaml +++ b/devfile-support/samples/with-nodejs-parent.devfile.yaml @@ -1,5 +1,6 @@ -name: with-parent schemaVersion: 2.0.0 +metadata: + name: with-parent parent: uri: https://raw.githubusercontent.com/che-incubator/devworkspace-api/proposal-25-variant-1-define-stacks/devfile-support/samples/nodejs-stack.devfile.yaml commands: diff --git a/devfile-support/transformation-rules/add-name-and-version-metadata.json b/devfile-support/transformation-rules/add-name-and-version-metadata.json new file mode 100644 index 000000000..741fcc00c --- /dev/null +++ b/devfile-support/transformation-rules/add-name-and-version-metadata.json @@ -0,0 +1,17 @@ +[ + { + "op": "add", + "path": "/properties/metadata", + "value": { "type": "object", "description": "Optional metadata", "properties": {} } + }, + { + "op": "add", + "path": "/properties/metadata/properties/version", + "value": { "type": "string", "description": "Optional semver-compatible version", "pattern": "^([1-9]+)\\.([0-9]+)\\.([0-9]+)(\\-[0-9a-z-]+(\\.[0-9a-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$" } + }, + { + "op": "add", + "path": "/properties/metadata/properties/name", + "value": { "type": "string", "description": "Optional devfile name" } + } +] diff --git a/devfile-support/transformation-rules/add-name-and-version.json b/devfile-support/transformation-rules/add-schemaVersion.json similarity index 70% rename from devfile-support/transformation-rules/add-name-and-version.json rename to devfile-support/transformation-rules/add-schemaVersion.json index 0fed2b807..cb724d2f2 100644 --- a/devfile-support/transformation-rules/add-name-and-version.json +++ b/devfile-support/transformation-rules/add-schemaVersion.json @@ -4,11 +4,6 @@ "path": "/description", "value": "Devfile schema." }, - { - "op": "add", - "path": "/properties/name", - "value": { "type": "string", "description": "devfile name" } - }, { "op": "add", "path": "/properties/schemaVersion", @@ -17,6 +12,6 @@ { "op": "add", "path": "/required", - "value": [ "name", "schemaVersion" ] + "value": [ "schemaVersion" ] } ] diff --git a/schemas/devfile.json b/schemas/devfile.json index c71a8a2e2..29aea5e0c 100644 --- a/schemas/devfile.json +++ b/schemas/devfile.json @@ -779,9 +779,20 @@ }, "type": "array" }, - "name": { - "type": "string", - "description": "devfile name" + "metadata": { + "type": "object", + "description": "Optional metadata", + "properties": { + "version": { + "type": "string", + "description": "Optional semver-compatible version", + "pattern": "^([1-9]+)\\.([0-9]+)\\.([0-9]+)(\\-[0-9a-z-]+(\\.[0-9a-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$" + }, + "name": { + "type": "string", + "description": "Optional devfile name" + } + } }, "schemaVersion": { "type": "string", @@ -791,7 +802,6 @@ }, "type": "object", "required": [ - "name", "schemaVersion" ] }