mirror of https://github.com/docker/compose.git
Add "style" tag to gocritic
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
This commit is contained in:
parent
d42adf6efb
commit
96cbb1cbcf
|
@ -39,9 +39,11 @@ linters-settings:
|
|||
enabled-tags:
|
||||
- diagnostic
|
||||
- opinionated
|
||||
- style
|
||||
disabled-checks:
|
||||
- paramTypeCombine
|
||||
- unnamedResult
|
||||
- whyNoLint
|
||||
gocyclo:
|
||||
min-complexity: 16
|
||||
lll:
|
||||
|
|
|
@ -27,6 +27,16 @@ import (
|
|||
"github.com/docker/compose/v2/pkg/api"
|
||||
)
|
||||
|
||||
// LogConsumer consume logs from services and format them
|
||||
type logConsumer struct {
|
||||
ctx context.Context
|
||||
presenters sync.Map // map[string]*presenter
|
||||
width int
|
||||
writer io.Writer
|
||||
color bool
|
||||
prefix bool
|
||||
}
|
||||
|
||||
// NewLogConsumer creates a new LogConsumer
|
||||
func NewLogConsumer(ctx context.Context, w io.Writer, color bool, prefix bool) api.LogConsumer {
|
||||
return &logConsumer{
|
||||
|
@ -101,16 +111,6 @@ func (l *logConsumer) computeWidth() {
|
|||
l.width = width + 1
|
||||
}
|
||||
|
||||
// LogConsumer consume logs from services and format them
|
||||
type logConsumer struct {
|
||||
ctx context.Context
|
||||
presenters sync.Map // map[string]*presenter
|
||||
width int
|
||||
writer io.Writer
|
||||
color bool
|
||||
prefix bool
|
||||
}
|
||||
|
||||
type presenter struct {
|
||||
colors colorFunc
|
||||
name string
|
||||
|
|
|
@ -553,7 +553,7 @@ func (s composeService) getLinks(ctx context.Context, projectName string, servic
|
|||
containerName := getCanonicalContainerName(c)
|
||||
links = append(links,
|
||||
format(containerName, linkName),
|
||||
format(containerName, strings.Join([]string{linkServiceName, strconv.Itoa(number)}, Separator)),
|
||||
format(containerName, linkServiceName+Separator+strconv.Itoa(number)),
|
||||
format(containerName, strings.Join([]string{projectName, linkServiceName, strconv.Itoa(number)}, Separator)),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -263,7 +263,7 @@ func (s *composeService) copyFromContainer(ctx context.Context, containerID, src
|
|||
}
|
||||
|
||||
preArchive := content
|
||||
if len(srcInfo.RebaseName) != 0 {
|
||||
if srcInfo.RebaseName != "" {
|
||||
_, srcBase := archive.SplitPathDirEntry(srcInfo.Path)
|
||||
preArchive = archive.RebaseArchiveEntries(content, srcBase, srcInfo.RebaseName)
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import (
|
|||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/compose-spec/compose-go/types"
|
||||
composetypes "github.com/compose-spec/compose-go/types"
|
||||
"github.com/docker/compose/v2/pkg/api"
|
||||
moby "github.com/docker/docker/api/types"
|
||||
|
@ -66,17 +65,17 @@ func TestBuildVolumeMount(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestServiceImageName(t *testing.T) {
|
||||
assert.Equal(t, getImageName(types.ServiceConfig{Image: "myImage"}, "myProject"), "myImage")
|
||||
assert.Equal(t, getImageName(types.ServiceConfig{Name: "aService"}, "myProject"), "myProject_aService")
|
||||
assert.Equal(t, getImageName(composetypes.ServiceConfig{Image: "myImage"}, "myProject"), "myImage")
|
||||
assert.Equal(t, getImageName(composetypes.ServiceConfig{Name: "aService"}, "myProject"), "myProject_aService")
|
||||
}
|
||||
|
||||
func TestPrepareNetworkLabels(t *testing.T) {
|
||||
project := types.Project{
|
||||
project := composetypes.Project{
|
||||
Name: "myProject",
|
||||
Networks: types.Networks(map[string]types.NetworkConfig{"skynet": {}}),
|
||||
Networks: composetypes.Networks(map[string]composetypes.NetworkConfig{"skynet": {}}),
|
||||
}
|
||||
prepareNetworks(&project)
|
||||
assert.DeepEqual(t, project.Networks["skynet"].Labels, types.Labels(map[string]string{
|
||||
assert.DeepEqual(t, project.Networks["skynet"].Labels, composetypes.Labels(map[string]string{
|
||||
"com.docker.compose.network": "skynet",
|
||||
"com.docker.compose.project": "myProject",
|
||||
"com.docker.compose.version": api.ComposeVersion,
|
||||
|
|
|
@ -32,6 +32,11 @@ type logPrinter interface {
|
|||
Cancel()
|
||||
}
|
||||
|
||||
type printer struct {
|
||||
queue chan api.ContainerEvent
|
||||
consumer api.LogConsumer
|
||||
}
|
||||
|
||||
// newLogPrinter builds a LogPrinter passing containers logs to LogConsumer
|
||||
func newLogPrinter(consumer api.LogConsumer) logPrinter {
|
||||
queue := make(chan api.ContainerEvent)
|
||||
|
@ -48,11 +53,6 @@ func (p *printer) Cancel() {
|
|||
}
|
||||
}
|
||||
|
||||
type printer struct {
|
||||
queue chan api.ContainerEvent
|
||||
consumer api.LogConsumer
|
||||
}
|
||||
|
||||
func (p *printer) HandleEvent(event api.ContainerEvent) {
|
||||
p.queue <- event
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue