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

Port over odo parser #34

Merged
merged 42 commits into from
Oct 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
9557a63
initial commit to make it work
yangcao77 Sep 29, 2020
e3b41ff
copy over the latest schema and devfile v2
yangcao77 Sep 30, 2020
3b47b88
adopt latest devfile/api
yangcao77 Sep 30, 2020
f175a13
resolve compilcation error due to change of struct
yangcao77 Sep 30, 2020
ddd4e6b
Remove parser hardcode dependency on devfile struct
maysunfaisal Sep 30, 2020
4584c82
get the schema from URL
yangcao77 Oct 1, 2020
f2c2b16
Init json in map init()
maysunfaisal Oct 1, 2020
86ebc57
migrate commponent.go and test from odo
yangcao77 Oct 7, 2020
449585d
add helper functions and tests
yangcao77 Oct 7, 2020
1eed932
convert more files from devfile/parser
yangcao77 Oct 7, 2020
51f9e56
use hard-coded schema, will get from devfile/api later
yangcao77 Oct 7, 2020
4db1d01
integrate more
yangcao77 Oct 9, 2020
46f6471
add configurable.go
yangcao77 Oct 13, 2020
3d01ffe
pull in and integrate the latest devfileHearder change
yangcao77 Oct 14, 2020
1cb47c5
Struct test commit
maysunfaisal Oct 15, 2020
7029a36
Cleanup comments
maysunfaisal Oct 15, 2020
150298f
Fix tests for new struct
maysunfaisal Oct 15, 2020
f7fa688
Merge pull request #1 from maysunfaisal/v2-parser-structure-2
maysunfaisal Oct 15, 2020
db34d9f
Remove new version placeholder test
maysunfaisal Oct 15, 2020
cc6712b
Remove outdated validation code
maysunfaisal Oct 15, 2020
75d8833
add configurable test
yangcao77 Oct 15, 2020
5da803e
cleanup go mod
yangcao77 Oct 15, 2020
f62e977
Update go sum
maysunfaisal Oct 15, 2020
cbc8b6c
separate the function definition for interface into multiple files
yangcao77 Oct 19, 2020
9d1d7bf
Update commands and commands test
maysunfaisal Oct 19, 2020
d8b4188
add unit tests for header.go and parent.go
yangcao77 Oct 20, 2020
b35d762
add unit tests for projects.go
yangcao77 Oct 20, 2020
efe5165
Update tests for events and components
maysunfaisal Oct 20, 2020
29c1c85
Mention supported versions when unable to parse version
maysunfaisal Oct 20, 2020
be28094
address some review comments
yangcao77 Oct 20, 2020
6a97010
Merge branch 'portOverOdoParser' of github.com:yangcao77/parser into …
yangcao77 Oct 20, 2020
3a759b5
add getComponentType method
yangcao77 Oct 20, 2020
36dbff4
remove odo specific function
yangcao77 Oct 20, 2020
4e66634
pull in latest devfiel schema
yangcao77 Oct 20, 2020
bc9fe45
remove some useless functions, update go mod
yangcao77 Oct 20, 2020
b32c383
modify test due to starterproject change in devfile/api
yangcao77 Oct 20, 2020
1b4bb6f
Move common pkg to v2 since its v2 spec schema
maysunfaisal Oct 20, 2020
32cf920
make fs internal filed to be consistent with the others
yangcao77 Oct 20, 2020
ad7d7dd
address review comments
yangcao77 Oct 20, 2020
c2de3d1
address review comments
yangcao77 Oct 21, 2020
3648386
rename fake.go to avoid confusion
yangcao77 Oct 21, 2020
6c0f459
address some review comments
yangcao77 Oct 22, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ main

# Files used for debugging
.vscode/

.DS_Store
106 changes: 48 additions & 58 deletions devfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,53 @@ schemaVersion: 2.0.0
metadata:
name: nodejs
version: 1.0.0
alpha.deployment-manifest: "https://raw.githubusercontent.com/groeges/devfile-registry/master/devfiles/nodejs/deploy_deployment.yaml"
projects:
- name: nodejs-starter
git:
location: "https://github.com/odo-devfiles/nodejs-ex.git"
alpha.build-dockerfile: https://raw.githubusercontent.com/odo-devfiles/registry/master/devfiles/nodejs/build/Dockerfile
alpha.deployment-manifest: https://raw.githubusercontent.com/odo-devfiles/registry/master/devfiles/nodejs/deploy/deployment-manifest.yaml
starterProjects:
- name: nodejs-starter
git:
remotes:
origin: https://github.com/odo-devfiles/nodejs-ex.git
components:
- container:
name: runtime
image: registry.access.redhat.com/ubi8/nodejs-12:1-36
memoryLimit: 1024Mi
mountSources: true
endpoints:
- name: http-3000
targetPort: 3000
configuration:
protocol: tcp
scheme: http
type: terminal

- dockerfile:
name: dockerfile-build
source:
sourceDir: "src"
location: "https://github.com/ranakan19/golang-ex.git"
dockerfileLocation: "https://raw.githubusercontent.com/wtam2018/test/master/nodejs-dockerfiile"
destination: "docker.io"

