fix: Backend platform-aware Agent-Update (nicht mehr hardcoded freebsd)
This commit is contained in:
parent
291d2e3c17
commit
358682e5f3
@ -184,8 +184,20 @@ func (h *Handler) pushAgentUpdate(hub *ws.Hub) http.HandlerFunc {
|
|||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
agentID := r.PathValue("id")
|
agentID := r.PathValue("id")
|
||||||
|
|
||||||
// TODO: Agent-Plattform aus DB lesen; fuer jetzt default freebsd
|
// Plattform aus Request-Body oder Query-Parameter lesen, default linux
|
||||||
version, hash, binary, err := h.db.GetLatestFirmware("freebsd")
|
platform := r.URL.Query().Get("platform")
|
||||||
|
if platform == "" {
|
||||||
|
var reqBody struct {
|
||||||
|
Platform string `json:"platform"`
|
||||||
|
}
|
||||||
|
body, _ := io.ReadAll(r.Body)
|
||||||
|
json.Unmarshal(body, &reqBody)
|
||||||
|
platform = reqBody.Platform
|
||||||
|
}
|
||||||
|
if platform == "" {
|
||||||
|
platform = "linux"
|
||||||
|
}
|
||||||
|
version, hash, binary, err := h.db.GetLatestFirmware(platform)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeError(w, http.StatusNotFound, "Keine Firmware verfuegbar")
|
writeError(w, http.StatusNotFound, "Keine Firmware verfuegbar")
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user