wip: oci image management
This commit is contained in:
49
handler/registry_tag.go
Normal file
49
handler/registry_tag.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"gitea.loveuer.com/loveuer/cluster/internal/rerr"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
func handleTags(c fiber.Ctx) error {
|
||||
if c.Method() != "GET" {
|
||||
return rerr.Error(c, &rerr.RepositoryError{
|
||||
Status: http.StatusBadRequest,
|
||||
Code: "METHOD_UNKNOWN",
|
||||
Message: "We don't understand your method + url",
|
||||
})
|
||||
}
|
||||
|
||||
type Req struct {
|
||||
Last int `json:"last" query:"last"`
|
||||
N int `json:"n" query:"n"`
|
||||
}
|
||||
|
||||
elem := strings.Split(c.Path(), "/")
|
||||
elem = elem[1:]
|
||||
repo := strings.Join(elem[1:len(elem)-2], "/")
|
||||
|
||||
var req Req
|
||||
if err := c.Bind().Query(&req); err != nil {
|
||||
return rerr.Error(c, &rerr.RepositoryError{
|
||||
Status: http.StatusBadRequest,
|
||||
Code: "BAD_REQUEST",
|
||||
Message: err.Error(),
|
||||
})
|
||||
}
|
||||
|
||||
if req.N <= 0 {
|
||||
req.N = 100
|
||||
}
|
||||
|
||||
list, re := m.Tags(c.Context(), repo, req.N, req.Last, "")
|
||||
if re != nil {
|
||||
return rerr.Error(c, re)
|
||||
}
|
||||
|
||||
return c.JSON(list)
|
||||
}
|
||||
Reference in New Issue
Block a user