- name: runtime
container:
endpoints:
- name: http-3000
targetPort: 3000
image: registry.access.redhat.com/ubi8/nodejs-12:1-45
memoryLimit: 1024Mi
mountSources: true
sourceMapping: /project
commands:
- exec:
id: install
component: runtime
commandLine: npm install
workingDir: ${CHE_PROJECTS_ROOT}/nodejs-starter
group:
kind: build
isDefault: true
- exec:
id: run
component: runtime
commandLine: npm start
workingDir: ${CHE_PROJECTS_ROOT}/nodejs-starter
group:
kind: run
isDefault: true
- exec:
id: debug
component: runtime
commandLine: npm run debug
workingDir: ${CHE_PROJECTS_ROOT}/nodejs-starter
group:
kind: debug
isDefault: true
- exec:
id: test
component: runtime
commandLine: npm test
workingDir: ${CHE_PROJECTS_ROOT}/nodejs-starter
group:
kind: test
isDefault: true
- exec:
commandLine: npm install
component: runtime
group:
isDefault: true
kind: build
workingDir: /project
id: install
- exec:
commandLine: npm start
component: runtime
group:
isDefault: true
kind: run
workingDir: /project
id: run
- exec:
commandLine: npm run debug
component: runtime
group:
isDefault: true
kind: debug
workingDir: /project
id: debug
- exec:
commandLine: npm test
component: runtime
group:
isDefault: true
kind: test
workingDir: /project
id: test
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ module github.com/devfile/parser
go 1.14

require (
github.com/devfile/api v0.0.0-20200826170839-778718f72ad7
github.com/devfile/api v0.0.0-20201020083026-77074bac47ab
github.com/fatih/color v1.7.0
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
github.com/gobwas/glob v0.2.3
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348
github.com/mattn/go-colorable v0.1.2 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/pkg/errors v0.9.1
github.com/spf13/afero v1.3.2
github.com/xeipuuv/gojsonschema v1.2.0
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e // indirect
golang.org/x/sys v0.0.0-20200509044756-6aff5f38e54f // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
gopkg.in/yaml.v2 v2.3.0
k8s.io/api v0.18.6
k8s.io/apimachinery v0.18.6
k8s.io/klog v1.0.0
Expand Down
752 changes: 5 additions & 747 deletions go.sum

Large diffs are not rendered by default.

23 changes: 8 additions & 15 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"fmt"
"reflect"

devfilepkg "github.com/devfile/parser/pkg/devfile"
"github.com/devfile/parser/pkg/devfile/parser"
v200 "github.com/devfile/parser/pkg/devfile/parser/data/2.0.0"
v2 "github.com/devfile/parser/pkg/devfile/parser/data/v2"
)

func main() {
Expand All @@ -14,17 +15,12 @@ func main() {
fmt.Println(err)
} else {
devdata := devfile.Data
if (reflect.TypeOf(devdata) == reflect.TypeOf(&v200.Devfile200{})) {
d := devdata.(*v200.Devfile200)
if (reflect.TypeOf(devdata) == reflect.TypeOf(&v2.DevfileV2{})) {
d := devdata.(*v2.DevfileV2)
fmt.Println(d.SchemaVersion)
}

for _, component := range devfile.Data.GetComponents() {
/*
if component.Dockerfile != nil {
fmt.Println(component.Dockerfile.DockerfileLocation)
}
*/
if component.Container != nil {
fmt.Println(component.Container.Image)
}
Expand All @@ -40,11 +36,8 @@ func main() {
}

//ParseDevfile to parse devfile from library
func ParseDevfile(devfileLocation string) (devfileoj parser.DevfileObj, err error) {
/*
var devfile parser.DevfileObj
devfile, err = parser.ParseAndValidate(devfileLocation)
return devfile, err
*/
return
func ParseDevfile(devfileLocation string) (parser.DevfileObj, error) {

devfile, err := devfilepkg.ParseAndValidate(devfileLocation)
return devfile, err
}
58 changes: 58 additions & 0 deletions pkg/devfile/parse.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package devfile

import (
"github.com/devfile/parser/pkg/devfile/parser"
)

// ParseFromURLAndValidate func parses the devfile data from the url
// and validates the devfile integrity with the schema
// and validates the devfile data.
// Creates devfile context and runtime objects.
func ParseFromURLAndValidate(url string) (d parser.DevfileObj, err error) {

// read and parse devfile from the given URL
d, err = parser.ParseFromURL(url)
if err != nil {
return d, err
}

// odo specific validation on devfile content
// err = validate.ValidateDevfileData(d.Data)

return d, err
}

// ParseFromDataAndValidate func parses the devfile data
// and validates the devfile integrity with the schema
// and validates the devfile data.
// Creates devfile context and runtime objects.
func ParseFromDataAndValidate(data []byte) (d parser.DevfileObj, err error) {
// read and parse devfile from the given bytes
d, err = parser.ParseFromData(data)
if err != nil {
return d, err
}

// odo specific validation on devfile content
// err = validate.ValidateDevfileData(d.Data)

return d, err
}

// ParseAndValidate func parses the devfile data
// and validates the devfile integrity with the schema
// and validates the devfile data.
// Creates devfile context and runtime objects.
func ParseAndValidate(path string) (d parser.DevfileObj, err error) {

// read and parse devfile from given path
d, err = parser.Parse(path)
if err != nil {
return d, err
}

// odo specific validation on devfile content
// err = validate.ValidateDevfileData(d.Data)

return d, err
}
Loading