Converts v1 devfiles to v2 (#3279)

* Converts v1 devfiles to v2

* Moves init tests to devfilesV1 folder
This commit is contained in:
Mrinal Das
2020-06-15 13:41:46 +05:30
committed by GitHub
parent 6cbe763c6b
commit 3154f6010d
15 changed files with 263 additions and 368 deletions

View File

@@ -1,28 +1,30 @@
apiVersion: 1.0.0
schemaVersion: 2.0.0
metadata:
name: test-devfile
projects:
-
name: nodejs-web-app
source:
type: git
- name: nodejs-web-app
git:
location: "https://github.com/che-samples/web-nodejs-sample.git"
components:
- type: dockerimage
image: quay.io/eclipse/che-nodejs10-ubi:nightly
alias: runtime
memoryLimit: 1024Mi
mountSources: true
- container:
name: runtime
image: quay.io/eclipse/che-nodejs10-ubi:nightly
memoryLimit: 1024Mi
mountSources: true
commands:
- name: devbuild
actions:
- type: exec
component: runtime
command: "npm install"
workdir: ${CHE_PROJECTS_ROOT}/nodejs-web-app/app
- name: devrun
actions:
- type: exec
component: runtime
command: "nodemon app.js"
workdir: ${CHE_PROJECTS_ROOT}/nodejs-web-app/app
- exec:
id: devbuild
component: runtime
commandLine: "npm install"
workingDir: ${CHE_PROJECTS_ROOT}/nodejs-web-app/app
group:
kind: build
isDefault: true
- exec:
id: devrun
component: runtime
commandLine: "nodemon app.js"
workingDir: ${CHE_PROJECTS_ROOT}/nodejs-web-app/app
group:
kind: run
isDefault: true

View File

@@ -1,30 +1,32 @@
apiVersion: 1.0.0
schemaVersion: 2.0.0
metadata:
name: test-devfile
projects:
-
name: nodejs-web-app
source:
type: git
- name: nodejs-web-app
git:
location: "https://github.com/che-samples/web-nodejs-sample.git"
components:
- type: dockerimage
image: quay.io/eclipse/che-nodejs10-ubi:nightly
alias: runtime
memoryLimit: 1024Mi
mountSources: true
- container:
name: runtime
image: quay.io/eclipse/che-nodejs10-ubi:nightly
memoryLimit: 1024Mi
mountSources: true
commands:
- name: devbuild
actions:
- type: exec
component: runtime
command: "npm install"
workdir: ${CHE_PROJECTS_ROOT}/nodejs-web-app/app
- name: devrun
attributes:
- exec:
id: devbuild
component: runtime
commandLine: "npm install"
workingDir: ${CHE_PROJECTS_ROOT}/nodejs-web-app/app
group:
kind: build
isDefault: true
- exec:
id: devrun
attributes:
restart: "false"
actions:
- type: exec
component: runtime
command: "nodemon app.js"
workdir: ${CHE_PROJECTS_ROOT}/nodejs-web-app/app
component: runtime
commandLine: "nodemon app.js"
workingDir: ${CHE_PROJECTS_ROOT}/nodejs-web-app/app
group:
kind: run
isDefault: true

View File

@@ -1,53 +1,52 @@
apiVersion: 1.0.0
schemaVersion: 2.0.0
metadata:
name: test-devfile
projects:
-
name: nodejs-web-app
source:
type: git
- name: nodejs-web-app
git:
location: "https://github.com/che-samples/web-nodejs-sample.git"
components:
- type: dockerimage
image: quay.io/eclipse/che-nodejs10-ubi:nightly
endpoints:
- name: "3000/tcp"
port: 3000
alias: runtime
env:
- name: FOO
value: "bar"
memoryLimit: 1024Mi
mountSources: true
volumes:
- name: myvol
containerPath: /data
- type: dockerimage
image: quay.io/eclipse/che-nodejs10-ubi:nightly
alias: runtime2
memoryLimit: 1024Mi
mountSources: false
volumes:
- name: myvol
containerPath: /data
- name: myvol2
containerPath: /data2
- container:
name: runtime
image: quay.io/eclipse/che-nodejs10-ubi:nightly
memoryLimit: 1024Mi
env:
- name: FOO
value: "bar"
endpoints:
- name: "3000/tcp"
configuration:
protocol: tcp
scheme: http
targetPort: 3000
mountSources: true
volumeMounts:
- name: myvol
path: /data
- container:
name: runtime2
image: quay.io/eclipse/che-nodejs10-ubi:nightly
memoryLimit: 1024Mi
mountSources: false
volumeMounts:
- name: myvol
path: /data
- name: myvol2
path: /data2
commands:
- name: devInit
actions:
- type: exec
component: runtime
command: "echo init >> myfile-init.log"
workdir: /data
- name: devBuild
actions:
- type: exec
component: runtime
command: "echo hello >> myfile.log"
workdir: /data
- name: devRun
actions:
- type: exec
component: runtime2
command: "cat myfile.log"
workdir: /data
- exec:
id: devbuild
component: runtime
commandLine: "echo hello >> myfile.log"
workingDir: /data
group:
kind: build
isDefault: true
- exec:
id: devrun
component: runtime2
commandLine: "cat myfile.log"
workingDir: /data
group:
kind: run
isDefault: true

View File

@@ -1,28 +1,31 @@
apiVersion: 1.0.0
schemaVersion: 2.0.0
metadata:
name: test-devfile
projects:
-
name: nodejs-web-app
source:
type: git
- name: nodejs-web-app
git:
location: "https://github.com/che-samples/web-nodejs-sample.git"
components:
- type: dockerimage
image: quay.io/eclipse/che-nodejs10-ubi:nightly
endpoints:
- name: "3000/tcp"
port: 3000
alias: runtime
env:
- name: FOO
value: "bar"
memoryLimit: 1024Mi
mountSources: true
- container:
name: runtime
image: quay.io/eclipse/che-nodejs10-ubi:nightly
memoryLimit: 1024Mi
env:
- name: FOO
value: "bar"
endpoints:
- name: "3000/tcp"
configuration:
protocol: tcp
scheme: http
targetPort: 3000
mountSources: true
commands:
- name: devrun
actions:
- type: exec
component: runtime
command: "npm install && nodemon app.js"
workdir: ${CHE_PROJECTS_ROOT}/nodejs-web-app/app
- exec:
id: devrun
component: runtime
commandLine: "npm install && nodemon app.js"
workingDir: ${CHE_PROJECTS_ROOT}/nodejs-web-app/app
group:
kind: run
isDefault: true

View File

@@ -1,34 +1,39 @@
apiVersion: 1.0.0
schemaVersion: 2.0.0
metadata:
name: test-devfile
projects:
-
name: nodejs-web-app
source:
type: git
- name: nodejs-web-app
git:
location: "https://github.com/che-samples/web-nodejs-sample.git"
components:
- type: dockerimage
image: quay.io/eclipse/che-nodejs10-ubi:nightly
endpoints:
- name: "3000/tcp"
port: 3000
alias: runtime
env:
- name: FOO
value: "bar"
memoryLimit: 1024Mi
mountSources: true
- container:
name: runtime
image: quay.io/eclipse/che-nodejs10-ubi:nightly
memoryLimit: 1024Mi
env:
- name: FOO
value: "bar"
endpoints:
- name: "3000/tcp"
configuration:
protocol: tcp
scheme: http
targetPort: 3000
mountSources: true
commands:
- name: devbuild
actions:
- type: exec
component: runtime
command: "npm install"
workdir: ${CHE_PROJECTS_ROOT}/nodejs-web-app/app
- name: devrun
actions:
- type: exec
component: runtime
command: "nodemon app.js"
workdir: ${CHE_PROJECTS_ROOT}/nodejs-web-app/app
- exec:
id: devbuild
component: runtime
commandLine: "npm install"
workingDir: ${CHE_PROJECTS_ROOT}/nodejs-web-app/app
group:
kind: build
isDefault: true
- exec:
id: devrun
component: runtime
commandLine: "nodemon app.js"
workingDir: ${CHE_PROJECTS_ROOT}/nodejs-web-app/app
group:
kind: run
isDefault: true

View File

@@ -1,46 +1,50 @@
apiVersion: 1.0.0
schemaVersion: 2.0.0
metadata:
name: test-devfile
projects:
-
name: nodejs-web-app
source:
type: git
- name: nodejs-web-app
git:
location: "https://github.com/che-samples/web-nodejs-sample.git"
components:
- type: dockerimage
image: quay.io/eclipse/che-nodejs10-ubi:nightly
endpoints:
- name: "3000/tcp"
port: 3000
alias: runtime
env:
- name: FOO
value: "bar"
memoryLimit: 1024Mi
mountSources: true
- container:
name: runtime
image: quay.io/eclipse/che-nodejs10-ubi:nightly
memoryLimit: 1024Mi
endpoints:
- name: "3000/tcp"
configuration:
protocol: tcp
scheme: http
targetPort: 3000
mountSources: true
commands:
- name: build
actions:
- type: exec
component: runtime
command: "npm install"
workdir: ${CHE_PROJECTS_ROOT}/nodejs-web-app/app
- name: devbuild
actions:
- type: exec
component: runtime
command: "npm install"
workdir: ${CHE_PROJECTS_ROOT}/nodejs-web-app/app
- name: run
actions:
- type: exec
component: runtime
command: "nodemon app.js"
workdir: ${CHE_PROJECTS_ROOT}/nodejs-web-app/app
- name: devrun
actions:
- type: exec
component: runtime
command: "nodemon app.js"
workdir: ${CHE_PROJECTS_ROOT}/nodejs-web-app/app
- exec:
id: devbuild
component: runtime
commandLine: "npm install"
workingDir: ${CHE_PROJECTS_ROOT}/nodejs-web-app/app
group:
kind: build
isDefault: true
- exec:
id: build
component: runtime
commandLine: "npm install"
workingDir: ${CHE_PROJECTS_ROOT}/nodejs-web-app/app
group:
kind: build
- exec:
id: devrun
component: runtime
commandLine: "nodemon app.js"
workingDir: ${CHE_PROJECTS_ROOT}/nodejs-web-app/app
group:
kind: run
isDefault: true
- exec:
id: run
component: runtime
commandLine: "nodemon app.js"
workingDir: ${CHE_PROJECTS_ROOT}/nodejs-web-app/app
group:
kind: run

View File

@@ -1,55 +1,52 @@
---
apiVersion: 1.0.0
schemaVersion: 2.0.0
metadata:
generateName: java-spring-boot
name: java-spring-boot
projects:
-
name: springbootproject
source:
type: git
- name: springbootproject
git:
location: "https://github.com/maysunfaisal/springboot.git"
components:
-
type: chePlugin
id: redhat/java/latest
memoryLimit: 1512Mi
-
type: dockerimage
image: maysunfaisal/springbootbuild
alias: tools
memoryLimit: 768Mi
command: ['tail']
args: [ '-f', '/dev/null']
mountSources: true
volumes:
- name: springbootpvc
containerPath: /data
-
type: dockerimage
image: maysunfaisal/springbootruntime
alias: runtime
memoryLimit: 768Mi
endpoints:
- name: '8080/tcp'
port: 8080
mountSources: false
volumes:
- name: springbootpvc
containerPath: /data
- container:
name: tools
image: maysunfaisal/springbootbuild
memoryLimit: 768Mi
command: ['tail']
args: [ '-f', '/dev/null']
volumeMounts:
- name: springbootpvc
path: /data
mountSources: true
- container:
name: runtime
image: maysunfaisal/springbootruntime
memoryLimit: 768Mi
command: ['tail']
args: [ '-f', '/dev/null']
endpoints:
- name: "8080/tcp"
configuration:
protocol: tcp
scheme: http
targetPort: 8080
volumeMounts:
- name: springbootpvc
path: /data
mountSources: false
commands:
-
name: devBuild
actions:
-
type: exec
component: tools
command: "/artifacts/bin/build-container-full.sh"
workdir: /projects/springbootproject
-
name: devRun
actions:
-
type: exec
component: runtime
command: "/artifacts/bin/start-server.sh"
workdir: /
- exec:
id: devbuild
component: tools
commandLine: "/artifacts/bin/build-container-full.sh"
workingDir: /projects/springbootproject
group:
kind: build
isDefault: true
- exec:
id: devrun
component: runtime
commandLine: "/artifacts/bin/start-server.sh"
workingDir: /
group:
kind: run
isDefault: true

View File

@@ -3,18 +3,15 @@ apiVersion: 1.0.0
metadata:
generateName: java-spring-boot
projects:
-
name: springbootproject
- name: springbootproject
source:
type: git
location: "https://github.com/maysunfaisal/springboot.git"
components:
-
type: chePlugin
- type: chePlugin
id: redhat/java/latest
memoryLimit: 1512Mi
-
type: dockerimage
- type: dockerimage
image: maysunfaisal/springbootbuild
alias: tools
memoryLimit: 768Mi
@@ -24,8 +21,7 @@ components:
volumes:
- name: springbootpvc
containerPath: /data
-
type: dockerimage
- type: dockerimage
image: maysunfaisal/springbootruntime
alias: runtime
memoryLimit: 768Mi
@@ -37,19 +33,15 @@ components:
- name: springbootpvc
containerPath: /data
commands:
-
name: devInit
- name: devInit
actions:
-
type: exec
- type: exec
component: tools
command: "echo hello; touch /data/afile.txt"
workdir: /projects/springbootproject
-
name: devRun
- name: devRun
actions:
-
type: exec
- type: exec
component: runtime
command: "/artifacts/bin/start-server.sh"
workdir: /
workdir: /

View File

@@ -37,10 +37,10 @@ components:
- name: springbootpvc
containerPath: /data
commands:
-
-
name: devinit
actions:
-
-
type: exec
component: tools
command: "echo hello"
@@ -60,4 +60,4 @@ commands:
type: exec
component: runtime
command: "/artifacts/bin/start-server.sh"
workdir: /
workdir: /

View File

@@ -1,39 +0,0 @@
schemaVersion: "2.0.0"
metadata:
name: test-devfile
projects:
- name: nodejs-web-app
git:
location: "https://github.com/che-samples/web-nodejs-sample.git"
components:
- container:
image: quay.io/eclipse/che-nodejs10-ubi:nightly
mountSources: true
name: "runtime"
memoryLimit: 1024Mi
env:
- name: FOO
value: "bar"
endpoints:
- name: '3000/tcp'
targetPort: 3000
# odo not using currently, added to validate JSON Schema
configuration:
protocol: tcp
scheme: http
type: terminal
commands:
- exec:
id: download dependencies
commandLine: "npm install"
component: runtime
workingDir: ${CHE_PROJECTS_ROOT}/nodejs-web-app/app
group:
kind: build
- exec:
id: run the app
commandLine: "nodemon app.js"
component: runtime
workingDir: ${CHE_PROJECTS_ROOT}/nodejs-web-app/app
group:
kind: run

View File

@@ -1,56 +0,0 @@
schemaVersion: 2.0.0
metadata:
name: java-spring-boot
version: 1.0.0
projects:
- name: springbootproject
git:
location: "https://github.com/odo-devfiles/springboot-ex.git"
components:
- chePlugin:
id: redhat/java/latest
memoryLimit: 1512Mi
- container:
name: tools
image: maysunfaisal/springbootbuild
memoryLimit: 768Mi
command: ['tail']
args: [ '-f', '/dev/null']
mountSources: true
volumeMounts:
- name: springbootpvc
path: /data
- container:
name: runtime
image: maysunfaisal/springbootruntime
memoryLimit: 768Mi
command: ['tail']
args: [ '-f', '/dev/null']
endpoints:
- name: '8080/tcp'
targetPort: 8080
configuration:
discoverable: false
public: true
protocol: http
mountSources: false
volumeMounts:
- name: springbootpvc
path: /data
commands:
- exec:
id: devBuild
component: tools
commandLine: "/artifacts/bin/build-container-full.sh"
workingDir: /projects/springbootproject
group:
kind: build
isDefault: true
- exec:
id: devRun
component: runtime
commandLine: "/artifacts/bin/start-server.sh"
workingDir: /
group:
kind: run
isDefault: true

View File

@@ -107,7 +107,7 @@ func ReplaceString(filename string, oldString string, newString string) {
f, err := ioutil.ReadFile(filename)
Expect(err).NotTo(HaveOccurred())
newContent := strings.Replace(string(f), oldString, newString, 1)
newContent := strings.ReplaceAll(string(f), oldString, newString)
err = ioutil.WriteFile(filename, []byte(newContent), 0600)
Expect(err).NotTo(HaveOccurred())

View File

@@ -191,7 +191,7 @@ var _ = Describe("odo devfile push command tests", func() {
helper.CmdShouldPass("odo", "create", "java-spring-boot", "--project", namespace, cmpName)
helper.CopyExample(filepath.Join("source", "devfiles", "springboot", "project"), context)
helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "springboot", "devfile-init.yaml"), filepath.Join(context, "devfile.yaml"))
helper.CopyExampleDevFile(filepath.Join("source", "devfilesV1", "springboot", "devfile-init.yaml"), filepath.Join(context, "devfile.yaml"))
output := helper.CmdShouldPass("odo", "push", "--namespace", namespace)
helper.MatchAllInOutput(output, []string{
@@ -205,7 +205,7 @@ var _ = Describe("odo devfile push command tests", func() {
helper.CmdShouldPass("odo", "create", "java-spring-boot", "--project", namespace, cmpName)
helper.CopyExample(filepath.Join("source", "devfiles", "springboot", "project"), context)
helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "springboot", "devfile-init-without-build.yaml"), filepath.Join(context, "devfile.yaml"))
helper.CopyExampleDevFile(filepath.Join("source", "devfilesV1", "springboot", "devfile-init-without-build.yaml"), filepath.Join(context, "devfile.yaml"))
output := helper.CmdShouldPass("odo", "push", "--namespace", namespace)
helper.MatchAllInOutput(output, []string{
@@ -218,7 +218,7 @@ var _ = Describe("odo devfile push command tests", func() {
helper.CmdShouldPass("odo", "create", "java-spring-boot", "--project", namespace, cmpName)
helper.CopyExample(filepath.Join("source", "devfiles", "springboot", "project"), context)
helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "springboot", "devfile-init.yaml"), filepath.Join(context, "devfile.yaml"))
helper.CopyExampleDevFile(filepath.Join("source", "devfilesV1", "springboot", "devfile-init.yaml"), filepath.Join(context, "devfile.yaml"))
output := helper.CmdShouldPass("odo", "push", "--namespace", namespace)
helper.MatchAllInOutput(output, []string{
@@ -278,7 +278,6 @@ var _ = Describe("odo devfile push command tests", func() {
output := helper.CmdShouldPass("odo", "push", "--namespace", namespace)
helper.MatchAllInOutput(output, []string{
"Executing devinit command",
"Executing devbuild command",
"Executing devrun command",
})
@@ -288,19 +287,6 @@ var _ = Describe("odo devfile push command tests", func() {
var statErr error
var cmdOutput string
cliRunner.CheckCmdOpInRemoteDevfilePod(
podName,
"runtime",
namespace,
[]string{"cat", "/data/myfile-init.log"},
func(cmdOp string, err error) bool {
cmdOutput = cmdOp
statErr = err
return true
},
)
Expect(statErr).ToNot(HaveOccurred())
Expect(cmdOutput).To(ContainSubstring("init"))
cliRunner.CheckCmdOpInRemoteDevfilePod(
podName,

View File

@@ -153,7 +153,7 @@ var _ = Describe("odo docker devfile push command tests", func() {
helper.CmdShouldPass("odo", "create", "java-spring-boot", cmpName)
helper.CopyExample(filepath.Join("source", "devfiles", "springboot", "project"), context)
helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "springboot", "devfile-init.yaml"), filepath.Join(context, "devfile.yaml"))
helper.CopyExampleDevFile(filepath.Join("source", "devfilesV1", "springboot", "devfile-init.yaml"), filepath.Join(context, "devfile.yaml"))
output := helper.CmdShouldPass("odo", "push")
helper.MatchAllInOutput(output, []string{
@@ -174,7 +174,7 @@ var _ = Describe("odo docker devfile push command tests", func() {
helper.CmdShouldPass("odo", "create", "java-spring-boot", cmpName)
helper.CopyExample(filepath.Join("source", "devfiles", "springboot", "project"), context)
helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "springboot", "devfile-init-without-build.yaml"), filepath.Join(context, "devfile.yaml"))
helper.CopyExampleDevFile(filepath.Join("source", "devfilesV1", "springboot", "devfile-init-without-build.yaml"), filepath.Join(context, "devfile.yaml"))
output := helper.CmdShouldPass("odo", "push")
helper.MatchAllInOutput(output, []string{

View File

@@ -64,8 +64,8 @@ func ExecWithMissingRunCommand(projectDirPath, cmpName, namespace string) {
helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), projectDirPath)
helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile.yaml"), filepath.Join(projectDirPath, "devfile.yaml"))
// Rename the devrun command
helper.ReplaceString(filepath.Join(projectDirPath, "devfile.yaml"), "devrun", "randomcommand")
// Remove the run commands
helper.ReplaceString(filepath.Join(projectDirPath, "devfile.yaml"), "kind: run", "kind: debug")
args = []string{"push"}
args = useProjectIfAvailable(args, namespace)