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:
@@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user