Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: introduce devfile version 2 #1

Merged
merged 12 commits into from
Oct 26, 2021
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Thumbs.db

vendor/
*.db
.vscode/

# ignore default binary name generated with Makefile
golang-echo-realworld-example-app
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"golang.go"
]
}
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
"version": "0.2.0",
"configurations": [
{
"name": "Debug current file",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}"
}
]
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need these settings ?
it's not brought automatically by the plug-in definition ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the file

"go.lintTool": "golangci-lint",
"go.lintFlags": "--fast",
"go.useLanguageServer": true
}
98 changes: 98 additions & 0 deletions devfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
schemaVersion: 2.1.0
metadata:
name: golang-echo-example
projects:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we have two projects being checkout there ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok but with devfile v2 we really want to emphasis the devfile being inside the project and not being cross-project

so either we merge two examples in one repository or we create one devfile per repository. It means 'two samples'

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Splited the devfile to separate projects

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to create one devfile per repository and in go/meta.yaml use only https://github.com/che-samples/golang-echo-example/tree/devfilev2 as Getting Started sample.
@benoitf wdyt?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine

- git:
checkoutFrom:
revision: devfile2
remotes:
origin: "https://github.com/che-samples/golang-example.git"
name: golang-example
- git:
checkoutFrom:
revision: devfile2
remotes:
origin: "https://github.com/che-samples/golang-echo-example.git"
name: golang-echo-example
components:
- name: go-cli
container:
# this version is used in the plugin
image: quay.io/devfile/universal-developer-image:ubi8-b452131
env:
- name: GOPATH
# replicate the GOPATH from the plugin
value: /projects
- name: GOCACHE
# replicate the GOCACHE from the plugin, even though the cache is not shared
# between the two
value: /tmp/.cache
endpoints:
- name: 8080-tcp
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small remark, maybe it's better to change the name as well: 8585-tcp

targetPort: 27017
memoryLimit: 2Gi
mountSources: true
commands:
- id: run-outyet
exec:
label: "1.1 Run outyet"
component: go-cli
workingDir: ${PROJECTS_ROOT}/golang-example/outyet
commandLine: "go get -d && go run main.go"
group:
kind: run
- id: stop
exec:
label: "1.2 Stop outyet"
component: go-cli
commandLine: "kill $(pidof go)"
group:
kind: run
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be removed as well no ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command works for both projects

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but look at the name of the command (label)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right, renamed the command

- id: test-outyet
exec:
label: "1.3 Test outyet"
component: go-cli
workingDir: ${PROJECTS_ROOT}/golang-example/outyet
commandLine: "go test"
group:
kind: test
- id: dependencies
exec:
label: "2.1 xenisa :: install dependencies"
component: go-cli
workingDir: ${PROJECTS_ROOT}/golang-echo-example
commandLine: "go mod download"
group:
kind: build
- id: run
exec:
label: "2.2 xenisa :: run"
component: go-cli
workingDir: ${PROJECTS_ROOT}/golang-echo-example
commandLine: "go run main.go"
group:
kind: run
- id: build
exec:
label: "2.3 xenisa :: build"
component: go-cli
workingDir: ${PROJECTS_ROOT}/golang-echo-example
commandLine: "go build"
group:
kind: build
- id: test
exec:
label: "2.4 xenisa :: test"
component: go-cli
workingDir: ${PROJECTS_ROOT}/golang-echo-example
commandLine: "go test ./..."
group:
kind: test
- id: file
exec:
label: "Run current file"
component: go-cli
workingDir: ${fileDirname}
commandLine: "go get -d && go run ${file}"
group:
kind: run