Skip to content

Commit 2ca9308

Browse files
fetchDevfile now returns the devfile's index schema for telemetry data.
1 parent 2bb8eb9 commit 2ca9308

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

index/server/pkg/server/endpoint.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func serveDevfile(c *gin.Context) {
140140
func serveDevfileStarterProject(c *gin.Context) {
141141
devfileName := c.Param("devfileName")
142142
starterProjectName := c.Param("starterProjectName")
143-
devfileBytes := fetchDevfile(c, devfileName)
143+
devfileBytes, devfileIndexSchema := fetchDevfile(c, devfileName)
144144

145145
if len(devfileBytes) == 0 {
146146
// fetchDevfile was unsuccessful (error or not found)
@@ -273,7 +273,7 @@ func buildIndexAPIResponse(c *gin.Context) {
273273
}
274274

275275
// fetchDevfile retrieves a specified devfile stored under /registry/**/<devfileName>
276-
func fetchDevfile(c *gin.Context, devfileName string) []byte {
276+
func fetchDevfile(c *gin.Context, devfileName string) ([]byte, indexSchema.Schema) {
277277
var index []indexSchema.Schema
278278
bytes, err := ioutil.ReadFile(indexPath)
279279
if err != nil {
@@ -282,7 +282,7 @@ func fetchDevfile(c *gin.Context, devfileName string) []byte {
282282
"error": err.Error(),
283283
"status": fmt.Sprintf("failed to pull the devfile of %s", devfileName),
284284
})
285-
return make([]byte, 0)
285+
return make([]byte, 0), indexSchema.Schema{}
286286
}
287287
err = json.Unmarshal(bytes, &index)
288288
if err != nil {
@@ -291,7 +291,7 @@ func fetchDevfile(c *gin.Context, devfileName string) []byte {
291291
"error": err.Error(),
292292
"status": fmt.Sprintf("failed to pull the devfile of %s", devfileName),
293293
})
294-
return make([]byte, 0)
294+
return make([]byte, 0), indexSchema.Schema{}
295295
}
296296

297297
// Reuse 'bytes' for devfile bytes, assign empty
@@ -314,18 +314,18 @@ func fetchDevfile(c *gin.Context, devfileName string) []byte {
314314
"error": err.Error(),
315315
"status": fmt.Sprintf("failed to pull the devfile of %s", devfileName),
316316
})
317-
return make([]byte, 0)
317+
return make([]byte, 0), devfileIndex
318318
}
319319

320-
return bytes
320+
return bytes, devfileIndex
321321
}
322322
}
323323

324324
c.JSON(http.StatusNotFound, gin.H{
325325
"status": fmt.Sprintf("the devfile of %s didn't exist", devfileName),
326326
})
327327

328-
return bytes
328+
return bytes, indexSchema.Schema{}
329329
}
330330

331331
/** source from serveDevfile **/

0 commit comments

Comments
 (0)