44 lines
734 B
Go
44 lines
734 B
Go
package images
|
|
|
|
import (
|
|
"floares/lib/http/images"
|
|
"github.com/gin-gonic/gin"
|
|
"net/http"
|
|
)
|
|
|
|
func ListImages(c *gin.Context) {
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"data": images.List(),
|
|
"code": http.StatusOK,
|
|
})
|
|
}
|
|
func PullImage(c *gin.Context) {
|
|
type Ref struct {
|
|
Ref string `json:"ref"`
|
|
}
|
|
var ref Ref
|
|
if err := c.ShouldBind(&ref); err != nil {
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"code": http.StatusBadRequest,
|
|
"data": gin.H{
|
|
"err": err.Error(),
|
|
},
|
|
})
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"data": images.Pull(ref.Ref),
|
|
"code": http.StatusOK,
|
|
})
|
|
}
|
|
|
|
func Delete(c *gin.Context) {
|
|
result := images.Delete(c.Param("id"))
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"code": http.StatusOK,
|
|
"err": result.Error,
|
|
})
|
|
|
|
}
|