mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-22 15:11:02 +00:00
Fix types
This commit is contained in:
parent
c7b58683ae
commit
826f0293f1
4 changed files with 22 additions and 27 deletions
|
|
@ -1,13 +1,10 @@
|
|||
linters:
|
||||
disable:
|
||||
- structcheck # gives false positives
|
||||
enable:
|
||||
- gofumpt
|
||||
- thelper
|
||||
- goimports
|
||||
- tparallel
|
||||
- wastedassign
|
||||
- exportloopref
|
||||
- unparam
|
||||
- prealloc
|
||||
- unconvert
|
||||
|
|
|
|||
|
|
@ -7,14 +7,12 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/sasha-s/go-deadlock"
|
||||
|
||||
dockerTypes "github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/go-errors/errors"
|
||||
"github.com/jesseduffield/lazydocker/pkg/i18n"
|
||||
"github.com/jesseduffield/lazydocker/pkg/utils"
|
||||
"github.com/sasha-s/go-deadlock"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/xerrors"
|
||||
)
|
||||
|
|
@ -29,12 +27,12 @@ type Container struct {
|
|||
OneOff bool
|
||||
ProjectName string
|
||||
ID string
|
||||
Container dockerTypes.Container
|
||||
Container container.Summary
|
||||
Client *client.Client
|
||||
OSCommand *OSCommand
|
||||
Log *logrus.Entry
|
||||
StatHistory []*RecordedStats
|
||||
Details dockerTypes.ContainerJSON
|
||||
Details container.InspectResponse
|
||||
MonitoringStats bool
|
||||
DockerCommand LimitedDockerCommand
|
||||
Tr *i18n.TranslationSet
|
||||
|
|
@ -105,15 +103,15 @@ func (c *Container) Attach() (*exec.Cmd, error) {
|
|||
}
|
||||
|
||||
// Top returns process information
|
||||
func (c *Container) Top(ctx context.Context) (container.ContainerTopOKBody, error) {
|
||||
func (c *Container) Top(ctx context.Context) (container.TopResponse, error) {
|
||||
detail, err := c.Inspect()
|
||||
if err != nil {
|
||||
return container.ContainerTopOKBody{}, err
|
||||
return container.TopResponse{}, err
|
||||
}
|
||||
|
||||
// check container status
|
||||
if !detail.State.Running {
|
||||
return container.ContainerTopOKBody{}, errors.New("container is not running")
|
||||
return container.TopResponse{}, errors.New("container is not running")
|
||||
}
|
||||
|
||||
return c.Client.ContainerTop(ctx, c.ID, []string{})
|
||||
|
|
@ -126,7 +124,7 @@ func (c *DockerCommand) PruneContainers() error {
|
|||
}
|
||||
|
||||
// Inspect returns details about the container
|
||||
func (c *Container) Inspect() (dockerTypes.ContainerJSON, error) {
|
||||
func (c *Container) Inspect() (container.InspectResponse, error) {
|
||||
return c.Client.ContainerInspect(context.Background(), c.ID)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
dockerTypes "github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/fatih/color"
|
||||
"github.com/jesseduffield/lazydocker/pkg/commands"
|
||||
"github.com/jesseduffield/lazydocker/pkg/config"
|
||||
|
|
@ -30,7 +30,7 @@ func displayContainerImage(container *commands.Container) string {
|
|||
}
|
||||
|
||||
func displayPorts(c *commands.Container) string {
|
||||
portStrings := lo.Map(c.Container.Ports, func(port dockerTypes.Port, _ int) string {
|
||||
portStrings := lo.Map(c.Container.Ports, func(port container.Port, _ int) string {
|
||||
if port.PublicPort == 0 {
|
||||
return fmt.Sprintf("%d/%s", port.PrivatePort, port.Type)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"sort"
|
||||
"testing"
|
||||
|
||||
dockerTypes "github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/jesseduffield/lazydocker/pkg/commands"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
|
@ -14,28 +14,28 @@ func sampleContainers() []*commands.Container {
|
|||
{
|
||||
ID: "1",
|
||||
Name: "1",
|
||||
Container: dockerTypes.Container{
|
||||
Container: container.Summary{
|
||||
State: "exited",
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "2",
|
||||
Name: "2",
|
||||
Container: dockerTypes.Container{
|
||||
Container: container.Summary{
|
||||
State: "running",
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "3",
|
||||
Name: "3",
|
||||
Container: dockerTypes.Container{
|
||||
Container: container.Summary{
|
||||
State: "running",
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "4",
|
||||
Name: "4",
|
||||
Container: dockerTypes.Container{
|
||||
Container: container.Summary{
|
||||
State: "created",
|
||||
},
|
||||
},
|
||||
|
|
@ -47,28 +47,28 @@ func expectedPerStatusContainers() []*commands.Container {
|
|||
{
|
||||
ID: "2",
|
||||
Name: "2",
|
||||
Container: dockerTypes.Container{
|
||||
Container: container.Summary{
|
||||
State: "running",
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "3",
|
||||
Name: "3",
|
||||
Container: dockerTypes.Container{
|
||||
Container: container.Summary{
|
||||
State: "running",
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "1",
|
||||
Name: "1",
|
||||
Container: dockerTypes.Container{
|
||||
Container: container.Summary{
|
||||
State: "exited",
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "4",
|
||||
Name: "4",
|
||||
Container: dockerTypes.Container{
|
||||
Container: container.Summary{
|
||||
State: "created",
|
||||
},
|
||||
},
|
||||
|
|
@ -80,28 +80,28 @@ func expectedLegacySortedContainers() []*commands.Container {
|
|||
{
|
||||
ID: "1",
|
||||
Name: "1",
|
||||
Container: dockerTypes.Container{
|
||||
Container: container.Summary{
|
||||
State: "exited",
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "2",
|
||||
Name: "2",
|
||||
Container: dockerTypes.Container{
|
||||
Container: container.Summary{
|
||||
State: "running",
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "3",
|
||||
Name: "3",
|
||||
Container: dockerTypes.Container{
|
||||
Container: container.Summary{
|
||||
State: "running",
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "4",
|
||||
Name: "4",
|
||||
Container: dockerTypes.Container{
|
||||
Container: container.Summary{
|
||||
State: "created",
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue