mirror of https://github.com/docker/compose.git
happy shinny linter ☜(⌒▽⌒)☞
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
49415afe5d
commit
15882d3503
|
@ -18,9 +18,11 @@ package compose
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/docker/compose-cli/api/client"
|
"github.com/docker/compose-cli/api/client"
|
||||||
"github.com/docker/compose-cli/api/compose"
|
"github.com/docker/compose-cli/api/compose"
|
||||||
"github.com/docker/compose-cli/api/progress"
|
"github.com/docker/compose-cli/api/progress"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ package compose
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"golang.org/x/sync/errgroup"
|
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -37,6 +36,7 @@ import (
|
||||||
"github.com/compose-spec/compose-go/types"
|
"github.com/compose-spec/compose-go/types"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"golang.org/x/sync/errgroup"
|
||||||
)
|
)
|
||||||
|
|
||||||
// composeOptions hold options common to `up` and `run` to run compose project
|
// composeOptions hold options common to `up` and `run` to run compose project
|
||||||
|
@ -223,7 +223,7 @@ func runCreateStart(ctx context.Context, opts upOptions, services []string) erro
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
eg.Wait()
|
err = eg.Wait()
|
||||||
if exitCode != 0 {
|
if exitCode != 0 {
|
||||||
return cmd.ExitCodeError{ExitCode: exitCode}
|
return cmd.ExitCodeError{ExitCode: exitCode}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ import (
|
||||||
func NewLogConsumer(ctx context.Context, w io.Writer, color bool, prefix bool) compose.LogConsumer {
|
func NewLogConsumer(ctx context.Context, w io.Writer, color bool, prefix bool) compose.LogConsumer {
|
||||||
return &logConsumer{
|
return &logConsumer{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
presenters: map[string]*Presenter{},
|
presenters: map[string]*presenter{},
|
||||||
width: 0,
|
width: 0,
|
||||||
writer: w,
|
writer: w,
|
||||||
color: color,
|
color: color,
|
||||||
|
@ -42,12 +42,12 @@ func (l *logConsumer) Register(service string, source string) {
|
||||||
l.register(service, source)
|
l.register(service, source)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *logConsumer) register(service string, source string) *Presenter {
|
func (l *logConsumer) register(service string, source string) *presenter {
|
||||||
cf := monochrome
|
cf := monochrome
|
||||||
if l.color {
|
if l.color {
|
||||||
cf = <-loop
|
cf = <-loop
|
||||||
}
|
}
|
||||||
p := &Presenter{
|
p := &presenter{
|
||||||
colors: cf,
|
colors: cf,
|
||||||
service: service,
|
service: service,
|
||||||
container: source,
|
container: source,
|
||||||
|
@ -98,20 +98,20 @@ func (l *logConsumer) computeWidth() {
|
||||||
// LogConsumer consume logs from services and format them
|
// LogConsumer consume logs from services and format them
|
||||||
type logConsumer struct {
|
type logConsumer struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
presenters map[string]*Presenter
|
presenters map[string]*presenter
|
||||||
width int
|
width int
|
||||||
writer io.Writer
|
writer io.Writer
|
||||||
color bool
|
color bool
|
||||||
prefix bool
|
prefix bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Presenter struct {
|
type presenter struct {
|
||||||
colors colorFunc
|
colors colorFunc
|
||||||
service string
|
service string
|
||||||
container string
|
container string
|
||||||
prefix string
|
prefix string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Presenter) setPrefix(width int) {
|
func (p *presenter) setPrefix(width int) {
|
||||||
p.prefix = p.colors(fmt.Sprintf("%-"+strconv.Itoa(width)+"s |", p.container))
|
p.prefix = p.colors(fmt.Sprintf("%-"+strconv.Itoa(width)+"s |", p.container))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue