feat: add volume, images and networks
This commit is contained in:
@ -108,12 +108,21 @@ func (g *Gateway) Tunnel(stream agentv1.AgentGateway_TunnelServer) error {
|
||||
|
||||
switch p := msg.Payload.(type) {
|
||||
case *agentv1.AgentMessage_Snapshot:
|
||||
g.registry.UpdateContainers(agentID, p.Snapshot.Containers)
|
||||
g.registry.UpdateResources(agentID, p.Snapshot.Containers, p.Snapshot.Images, p.Snapshot.Volumes, p.Snapshot.Networks)
|
||||
g.broker.Publish(broker.Event{
|
||||
Type: "containers.updated",
|
||||
AgentID: agentID,
|
||||
Payload: p.Snapshot.Containers,
|
||||
})
|
||||
g.broker.Publish(broker.Event{
|
||||
Type: "resources.updated",
|
||||
AgentID: agentID,
|
||||
Payload: map[string]any{
|
||||
"images": p.Snapshot.Images,
|
||||
"volumes": p.Snapshot.Volumes,
|
||||
"networks": p.Snapshot.Networks,
|
||||
},
|
||||
})
|
||||
|
||||
case *agentv1.AgentMessage_Result:
|
||||
g.broker.Publish(broker.Event{
|
||||
|
||||
@ -16,6 +16,9 @@ type AgentState struct {
|
||||
OS string
|
||||
LastSeenAt time.Time
|
||||
Containers []*agentv1.ContainerInfo
|
||||
Images []*agentv1.ImageInfo
|
||||
Volumes []*agentv1.VolumeInfo
|
||||
Networks []*agentv1.NetworkInfo
|
||||
|
||||
cmdCh chan *agentv1.ServerMessage
|
||||
}
|
||||
@ -80,6 +83,18 @@ func (r *Registry) UpdateContainers(id string, containers []*agentv1.ContainerIn
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Registry) UpdateResources(id string, containers []*agentv1.ContainerInfo, images []*agentv1.ImageInfo, volumes []*agentv1.VolumeInfo, networks []*agentv1.NetworkInfo) {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
if s, ok := r.agents[id]; ok {
|
||||
s.Containers = containers
|
||||
s.Images = images
|
||||
s.Volumes = volumes
|
||||
s.Networks = networks
|
||||
s.LastSeenAt = time.Now()
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateAlias refreshes the alias for a live agent (called after an admin update).
|
||||
func (r *Registry) UpdateAlias(id, alias string) {
|
||||
r.mu.Lock()
|
||||
|
||||
Reference in New Issue
Block a user