Skip to content

Commit 826f029

Browse files
committed
Fix types
1 parent c7b5868 commit 826f029

File tree

4 files changed

+22
-27
lines changed

4 files changed

+22
-27
lines changed

.golangci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
linters:
2-
disable:
3-
- structcheck # gives false positives
42
enable:
53
- gofumpt
64
- thelper
75
- goimports
86
- tparallel
97
- wastedassign
10-
- exportloopref
118
- unparam
129
- prealloc
1310
- unconvert

pkg/commands/container.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ import (
77
"strings"
88

99
"github.com/docker/docker/api/types/container"
10-
"github.com/sasha-s/go-deadlock"
11-
12-
dockerTypes "github.com/docker/docker/api/types"
1310
"github.com/docker/docker/api/types/filters"
1411
"github.com/docker/docker/client"
1512
"github.com/go-errors/errors"
1613
"github.com/jesseduffield/lazydocker/pkg/i18n"
1714
"github.com/jesseduffield/lazydocker/pkg/utils"
15+
"github.com/sasha-s/go-deadlock"
1816
"github.com/sirupsen/logrus"
1917
"golang.org/x/xerrors"
2018
)
@@ -29,12 +27,12 @@ type Container struct {
2927
OneOff bool
3028
ProjectName string
3129
ID string
32-
Container dockerTypes.Container
30+
Container container.Summary
3331
Client *client.Client
3432
OSCommand *OSCommand
3533
Log *logrus.Entry
3634
StatHistory []*RecordedStats
37-
Details dockerTypes.ContainerJSON
35+
Details container.InspectResponse
3836
MonitoringStats bool
3937
DockerCommand LimitedDockerCommand
4038
Tr *i18n.TranslationSet
@@ -105,15 +103,15 @@ func (c *Container) Attach() (*exec.Cmd, error) {
105103
}
106104

107105
// Top returns process information
108-
func (c *Container) Top(ctx context.Context) (container.ContainerTopOKBody, error) {
106+
func (c *Container) Top(ctx context.Context) (container.TopResponse, error) {
109107
detail, err := c.Inspect()
110108
if err != nil {
111-
return container.ContainerTopOKBody{}, err
109+
return container.TopResponse{}, err
112110
}
113111

114112
// check container status
115113
if !detail.State.Running {
116-
return container.ContainerTopOKBody{}, errors.New("container is not running")
114+
return container.TopResponse{}, errors.New("container is not running")
117115
}
118116

119117
return c.Client.ContainerTop(ctx, c.ID, []string{})
@@ -126,7 +124,7 @@ func (c *DockerCommand) PruneContainers() error {
126124
}
127125

128126
// Inspect returns details about the container
129-
func (c *Container) Inspect() (dockerTypes.ContainerJSON, error) {
127+
func (c *Container) Inspect() (container.InspectResponse, error) {
130128
return c.Client.ContainerInspect(context.Background(), c.ID)
131129
}
132130

pkg/gui/presentation/containers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"strconv"
77
"strings"
88

9-
dockerTypes "github.com/docker/docker/api/types"
9+
"github.com/docker/docker/api/types/container"
1010
"github.com/fatih/color"
1111
"github.com/jesseduffield/lazydocker/pkg/commands"
1212
"github.com/jesseduffield/lazydocker/pkg/config"
@@ -30,7 +30,7 @@ func displayContainerImage(container *commands.Container) string {
3030
}
3131

3232
func displayPorts(c *commands.Container) string {
33-
portStrings := lo.Map(c.Container.Ports, func(port dockerTypes.Port, _ int) string {
33+
portStrings := lo.Map(c.Container.Ports, func(port container.Port, _ int) string {
3434
if port.PublicPort == 0 {
3535
return fmt.Sprintf("%d/%s", port.PrivatePort, port.Type)
3636
}

pkg/gui/sort_container_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"sort"
55
"testing"
66

7-
dockerTypes "github.com/docker/docker/api/types"
7+
"github.com/docker/docker/api/types/container"
88
"github.com/jesseduffield/lazydocker/pkg/commands"
99
"github.com/stretchr/testify/assert"
1010
)
@@ -14,28 +14,28 @@ func sampleContainers() []*commands.Container {
1414
{
1515
ID: "1",
1616
Name: "1",
17-
Container: dockerTypes.Container{
17+
Container: container.Summary{
1818
State: "exited",
1919
},
2020
},
2121
{
2222
ID: "2",
2323
Name: "2",
24-
Container: dockerTypes.Container{
24+
Container: container.Summary{
2525
State: "running",
2626
},
2727
},
2828
{
2929
ID: "3",
3030
Name: "3",
31-
Container: dockerTypes.Container{
31+
Container: container.Summary{
3232
State: "running",
3333
},
3434
},
3535
{
3636
ID: "4",
3737
Name: "4",
38-
Container: dockerTypes.Container{
38+
Container: container.Summary{
3939
State: "created",
4040
},
4141
},
@@ -47,28 +47,28 @@ func expectedPerStatusContainers() []*commands.Container {
4747
{
4848
ID: "2",
4949
Name: "2",
50-
Container: dockerTypes.Container{
50+
Container: container.Summary{
5151
State: "running",
5252
},
5353
},
5454
{
5555
ID: "3",
5656
Name: "3",
57-
Container: dockerTypes.Container{
57+
Container: container.Summary{
5858
State: "running",
5959
},
6060
},
6161
{
6262
ID: "1",
6363
Name: "1",
64-
Container: dockerTypes.Container{
64+
Container: container.Summary{
6565
State: "exited",
6666
},
6767
},
6868
{
6969
ID: "4",
7070
Name: "4",
71-
Container: dockerTypes.Container{
71+
Container: container.Summary{
7272
State: "created",
7373
},
7474
},
@@ -80,28 +80,28 @@ func expectedLegacySortedContainers() []*commands.Container {
8080
{
8181
ID: "1",
8282
Name: "1",
83-
Container: dockerTypes.Container{
83+
Container: container.Summary{
8484
State: "exited",
8585
},
8686
},
8787
{
8888
ID: "2",
8989
Name: "2",
90-
Container: dockerTypes.Container{
90+
Container: container.Summary{
9191
State: "running",
9292
},
9393
},
9494
{
9595
ID: "3",
9696
Name: "3",
97-
Container: dockerTypes.Container{
97+
Container: container.Summary{
9898
State: "running",
9999
},
100100
},
101101
{
102102
ID: "4",
103103
Name: "4",
104-
Container: dockerTypes.Container{
104+
Container: container.Summary{
105105
State: "created",
106106
},
107107
},

0 commit comments

Comments
 (0)