refactor!(backend): remove check_cmd nonsense
This commit is contained in:
@@ -211,7 +211,6 @@ func main() {
|
||||
jobsGroup.POST("", jobsHandlers.AddJob)
|
||||
jobsGroup.POST("/:id/wait", jobsHandlers.WaitJob)
|
||||
jobsGroup.GET("/metrics", jobsHandlers.GetJobMetrics)
|
||||
jobsGroup.POST("/check_cmd", jobsHandlers.CheckCmd)
|
||||
}
|
||||
|
||||
// Agent registration
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -192,42 +191,6 @@ func resolveCommand(c *gin.Context, svc *service.ScriptService, interpID int64,
|
||||
return command, nil
|
||||
}
|
||||
|
||||
// @Summary Check command path
|
||||
// @Description Validates that a command binary exists on the system
|
||||
// @Tags jobs
|
||||
// @Accept json
|
||||
// @Param body body CheckCmdIn true "Command to check"
|
||||
// @Success 200 {object} CheckCmdOut
|
||||
// @Failure 404 {object} map[string]string
|
||||
// @Router /jobs/check_cmd [post]
|
||||
func (h *JobsHandlers) CheckCmd(c *gin.Context) {
|
||||
var in struct {
|
||||
Command string `json:"command" binding:"required"`
|
||||
}
|
||||
if err := c.Bind(&in); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid request"})
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := exec.LookPath(in.Command); err != nil {
|
||||
if errors.Is(err, exec.ErrNotFound) {
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "command not found"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, CheckCmdOut{Exists: true})
|
||||
}
|
||||
|
||||
type CheckCmdIn struct {
|
||||
Command string `json:"command" binding:"required" example:"bash"`
|
||||
}
|
||||
type CheckCmdOut struct {
|
||||
Exists bool `json:"exists"`
|
||||
}
|
||||
|
||||
// JobMetricsOut is the response body for the job metrics endpoint.
|
||||
type JobMetricsOut struct {
|
||||
Total int `json:"total"`
|
||||
|
||||
Reference in New Issue
Block a user