mirror of
https://github.com/docker/compose.git
synced 2025-07-27 15:44:08 +02:00
another hack-ish hack to support compose logs
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
4bd8a8860f
commit
7104b8126a
@ -27,6 +27,9 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
types2 "github.com/docker/docker/api/types"
|
||||||
|
"github.com/docker/docker/api/types/filters"
|
||||||
|
|
||||||
"github.com/docker/compose-cli/compose"
|
"github.com/docker/compose-cli/compose"
|
||||||
"github.com/docker/compose-cli/errdefs"
|
"github.com/docker/compose-cli/errdefs"
|
||||||
|
|
||||||
@ -145,7 +148,30 @@ services:
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e ecsLocalSimulation) Logs(ctx context.Context, projectName string, w io.Writer) error {
|
func (e ecsLocalSimulation) Logs(ctx context.Context, projectName string, w io.Writer) error {
|
||||||
return errors.Wrap(errdefs.ErrNotImplemented, "use docker-compose logs")
|
list, err := e.moby.ContainerList(ctx, types2.ContainerListOptions{
|
||||||
|
Filters: filters.NewArgs(filters.Arg("label", "com.docker.compose.project="+projectName)),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
services := map[string]types.ServiceConfig{}
|
||||||
|
for _, c := range list {
|
||||||
|
services[c.Labels["com.docker.compose.service"]] = types.ServiceConfig{
|
||||||
|
Image: "unused",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
marshal, err := yaml.Marshal(map[string]interface{}{
|
||||||
|
"services": services,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
cmd := exec.Command("docker-compose", "--context", "default", "--project-name", projectName, "-f", "-", "logs", "-f")
|
||||||
|
cmd.Stdin = strings.NewReader(string(marshal))
|
||||||
|
cmd.Stdout = os.Stdout
|
||||||
|
cmd.Stderr = os.Stderr
|
||||||
|
return cmd.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e ecsLocalSimulation) Ps(ctx context.Context, projectName string) ([]compose.ServiceStatus, error) {
|
func (e ecsLocalSimulation) Ps(ctx context.Context, projectName string) ([]compose.ServiceStatus, error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user