mirror of
https://github.com/lorsanstand/HomeOps-Hub.git
synced 2026-06-19 20:05:17 +03:00
feat: create save new agent in db
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user