`Event` is way too generic noon

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2021-02-09 11:53:35 +01:00
parent 27d640dd41
commit 06b033db6c
3 changed files with 5 additions and 8 deletions

View File

@ -68,7 +68,7 @@ type StartOptions struct {
// Attach will attach to container and pipe stdout/stderr to LogConsumer
Attach LogConsumer
// Listener will get notified on container events
Listener Listener
Listener chan ContainerExited
}
// UpOptions group options of the Up API
@ -188,11 +188,8 @@ type LogConsumer interface {
Status(service, container, message string)
}
// Listener get notified on container Events
type Listener chan Event
// Event let us know a Container exited
type Event struct {
// ContainerExited let us know a Container exited
type ContainerExited struct {
Service string
Status int
}

View File

@ -151,7 +151,7 @@ func runCreateStart(ctx context.Context, opts upOptions, services []string) erro
}
ctx, cancel := context.WithCancel(ctx)
listener := make(chan compose.Event)
listener := make(chan compose.ContainerExited)
go func() {
var aborting bool
for {

View File

@ -64,7 +64,7 @@ func (s *composeService) Start(ctx context.Context, project *types.Project, opti
service := c.Labels[serviceLabel]
options.Attach.Status(service, getCanonicalContainerName(c), fmt.Sprintf("exited with code %d", status.StatusCode))
if options.Listener != nil {
options.Listener <- compose.Event{
options.Listener <- compose.ContainerExited{
Service: service,
Status: int(status.StatusCode),
}