1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-26 07:13:41 +01:00

feat: supports container rename (#3390)

This commit is contained in:
Amir Raminfar
2024-11-14 13:54:56 -08:00
committed by GitHub
parent b3177e95d9
commit c032f788fb
7 changed files with 32 additions and 14 deletions

View File

@@ -309,9 +309,10 @@ func (d *httpClient) ContainerEvents(ctx context.Context, messages chan<- Contai
case message := <-dockerMessages:
if message.Type == events.ContainerEventType && len(message.Actor.ID) > 0 {
messages <- ContainerEvent{
ActorID: message.Actor.ID[:12],
Name: string(message.Action),
Host: d.host.ID,
ActorID: message.Actor.ID[:12],
Name: string(message.Action),
Host: d.host.ID,
ActorAttributes: message.Actor.Attributes,
}
}
}

View File

@@ -230,6 +230,17 @@ func (s *ContainerStore) init() {
return c, true
}
})
case "rename":
s.containers.Compute(event.ActorID, func(c *Container, loaded bool) (*Container, bool) {
if loaded {
log.Debug().Str("id", event.ActorID).Str("name", event.ActorAttributes["name"]).Msg("container renamed")
c.Name = event.ActorAttributes["name"]
return c, false
} else {
return c, true
}
})
}
s.subscribers.Range(func(c context.Context, events chan<- ContainerEvent) bool {
select {

View File

@@ -35,9 +35,10 @@ type ContainerStat struct {
// ContainerEvent represents events that are triggered
type ContainerEvent struct {
ActorID string `json:"actorId"`
Name string `json:"name"`
Host string `json:"host"`
Name string `json:"name"`
Host string `json:"host"`
ActorID string `json:"actorId"`
ActorAttributes map[string]string `json:"actorAttributes,omitempty"`
}
type LogPosition string