Skip to content

Commit ac993a8

Browse files
committedMar 1, 2021
restruct works
Signed-off-by: Stephanie <[email protected]>
1 parent ca9fa55 commit ac993a8

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed
 

‎pkg/devfile/parser/context/context.go

+4
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ func (d *DevfileCtx) PopulateFromURL() (err error) {
9595
if d.uriMap == nil {
9696
d.uriMap= make(map[string]bool)
9797
}
98+
fmt.Printf("uriMap length is: %v", len(d.uriMap))
99+
for k,_ := range d.uriMap {
100+
fmt.Printf("uriMap now contains: %s", k)
101+
}
98102
if d.uriMap[d.url] {
99103
return fmt.Errorf("URI %v is recursively referenced", d.url)
100104
}

‎pkg/devfile/parser/parse.go

+12-5
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,21 @@ func parseFromURI(uri string, curDevfileCtx devfileCtx.DevfileCtx) (DevfileObj,
183183
if err != nil {
184184
return DevfileObj{}, err
185185
}
186-
186+
// NewDevfileCtx
187+
var d DevfileObj
187188
// absolute URL address
188189
if strings.HasPrefix(uri, "http://") || strings.HasPrefix(uri, "https://") {
189-
return ParseFromURL(uri)
190+
// return ParseFromURL(uri)
191+
d.Ctx = devfileCtx.NewURLDevfileCtx(uri)
192+
d.Ctx.SetURIMap(curDevfileCtx.GetURIMap())
193+
// Fill the fields of DevfileCtx struct
194+
err = d.Ctx.PopulateFromURL()
195+
if err != nil {
196+
return DevfileObj{}, err
197+
}
198+
return parseDevfile(d, true)
190199
}
191200

192-
// NewDevfileCtx
193-
var d DevfileObj
194201
// relative path on disk
195202
if curDevfileCtx.GetAbsPath() != "" {
196203
d.Ctx = devfileCtx.NewDevfileCtx(path.Join(path.Dir(curDevfileCtx.GetAbsPath()), uri))
@@ -217,7 +224,7 @@ func parseFromURI(uri string, curDevfileCtx devfileCtx.DevfileCtx) (DevfileObj,
217224
// Fill the fields of DevfileCtx struct
218225
err = d.Ctx.PopulateFromURL()
219226
if err != nil {
220-
return d, err
227+
return DevfileObj{}, err
221228
}
222229
return parseDevfile(d, true)
223230
// u.String() is the joint absolute URL path

0 commit comments

Comments
 (0)
Please sign in to comment.