File tree 7 files changed +271
-18
lines changed
7 files changed +271
-18
lines changed Original file line number Diff line number Diff line change 1
- schemaVersion : 2.2.0
1
+ schemaVersion : 2.2.0-latest
2
2
metadata :
3
3
name : nodejs
4
4
version : 1.0.0
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ module github.com/devfile/library
3
3
go 1.15
4
4
5
5
require (
6
- github.com/devfile/api/v2 v2.0.0-20210914125740-da05a3e14c3b
6
+ github.com/devfile/api/v2 v2.0.0-20210917193329-089a48011460
7
7
github.com/fatih/color v1.7.0
8
8
github.com/gobwas/glob v0.2.3
9
9
github.com/golang/mock v1.5.0
Original file line number Diff line number Diff line change @@ -83,8 +83,8 @@ github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ
83
83
github.com/davecgh/go-spew v1.1.0 /go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38 =
84
84
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c =
85
85
github.com/davecgh/go-spew v1.1.1 /go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38 =
86
- github.com/devfile/api/v2 v2.0.0-20210914125740-da05a3e14c3b h1:OSORBTgmRBJUKbZhGJJn+CH7gyY4IBdARn9pJpnqyBs =
87
- github.com/devfile/api/v2 v2.0.0-20210914125740-da05a3e14c3b /go.mod h1:kLX/nW93gigOHXK3NLeJL2fSS/sgEe+OHu8bo3aoOi4 =
86
+ github.com/devfile/api/v2 v2.0.0-20210917193329-089a48011460 h1:cmd+3poyUwevcWchYdvE02YT1nQU4SJpA5/wrdLrpWE =
87
+ github.com/devfile/api/v2 v2.0.0-20210917193329-089a48011460 /go.mod h1:kLX/nW93gigOHXK3NLeJL2fSS/sgEe+OHu8bo3aoOi4 =
88
88
github.com/dgrijalva/jwt-go v3.2.0+incompatible /go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ =
89
89
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954 /go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no =
90
90
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96 /go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM =
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package parser
3
3
import (
4
4
"encoding/json"
5
5
"fmt"
6
+ "strings"
6
7
7
8
"github.com/devfile/library/pkg/devfile/parser/data"
8
9
"github.com/pkg/errors"
@@ -38,7 +39,9 @@ func (d *DevfileCtx) SetDevfileAPIVersion() error {
38
39
}
39
40
40
41
// Successful
41
- d .apiVersion = schemaVersion .(string )
42
+ // split by `-` and get the first substring as schema version, schemaVersion without `-` won't get affected
43
+ // e.g. 2.2.0-latest => 2.2.0, 2.2.0 => 2.2.0
44
+ d .apiVersion = strings .Split (schemaVersion .(string ), "-" )[0 ]
42
45
klog .V (4 ).Infof ("devfile schemaVersion: '%s'" , d .apiVersion )
43
46
return nil
44
47
}
Original file line number Diff line number Diff line change 9
9
func TestSetDevfileAPIVersion (t * testing.T ) {
10
10
11
11
const (
12
- schemaVersion = "2.0.0"
13
- validJson = `{"schemaVersion": "2.0.0"}`
12
+ schemaVersion = "2.2.0"
13
+ validJson = `{"schemaVersion": "2.2.0"}`
14
+ concreteSchema = `{"schemaVersion": "2.2.0-latest"}`
14
15
emptyJson = "{}"
15
16
emptySchemaVersionJson = `{"schemaVersion": ""}`
16
17
devfilePath = "/testpath/devfile.yaml"
@@ -30,6 +31,12 @@ func TestSetDevfileAPIVersion(t *testing.T) {
30
31
want : schemaVersion ,
31
32
wantErr : nil ,
32
33
},
34
+ {
35
+ name : "concrete schemaVersion" ,
36
+ devfileCtx : DevfileCtx {rawContent : []byte (concreteSchema ), absPath : devfilePath },
37
+ want : schemaVersion ,
38
+ wantErr : nil ,
39
+ },
33
40
{
34
41
name : "schemaVersion not present" ,
35
42
devfileCtx : DevfileCtx {rawContent : []byte (emptyJson ), absPath : devfilePath },
You can’t perform that action at this time.
0 commit comments