75f3dd141c
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CI and Release / lint-frontend (push) Has been cancelled
CI and Release / dockerfile-scan (push) Has been cancelled
CI and Release / test-frontend (push) Has been cancelled
CI and Release / lint-verification-agent (push) Has been cancelled
CI and Release / test-verification-agent (push) Has been cancelled
CI and Release / e2e-verification-agent (push) Has been cancelled
CI and Release / test-backend (push) Has been cancelled
CI and Release / build-dev-image (push) Has been cancelled
CI and Release / push-dev-image (push) Has been cancelled
CI and Release / build-image (push) Has been cancelled
CI and Release / build-verification-image (push) Has been cancelled
CI and Release / determine-version (push) Has been cancelled
CI and Release / push-image (push) Has been cancelled
CI and Release / push-verification-image (12) (push) Has been cancelled
CI and Release / lint-backend (push) Has been cancelled
CI and Release / push-verification-image (17) (push) Has been cancelled
CI and Release / push-verification-image (18) (push) Has been cancelled
CI and Release / release (push) Has been cancelled
CI and Release / publish-helm-chart (push) Has been cancelled
CI and Release / push-verification-image (13) (push) Has been cancelled
CI and Release / push-verification-image (14) (push) Has been cancelled
CI and Release / push-verification-image (15) (push) Has been cancelled
CI and Release / push-verification-image (16) (push) Has been cancelled
52 lines
1.7 KiB
Go
52 lines
1.7 KiB
Go
package system_agent
|
|
|
|
import (
|
|
"net/http"
|
|
"os"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
system_version "databasus-backend/internal/features/system/version"
|
|
)
|
|
|
|
type AgentController struct{}
|
|
|
|
func (c *AgentController) RegisterRoutes(router *gin.RouterGroup) {
|
|
router.GET("/system/verification-agent", c.DownloadVerificationAgent)
|
|
}
|
|
|
|
var verificationAgentBinaryPaths = map[string]string{
|
|
"amd64": "agent-binaries/databasus-verification-agent-linux-amd64",
|
|
"arm64": "agent-binaries/databasus-verification-agent-linux-arm64",
|
|
}
|
|
|
|
// DownloadVerificationAgent
|
|
// @Summary Download verification agent binary
|
|
// @Description Download the databasus-verification-agent binary for the specified architecture
|
|
// @Tags system/agent
|
|
// @Produce octet-stream
|
|
// @Param arch query string true "Target architecture" Enums(amd64, arm64)
|
|
// @Success 200 {file} binary
|
|
// @Header 200 {string} X-Databasus-Version "Version the served binary was built from"
|
|
// @Failure 400 {object} map[string]string
|
|
// @Failure 404 {object} map[string]string
|
|
// @Router /system/verification-agent [get]
|
|
func (c *AgentController) DownloadVerificationAgent(ctx *gin.Context) {
|
|
binaryPath, isOk := verificationAgentBinaryPaths[ctx.Query("arch")]
|
|
if !isOk {
|
|
ctx.JSON(http.StatusBadRequest, gin.H{"error": "arch must be amd64 or arm64"})
|
|
return
|
|
}
|
|
|
|
if _, err := os.Stat(binaryPath); os.IsNotExist(err) {
|
|
ctx.JSON(http.StatusNotFound, gin.H{"error": "verification agent binary not found"})
|
|
return
|
|
}
|
|
|
|
ctx.Header("Content-Type", "application/octet-stream")
|
|
ctx.Header("Content-Disposition", "attachment; filename=databasus-verification-agent")
|
|
ctx.Header(AgentVersionHeader, system_version.GetAppVersion())
|
|
|
|
ctx.File(binaryPath)
|
|
}
|