Skip to content

Commit

Permalink
go.mod: github.com/docker/docker, docker/cli v25.0.5
Browse files Browse the repository at this point in the history
Update to v25.0, and remove uses of deprecated types.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed Jul 15, 2024
1 parent c84bb88 commit 0232610
Show file tree
Hide file tree
Showing 348 changed files with 41,986 additions and 2,740 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=${GOARCH} GOARM=${GOARM} \
FROM ${BASE_IMAGE_BUILDER}:${GO_VERSION}-alpine${ALPINE_VERSION} AS docker-builder
ARG GOARCH=amd64
ARG GOARM
ARG DOCKER_VERSION=v24.0.7
ARG DOCKER_VERSION=v25.0.5
RUN apk add -U -q --progress --no-cache git bash coreutils gcc musl-dev
WORKDIR /go/src/github.com/docker/cli
RUN git clone --branch ${DOCKER_VERSION} --single-branch --depth 1 https://github.com/docker/cli.git . > /dev/null 2>&1
Expand Down
22 changes: 16 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module github.com/jesseduffield/lazydocker

go 1.20
go 1.21

require (
github.com/OpenPeeDeeP/xdg v0.2.1-0.20190312153938-4ba9e1eb294c
github.com/boz/go-throttle v0.0.0-20160922054636-fdc4eab740c1
github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21
github.com/docker/cli v24.0.7+incompatible
github.com/docker/docker v24.0.7+incompatible
github.com/docker/cli v25.0.5+incompatible
github.com/docker/docker v25.0.5+incompatible
github.com/fatih/color v1.10.0
github.com/go-errors/errors v1.5.1
github.com/gookit/color v1.5.0
Expand All @@ -31,15 +31,19 @@ require (
)

require (
github.com/Microsoft/go-winio v0.5.3 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/docker-credential-helpers v0.8.0 // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fvbommel/sortorder v1.1.0 // indirect
github.com/gdamore/encoding v1.0.1 // indirect
github.com/gdamore/tcell/v2 v2.7.4 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/goccy/go-yaml v1.11.0
github.com/gogo/protobuf v1.3.2 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
Expand All @@ -55,8 +59,14 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect
go.opentelemetry.io/otel v1.28.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 // indirect
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/otel/sdk v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/exp v0.0.0-20220428152302-39d4317da171 // indirect
golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
Expand Down
78 changes: 63 additions & 15 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/commands/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type Container struct {
}

// Remove removes the container
func (c *Container) Remove(options dockerTypes.ContainerRemoveOptions) error {
func (c *Container) Remove(options container.RemoveOptions) error {
c.Log.Warn(fmt.Sprintf("removing container %s", c.Name))
if err := c.Client.ContainerRemove(context.Background(), c.ID, options); err != nil {
if strings.Contains(err.Error(), "Stop the container before attempting removal or force remove") {
Expand Down
38 changes: 19 additions & 19 deletions pkg/commands/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
cliconfig "github.com/docker/cli/cli/config"
ddocker "github.com/docker/cli/cli/context/docker"
ctxstore "github.com/docker/cli/cli/context/store"
dockerTypes "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/client"
"github.com/imdario/mergo"
"github.com/jesseduffield/lazydocker/pkg/commands/ssh"
Expand Down Expand Up @@ -200,9 +200,9 @@ func (c *DockerCommand) RefreshContainersAndServices(currentServices []*Service,
func (c *DockerCommand) assignContainersToServices(containers []*Container, services []*Service) {
L:
for _, service := range services {
for _, container := range containers {
if !container.OneOff && container.ServiceName == service.Name {
service.Container = container
for _, ctr := range containers {
if !ctr.OneOff && ctr.ServiceName == service.Name {
service.Container = ctr
continue L
}
}
Expand All @@ -215,19 +215,19 @@ func (c *DockerCommand) GetContainers(existingContainers []*Container) ([]*Conta
c.ContainerMutex.Lock()
defer c.ContainerMutex.Unlock()

containers, err := c.Client.ContainerList(context.Background(), dockerTypes.ContainerListOptions{All: true})
containers, err := c.Client.ContainerList(context.Background(), container.ListOptions{All: true})
if err != nil {
return nil, err
}

ownContainers := make([]*Container, len(containers))

for i, container := range containers {
for i, ctr := range containers {
var newContainer *Container

// check if we already have data stored against the container
for _, existingContainer := range existingContainers {
if existingContainer.ID == container.ID {
if existingContainer.ID == ctr.ID {
newContainer = existingContainer
break
}
Expand All @@ -236,7 +236,7 @@ func (c *DockerCommand) GetContainers(existingContainers []*Container) ([]*Conta
// initialise the container if it's completely new
if newContainer == nil {
newContainer = &Container{
ID: container.ID,
ID: ctr.ID,
Client: c.Client,
OSCommand: c.OSCommand,
Log: c.Log,
Expand All @@ -245,17 +245,17 @@ func (c *DockerCommand) GetContainers(existingContainers []*Container) ([]*Conta
}
}

newContainer.Container = container
newContainer.Container = ctr
// if the container is made with a name label we will use that
if name, ok := container.Labels["name"]; ok {
if name, ok := ctr.Labels["name"]; ok {
newContainer.Name = name
} else {
newContainer.Name = strings.TrimLeft(container.Names[0], "/")
newContainer.Name = strings.TrimLeft(ctr.Names[0], "/")
}
newContainer.ServiceName = container.Labels["com.docker.compose.service"]
newContainer.ProjectName = container.Labels["com.docker.compose.project"]
newContainer.ContainerNumber = container.Labels["com.docker.compose.container"]
newContainer.OneOff = container.Labels["com.docker.compose.oneoff"] == "True"
newContainer.ServiceName = ctr.Labels["com.docker.compose.service"]
newContainer.ProjectName = ctr.Labels["com.docker.compose.project"]
newContainer.ContainerNumber = ctr.Labels["com.docker.compose.container"]
newContainer.OneOff = ctr.Labels["com.docker.compose.oneoff"] == "True"

ownContainers[i] = newContainer
}
Expand Down Expand Up @@ -309,15 +309,15 @@ func (c *DockerCommand) RefreshContainerDetails(containers []*Container) error {
// this contains a bit more info than what you get from the go-docker client
func (c *DockerCommand) SetContainerDetails(containers []*Container) {
wg := sync.WaitGroup{}
for _, container := range containers {
container := container
for _, ctr := range containers {
ctr := ctr
wg.Add(1)
go func() {
details, err := c.Client.ContainerInspect(context.Background(), container.ID)
details, err := c.Client.ContainerInspect(context.Background(), ctr.ID)
if err != nil {
c.Log.Error(err)
} else {
container.Details = details
ctr.Details = details
}
wg.Done()
}()
Expand Down
7 changes: 3 additions & 4 deletions pkg/commands/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import (
"context"
"strings"

"github.com/docker/docker/api/types/image"
"github.com/samber/lo"

dockerTypes "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/image"
"github.com/docker/docker/client"
"github.com/fatih/color"
"github.com/jesseduffield/lazydocker/pkg/utils"
"github.com/samber/lo"
"github.com/sirupsen/logrus"
)

Expand All @@ -20,7 +19,7 @@ type Image struct {
Name string
Tag string
ID string
Image dockerTypes.ImageSummary
Image image.Summary
Client *client.Client
OSCommand *OSCommand
Log *logrus.Entry
Expand Down
6 changes: 3 additions & 3 deletions pkg/commands/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"os/exec"

dockerTypes "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/jesseduffield/lazydocker/pkg/utils"
"github.com/sirupsen/logrus"
)
Expand All @@ -20,7 +20,7 @@ type Service struct {
}

// Remove removes the service's containers
func (s *Service) Remove(options dockerTypes.ContainerRemoveOptions) error {
func (s *Service) Remove(options container.RemoveOptions) error {
return s.Container.Remove(options)
}

Expand All @@ -39,7 +39,7 @@ func (s *Service) Restart() error {
return s.runCommand(s.OSCommand.Config.UserConfig.CommandTemplates.RestartService)
}

// Restart starts the service
// Start starts the service
func (s *Service) Start() error {
return s.runCommand(s.OSCommand.Config.UserConfig.CommandTemplates.StartService)
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/gui/container_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"os/signal"
"time"

dockerTypes "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/pkg/stdcopy"
"github.com/fatih/color"
"github.com/jesseduffield/lazydocker/pkg/commands"
Expand Down Expand Up @@ -104,8 +104,8 @@ func (gui *Gui) promptToReturn() {
}
}

func (gui *Gui) writeContainerLogs(container *commands.Container, ctx context.Context, writer io.Writer) error {
readCloser, err := gui.DockerCommand.Client.ContainerLogs(ctx, container.ID, dockerTypes.ContainerLogsOptions{
func (gui *Gui) writeContainerLogs(ctr *commands.Container, ctx context.Context, writer io.Writer) error {
readCloser, err := gui.DockerCommand.Client.ContainerLogs(ctx, ctr.ID, container.LogsOptions{
ShowStdout: true,
ShowStderr: true,
Timestamps: gui.Config.UserConfig.Logs.Timestamps,
Expand All @@ -119,7 +119,7 @@ func (gui *Gui) writeContainerLogs(container *commands.Container, ctx context.Co
}
defer readCloser.Close()

if !container.DetailsLoaded() {
if !ctr.DetailsLoaded() {
// loop until the details load or context is cancelled, using timer
ticker := time.NewTicker(time.Millisecond * 100)
defer ticker.Stop()
Expand All @@ -129,14 +129,14 @@ func (gui *Gui) writeContainerLogs(container *commands.Container, ctx context.Co
case <-ctx.Done():
return nil
case <-ticker.C:
if container.DetailsLoaded() {
if ctr.DetailsLoaded() {
break outer
}
}
}
}

if container.Details.Config.Tty {
if ctr.Details.Config.Tty {
_, err = io.Copy(writer, readCloser)
if err != nil {
return err
Expand Down
Loading

0 comments on commit 0232610

Please sign in to comment.