Skip to content

Commit 9c10f03

Browse files
Implementation 2 for fetchDevfile chosen and added. See Issue #720 discussion at: devfile/api#720
1 parent 3d7a869 commit 9c10f03

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

index/server/pkg/server/endpoint.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ func serveDevfile(c *gin.Context) {
143143
func serveDevfileStarterProject(c *gin.Context) {
144144
devfileName := c.Param("devfileName")
145145
starterProjectName := c.Param("starterProjectName")
146+
<<<<<<< HEAD
146147
devfileBytes, devfileIndexSchema := fetchDevfile(c, devfileName)
147148

148149
if len(devfileBytes) == 0 {
@@ -186,6 +187,15 @@ func serveDevfileStarterProject(c *gin.Context) {
186187
c.JSON(http.StatusNotFound, gin.H{
187188
"status": fmt.Sprintf("the starter project named %s does not exist in the devfile of %s", starterProjectName, devfileName),
188189
})
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+
>>>>>>> 2bb8eb9... Implementation 2 for fetchDevfile chosen and added. See Issue #720 discussion at: https://github.com/devfile/api/issues/720
189199
}
190200
}
191201

@@ -312,7 +322,11 @@ func buildIndexAPIResponse(c *gin.Context) {
312322
}
313323

314324
// fetchDevfile retrieves a specified devfile stored under /registry/**/<devfileName>
325+
<<<<<<< HEAD
315326
func fetchDevfile(c *gin.Context, devfileName string) ([]byte, indexSchema.Schema) {
327+
=======
328+
func fetchDevfile(c *gin.Context, devfileName string) []byte {
329+
>>>>>>> 2bb8eb9... Implementation 2 for fetchDevfile chosen and added. See Issue #720 discussion at: https://github.com/devfile/api/issues/720
316330
var index []indexSchema.Schema
317331
bytes, err := ioutil.ReadFile(indexPath)
318332
if err != nil {
@@ -321,7 +335,11 @@ func fetchDevfile(c *gin.Context, devfileName string) ([]byte, indexSchema.Schem
321335
"error": err.Error(),
322336
"status": fmt.Sprintf("failed to pull the devfile of %s", devfileName),
323337
})
338+
<<<<<<< HEAD
324339
return make([]byte, 0), indexSchema.Schema{}
340+
=======
341+
return make([]byte, 0)
342+
>>>>>>> 2bb8eb9... Implementation 2 for fetchDevfile chosen and added. See Issue #720 discussion at: https://github.com/devfile/api/issues/720
325343
}
326344
err = json.Unmarshal(bytes, &index)
327345
if err != nil {
@@ -330,7 +348,11 @@ func fetchDevfile(c *gin.Context, devfileName string) ([]byte, indexSchema.Schem
330348
"error": err.Error(),
331349
"status": fmt.Sprintf("failed to pull the devfile of %s", devfileName),
332350
})
351+
<<<<<<< HEAD
333352
return make([]byte, 0), indexSchema.Schema{}
353+
=======
354+
return make([]byte, 0)
355+
>>>>>>> 2bb8eb9... Implementation 2 for fetchDevfile chosen and added. See Issue #720 discussion at: https://github.com/devfile/api/issues/720
334356
}
335357

336358
// Reuse 'bytes' for devfile bytes, assign empty
@@ -353,18 +375,29 @@ func fetchDevfile(c *gin.Context, devfileName string) ([]byte, indexSchema.Schem
353375
"error": err.Error(),
354376
"status": fmt.Sprintf("failed to pull the devfile of %s", devfileName),
355377
})
378+
<<<<<<< HEAD
356379
return make([]byte, 0), devfileIndex
357380
}
358381

359382
return bytes, devfileIndex
383+
=======
384+
return make([]byte, 0)
385+
}
386+
387+
return bytes
388+
>>>>>>> 2bb8eb9... Implementation 2 for fetchDevfile chosen and added. See Issue #720 discussion at: https://github.com/devfile/api/issues/720
360389
}
361390
}
362391

363392
c.JSON(http.StatusNotFound, gin.H{
364393
"status": fmt.Sprintf("the devfile of %s didn't exist", devfileName),
365394
})
366395

396+
<<<<<<< HEAD
367397
return bytes, indexSchema.Schema{}
398+
=======
399+
return bytes
400+
>>>>>>> 2bb8eb9... Implementation 2 for fetchDevfile chosen and added. See Issue #720 discussion at: https://github.com/devfile/api/issues/720
368401
}
369402

370403
/** source from serveDevfile **/

0 commit comments

Comments
 (0)