feat: show systemd service logs in service details (#2440)

Co-authored-by: hank <hank@henrygd.me>
This commit is contained in:
spatiumstas
2026-09-28 20:57:36 +03:00
committed by GitHub
parent ad215788ed
commit 7626e5e3c8
19 changed files with 618 additions and 78 deletions

View File

@@ -115,6 +115,16 @@ func unmarshalLegacyResponse(resp common.AgentResponse, action common.WebSocketA
}
*d = resp.ServiceInfo
return nil
case common.GetSystemdLogs:
d, ok := dest.(*string)
if !ok {
return fmt.Errorf("unexpected dest type for GetSystemdLogs: %T", dest)
}
if resp.String == nil {
return errors.New("no systemd logs in response")
}
*d = *resp.String
return nil
}
return fmt.Errorf("unsupported action: %d", action)
}

View File

@@ -31,3 +31,12 @@ func TestUnmarshalSmartDataResponse(t *testing.T) {
})
}
}
func TestUnmarshalSystemdLogsResponse(t *testing.T) {
logs := "2026-09-27T12:00:00+00:00 host nginx[1]: started"
response := common.AgentResponse{String: &logs}
var result string
require.NoError(t, UnmarshalResponse(response, common.GetSystemdLogs, &result))
assert.Equal(t, logs, result)
}