@@ -143,6 +143,7 @@ func serveDevfile(c *gin.Context) {
143
143
func serveDevfileStarterProject (c * gin.Context ) {
144
144
devfileName := c .Param ("devfileName" )
145
145
starterProjectName := c .Param ("starterProjectName" )
146
+ << << << < HEAD
146
147
devfileBytes , devfileIndexSchema := fetchDevfile (c , devfileName )
147
148
148
149
if len (devfileBytes ) == 0 {
@@ -186,6 +187,15 @@ func serveDevfileStarterProject(c *gin.Context) {
186
187
c .JSON (http .StatusNotFound , gin.H {
187
188
"status" : fmt .Sprintf ("the starter project named %s does not exist in the devfile of %s" , starterProjectName , devfileName ),
188
189
})
190
+ == == == =
191
+ devfileBytes := fetchDevfile (c , devfileName )
192
+
193
+ if len (devfileBytes ) == 0 {
194
+ // fetchDevfile was unsuccessful (error or not found)
195
+ return
196
+ } else {
197
+ // TODO: Add fetch start project and set response source.
198
+ >> >> >> > 2 bb8eb9 ... Implementation 2 for fetchDevfile chosen and added . See Issue #720 discussion at : https ://github.com/devfile/api/issues/720
189
199
}
190
200
}
191
201
@@ -312,7 +322,11 @@ func buildIndexAPIResponse(c *gin.Context) {
312
322
}
313
323
314
324
// fetchDevfile retrieves a specified devfile stored under /registry/**/<devfileName>
325
+ << << << < HEAD
315
326
func fetchDevfile (c * gin.Context , devfileName string ) ([]byte , indexSchema.Schema ) {
327
+ == == == =
328
+ func fetchDevfile (c * gin .Context , devfileName string ) []byte {
329
+ >> >> >> > 2 bb8eb9 ... Implementation 2 for fetchDevfile chosen and added. See Issue #720 discussion at : https ://github.com/devfile/api/issues/720
316
330
var index []indexSchema .Schema
317
331
bytes , err := ioutil .ReadFile (indexPath )
318
332
if err != nil {
@@ -321,7 +335,11 @@ func fetchDevfile(c *gin.Context, devfileName string) ([]byte, indexSchema.Schem
321
335
"error" : err .Error (),
322
336
"status" : fmt .Sprintf ("failed to pull the devfile of %s" , devfileName ),
323
337
})
338
+ << << << < HEAD
324
339
return make ([]byte , 0 ), indexSchema.Schema {}
340
+ == == == =
341
+ return make ([]byte , 0 )
342
+ >> >> >> > 2 bb8eb9 ... Implementation 2 for fetchDevfile chosen and added . See Issue #720 discussion at : https ://github.com/devfile/api/issues/720
325
343
}
326
344
err = json .Unmarshal (bytes , & index )
327
345
if err != nil {
@@ -330,7 +348,11 @@ func fetchDevfile(c *gin.Context, devfileName string) ([]byte, indexSchema.Schem
330
348
"error" : err .Error (),
331
349
"status" : fmt .Sprintf ("failed to pull the devfile of %s" , devfileName ),
332
350
})
351
+ << << << < HEAD
333
352
return make ([]byte , 0 ), indexSchema.Schema {}
353
+ == == == =
354
+ return make ([]byte , 0 )
355
+ >> >> >> > 2 bb8eb9 ... Implementation 2 for fetchDevfile chosen and added . See Issue #720 discussion at : https ://github.com/devfile/api/issues/720
334
356
}
335
357
336
358
// Reuse 'bytes' for devfile bytes, assign empty
@@ -353,18 +375,29 @@ func fetchDevfile(c *gin.Context, devfileName string) ([]byte, indexSchema.Schem
353
375
"error" : err .Error (),
354
376
"status" : fmt .Sprintf ("failed to pull the devfile of %s" , devfileName ),
355
377
})
378
+ << << << < HEAD
356
379
return make ([]byte , 0 ), devfileIndex
357
380
}
358
381
359
382
return bytes , devfileIndex
383
+ == == == =
384
+ return make ([]byte , 0 )
385
+ }
386
+
387
+ return bytes
388
+ >> >> >> > 2 bb8eb9 ... Implementation 2 for fetchDevfile chosen and added . See Issue #720 discussion at : https ://github.com/devfile/api/issues/720
360
389
}
361
390
}
362
391
363
392
c .JSON (http .StatusNotFound , gin.H {
364
393
"status" : fmt .Sprintf ("the devfile of %s didn't exist" , devfileName ),
365
394
})
366
395
396
+ << << << < HEAD
367
397
return bytes , indexSchema.Schema {}
398
+ == == == =
399
+ return bytes
400
+ >> >> >> > 2 bb8eb9 ... Implementation 2 for fetchDevfile chosen and added . See Issue #720 discussion at : https ://github.com/devfile/api/issues/720
368
401
}
369
402
370
403
/** source from serveDevfile **/
0 commit comments