mirror of
https://github.com/docker/compose.git
synced 2026-08-31 23:03:55 +00:00
Revisit logs/up API to pass a LogConsumer vs io.Writer
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
4826d5155a
commit
ca123e08eb
11 changed files with 112 additions and 99 deletions
|
|
@ -18,12 +18,11 @@ package client
|
|||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
|
||||
"github.com/compose-spec/compose-go/types"
|
||||
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/errdefs"
|
||||
|
||||
"github.com/compose-spec/compose-go/types"
|
||||
)
|
||||
|
||||
type composeService struct {
|
||||
|
|
@ -45,7 +44,7 @@ func (c *composeService) Create(ctx context.Context, project *types.Project) err
|
|||
return errdefs.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *composeService) Start(ctx context.Context, project *types.Project, w io.Writer) error {
|
||||
func (c *composeService) Start(ctx context.Context, project *types.Project, consumer compose.LogConsumer) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
}
|
||||
|
||||
|
|
@ -57,7 +56,7 @@ func (c *composeService) Down(context.Context, string) error {
|
|||
return errdefs.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *composeService) Logs(context.Context, string, io.Writer) error {
|
||||
func (c *composeService) Logs(context.Context, string, compose.LogConsumer) error {
|
||||
return errdefs.ErrNotImplemented
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package compose
|
|||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
|
||||
"github.com/compose-spec/compose-go/types"
|
||||
)
|
||||
|
|
@ -34,13 +33,13 @@ type Service interface {
|
|||
// Create executes the equivalent to a `compose create`
|
||||
Create(ctx context.Context, project *types.Project) error
|
||||
// Start executes the equivalent to a `compose start`
|
||||
Start(ctx context.Context, project *types.Project, w io.Writer) error
|
||||
Start(ctx context.Context, project *types.Project, consumer LogConsumer) error
|
||||
// Up executes the equivalent to a `compose up`
|
||||
Up(ctx context.Context, project *types.Project, detach bool) error
|
||||
// Down executes the equivalent to a `compose down`
|
||||
Down(ctx context.Context, projectName string) error
|
||||
// Logs executes the equivalent to a `compose logs`
|
||||
Logs(ctx context.Context, projectName string, w io.Writer) error
|
||||
Logs(ctx context.Context, projectName string, consumer LogConsumer) error
|
||||
// Ps executes the equivalent to a `compose ps`
|
||||
Ps(ctx context.Context, projectName string) ([]ServiceStatus, error)
|
||||
// List executes the equivalent to a `docker stack ls`
|
||||
|
|
@ -89,3 +88,8 @@ type Stack struct {
|
|||
Status string
|
||||
Reason string
|
||||
}
|
||||
|
||||
// LogConsumer is a callback to process log messages from services
|
||||
type LogConsumer interface {
|
||||
Log(service, container, message string)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue