Skip to content

Commit 11baabf

Browse files
committed
update main.go to accept a url or a devfile path
Signed-off-by: Stephanie <[email protected]>
1 parent e03bb73 commit 11baabf

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

devfile.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
schemaVersion: 2.0.0
1+
schemaVersion: 2.1.0
22
metadata:
33
name: nodejs
44
version: 1.0.0

main.go

+16-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package main
22

33
import (
44
"fmt"
5+
"os"
56
"reflect"
7+
"strings"
68

79
devfilepkg "github.com/devfile/library/pkg/devfile"
810
"github.com/devfile/library/pkg/devfile/parser"
@@ -11,7 +13,20 @@ import (
1113
)
1214

1315
func main() {
14-
devfile, err := ParseDevfile("./devfile.yaml")
16+
var devfile parser.DevfileObj
17+
var err error
18+
if len(os.Args) > 1 {
19+
if strings.HasPrefix(os.Args[1], "http") {
20+
devfile, err = devfilepkg.ParseFromURLAndValidate(os.Args[1])
21+
} else{
22+
devfile, err = ParseDevfile(os.Args[1])
23+
}
24+
fmt.Println("parsing devfile from " + os.Args[1])
25+
26+
} else {
27+
devfile, err = ParseDevfile("devfile.yaml")
28+
fmt.Println("parsing devfile from " + devfile.Ctx.GetAbsPath())
29+
}
1530
if err != nil {
1631
fmt.Println(err)
1732
} else {

0 commit comments

Comments
 (0)