Skip to content

Commit 65dcb66

Browse files
fetchDevfile now returns the devfile's index schema for telemetry data.
1 parent 9c10f03 commit 65dcb66

File tree

1 file changed

+0
-33
lines changed

1 file changed

+0
-33
lines changed

index/server/pkg/server/endpoint.go

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

149148
if len(devfileBytes) == 0 {
@@ -187,15 +186,6 @@ func serveDevfileStarterProject(c *gin.Context) {
187186
c.JSON(http.StatusNotFound, gin.H{
188187
"status": fmt.Sprintf("the starter project named %s does not exist in the devfile of %s", starterProjectName, devfileName),
189188
})
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
199189
}
200190
}
201191

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

324314
// fetchDevfile retrieves a specified devfile stored under /registry/**/<devfileName>
325-
<<<<<<< HEAD
326315
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
330316
var index []indexSchema.Schema
331317
bytes, err := ioutil.ReadFile(indexPath)
332318
if err != nil {
@@ -335,11 +321,7 @@ func fetchDevfile(c *gin.Context, devfileName string) []byte {
335321
"error": err.Error(),
336322
"status": fmt.Sprintf("failed to pull the devfile of %s", devfileName),
337323
})
338-
<<<<<<< HEAD
339324
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
343325
}
344326
err = json.Unmarshal(bytes, &index)
345327
if err != nil {
@@ -348,11 +330,7 @@ func fetchDevfile(c *gin.Context, devfileName string) []byte {
348330
"error": err.Error(),
349331
"status": fmt.Sprintf("failed to pull the devfile of %s", devfileName),
350332
})
351-
<<<<<<< HEAD
352333
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
356334
}
357335

358336
// Reuse 'bytes' for devfile bytes, assign empty
@@ -375,29 +353,18 @@ func fetchDevfile(c *gin.Context, devfileName string) []byte {
375353
"error": err.Error(),
376354
"status": fmt.Sprintf("failed to pull the devfile of %s", devfileName),
377355
})
378-
<<<<<<< HEAD
379356
return make([]byte, 0), devfileIndex
380357
}
381358

382359
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
389360
}
390361
}
391362

392363
c.JSON(http.StatusNotFound, gin.H{
393364
"status": fmt.Sprintf("the devfile of %s didn't exist", devfileName),
394365
})
395366

396-
<<<<<<< HEAD
397367
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
401368
}
402369

403370
/** source from serveDevfile **/

0 commit comments

Comments
 (0)