mirror of
https://github.com/lorsanstand/HomeOps-Hub.git
synced 2026-09-18 16:18:21 +03:00
feat: add register agent in db
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/lorsanstand/HomeOps-Hub/internal/domain"
|
||||
"github.com/lorsanstand/HomeOps-Hub/internal/hub/store/sqlc/gen"
|
||||
)
|
||||
|
||||
type Agent struct {
|
||||
AgentID string
|
||||
AgentName string
|
||||
Architecture string
|
||||
System string
|
||||
Hostname string
|
||||
Version string
|
||||
Capabilities []domain.Capability
|
||||
}
|
||||
|
||||
func toDBAgent(agent Agent) gen.CreateAgentParams {
|
||||
return gen.CreateAgentParams{
|
||||
AgentID: agent.AgentID,
|
||||
AgentName: &agent.AgentName,
|
||||
Architecture: agent.Architecture,
|
||||
System: agent.System,
|
||||
Version: agent.Version,
|
||||
Capabilities: toJsonCapabilities(agent.Capabilities),
|
||||
}
|
||||
}
|
||||
|
||||
func toJsonCapabilities(caps []domain.Capability) []byte {
|
||||
data, err := json.Marshal(caps)
|
||||
if err != nil {
|
||||
return []byte{}
|
||||
}
|
||||
return data
|
||||
}
|
||||
Reference in New Issue
Block a user