feat: create save new agent in db

This commit is contained in:
2026-04-19 16:16:03 +03:00
parent 52766cf7e8
commit e289365ce8
14 changed files with 314 additions and 72 deletions
@@ -10,6 +10,8 @@ import (
"github.com/rs/zerolog"
)
const AgentVersion = "0.0"
type Collector interface {
GatherInfoSystem() (domain.HostInfo, []domain.Capability)
}
@@ -43,7 +45,7 @@ func (a *AgentService) RegisterAgentConn(ctx context.Context) {
info, caps := a.collect.GatherInfoSystem()
AgentID := a.settings.AgentID
AgentName := a.cfg.AppName
AgentData := domain.RegisterAgentRequest{AgentId: AgentID, AgentName: AgentName, Host: info, Capabilities: caps}
AgentData := domain.RegisterAgentRequest{AgentId: AgentID, AgentName: AgentName, Host: info, Capabilities: caps, AgentVersion: AgentVersion}
data, err := a.conn.RegisterAgent(ctx, AgentData)
if err != nil {
@@ -0,0 +1,25 @@
package agent_service
import (
"context"
"github.com/lorsanstand/HomeOps-Hub/internal/domain"
)
type CollectorMock struct {
host domain.HostInfo
caps []domain.Capability
}
func (c *CollectorMock) GatherInfoSystem() (domain.HostInfo, []domain.Capability) {
return c.host, c.caps
}
type ConnectionMock struct {
regAgentErr error
regResp domain.RegisterAgentResponse
}
func (c *ConnectionMock) RegisterAgent(ctx context.Context, RegisterData domain.RegisterAgentRequest) (domain.RegisterAgentResponse, error) {
return c.regResp, c.regAgentErr
}