New field added for works to store gradation repository
Some checks are pending
continuous-integration/drone/push Build is running

This commit is contained in:
nemunaire 2023-01-01 15:26:58 +01:00
parent e8d34869cc
commit 6def3de983
7 changed files with 97 additions and 10 deletions

32
gradation.go Normal file
View file

@ -0,0 +1,32 @@
package main
import (
"log"
"net/http"
"github.com/drone/drone-go/drone"
"github.com/gin-gonic/gin"
)
func declareAPIAdminGradationRoutes(router *gin.RouterGroup) {
router.GET("/gradation_repositories", func(c *gin.Context) {
client := drone.NewClient(droneEndpoint, droneConfig)
result, err := client.RepoList()
if err != nil {
log.Println("Unable to retrieve the repository list:", err.Error())
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": "Unable to retrieve the repository list."})
return
}
c.JSON(http.StatusOK, result)
})
router.POST("/gradation_repositories/sync", func(c *gin.Context) {
client := drone.NewClient(droneEndpoint, droneConfig)
result, err := client.RepoListSync()
if err != nil {
log.Println("Unable to retrieve the repository list:", err.Error())
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": "Unable to retrieve the repository list."})
return
}
c.JSON(http.StatusOK, result)
})
}