New route to retrieve gradation status
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
1515140c09
commit
184daa4cab
3 changed files with 65 additions and 8 deletions
|
|
@ -320,6 +320,36 @@ func declareAPIAuthRepositoriesRoutes(router *gin.RouterGroup) {
|
|||
TriggerTests(c, work, repo, u)
|
||||
})
|
||||
|
||||
repositoriesRoutes.GET("/gradation_status", func(c *gin.Context) {
|
||||
loggeduser := c.MustGet("LoggedUser").(*User)
|
||||
if !loggeduser.IsAdmin {
|
||||
c.AbortWithStatusJSON(http.StatusForbidden, gin.H{"errmsg": "Permission denied."})
|
||||
return
|
||||
}
|
||||
|
||||
repo := c.MustGet("repository").(*Repository)
|
||||
|
||||
slug := strings.Split(repo.TestsRef, "/")
|
||||
if len(slug) < 3 {
|
||||
return
|
||||
}
|
||||
|
||||
buildn, err := strconv.ParseInt(slug[2], 10, 32)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
client := drone.NewClient(droneEndpoint, droneConfig)
|
||||
build, err := client.Build(slug[0], slug[1], int(buildn))
|
||||
if err != nil {
|
||||
log.Println("Unable to communicate with Drone:", err.Error())
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": "Unable to communicate with Drone"})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, build)
|
||||
})
|
||||
|
||||
repositoriesRoutes.GET("/traces", func(c *gin.Context) {
|
||||
repo := c.MustGet("repository").(*Repository)
|
||||
|
||||
|
|
|
|||
Reference in a new issue