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