mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 00:38:33 +02:00
feat(proxmox): add journalctl endpoint without service; add limit parameter
Added new Proxmox journalctl endpoint `/journalctl/:node/:vmid` for viewing all journalctl output without requiring a service name. Made the service parameter optional across both endpoints. Introduced configurable `limit` query parameter (1-1000, default 100) to both proxmox journalctl and docker logs APIs, replacing hardcoded 100-line tail. Added container status check in LXCCommand to prevent command execution on stopped containers, returning a clear status message instead. Refactored route validation to use pre-fetched IPs and improved References() method for proxmox routes with better alias handling.
This commit is contained in:
@@ -13,7 +13,8 @@ import (
|
||||
type JournalctlRequest struct {
|
||||
Node string `uri:"node" binding:"required"`
|
||||
VMID int `uri:"vmid" binding:"required"`
|
||||
Service string `uri:"service" binding:"required"`
|
||||
Service string `uri:"service"`
|
||||
Limit int `query:"limit" binding:"omitempty,min=1,max=1000"`
|
||||
}
|
||||
|
||||
// @x-id "journalctl"
|
||||
@@ -24,12 +25,14 @@ type JournalctlRequest struct {
|
||||
// @Accept json
|
||||
// @Produce application/json
|
||||
// @Param path path JournalctlRequest true "Request"
|
||||
// @Param limit query int false "limit"
|
||||
// @Success 200 string plain "Journalctl output"
|
||||
// @Failure 400 {object} apitypes.ErrorResponse "Invalid request"
|
||||
// @Failure 403 {object} apitypes.ErrorResponse "Unauthorized"
|
||||
// @Failure 404 {object} apitypes.ErrorResponse "Node not found"
|
||||
// @Failure 500 {object} apitypes.ErrorResponse "Internal server error"
|
||||
// @Router /api/v1/proxmox/journalctl/{node}/{vmid}/{service} [get]
|
||||
// @Router /api/v1/proxmox/journalctl/{node}/{vmid} [get]
|
||||
// @Router /api/v1/proxmox/journalctl/{node}/{vmid}/{service} [get]
|
||||
func Journalctl(c *gin.Context) {
|
||||
var request JournalctlRequest
|
||||
if err := c.ShouldBindUri(&request); err != nil {
|
||||
@@ -50,7 +53,7 @@ func Journalctl(c *gin.Context) {
|
||||
}
|
||||
defer manager.Close()
|
||||
|
||||
reader, err := node.LXCJournalctl(c.Request.Context(), request.VMID, request.Service)
|
||||
reader, err := node.LXCJournalctl(c.Request.Context(), request.VMID, request.Service, request.Limit)
|
||||
if err != nil {
|
||||
c.Error(apitypes.InternalServerError(err, "failed to get journalctl output"))
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user