From 1c6f64e2542a89ff3dd127b9d973391cf949fd5d Mon Sep 17 00:00:00 2001 From: Frederik Ring Date: Tue, 25 Jul 2023 19:46:57 +0200 Subject: [PATCH] Current Docker client breaks in newer Go versions (#241) * Current Docker client breaks in newer Go versions * Cater for breaking API changes in Docker client * Update Docker client * Unpin Go version used for build * Tidy sum file --- Dockerfile | 2 +- cmd/backup/exec.go | 3 --- cmd/backup/script.go | 8 +++----- go.mod | 2 +- go.sum | 4 ++-- 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2934c0a..42249c4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # Copyright 2021 - Offen Authors # SPDX-License-Identifier: MPL-2.0 -FROM golang:1.20.5-alpine as builder +FROM golang:1.20-alpine as builder WORKDIR /app COPY . . diff --git a/cmd/backup/exec.go b/cmd/backup/exec.go index 235c69c..fa2ee81 100644 --- a/cmd/backup/exec.go +++ b/cmd/backup/exec.go @@ -91,7 +91,6 @@ func (s *script) runLabeledCommands(label string) error { }) } containersWithCommand, err := s.cli.ContainerList(context.Background(), types.ContainerListOptions{ - Quiet: true, Filters: filters.NewArgs(f...), }) if err != nil { @@ -105,7 +104,6 @@ func (s *script) runLabeledCommands(label string) error { Value: "docker-volume-backup.exec-pre", } deprecatedContainers, err := s.cli.ContainerList(context.Background(), types.ContainerListOptions{ - Quiet: true, Filters: filters.NewArgs(f...), }) if err != nil { @@ -123,7 +121,6 @@ func (s *script) runLabeledCommands(label string) error { Value: "docker-volume-backup.exec-post", } deprecatedContainers, err := s.cli.ContainerList(context.Background(), types.ContainerListOptions{ - Quiet: true, Filters: filters.NewArgs(f...), }) if err != nil { diff --git a/cmd/backup/script.go b/cmd/backup/script.go index 148e8e0..ba2cb2a 100644 --- a/cmd/backup/script.go +++ b/cmd/backup/script.go @@ -25,6 +25,7 @@ import ( "github.com/containrrr/shoutrrr" "github.com/containrrr/shoutrrr/pkg/router" "github.com/docker/docker/api/types" + ctr "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/client" @@ -281,9 +282,7 @@ func (s *script) stopContainers() (func() error, error) { return noop, nil } - allContainers, err := s.cli.ContainerList(context.Background(), types.ContainerListOptions{ - Quiet: true, - }) + allContainers, err := s.cli.ContainerList(context.Background(), types.ContainerListOptions{}) if err != nil { return noop, fmt.Errorf("stopContainers: error querying for containers: %w", err) } @@ -293,7 +292,6 @@ func (s *script) stopContainers() (func() error, error) { s.c.BackupStopContainerLabel, ) containersToStop, err := s.cli.ContainerList(context.Background(), types.ContainerListOptions{ - Quiet: true, Filters: filters.NewArgs(filters.KeyValuePair{ Key: "label", Value: containerLabel, @@ -318,7 +316,7 @@ func (s *script) stopContainers() (func() error, error) { var stoppedContainers []types.Container var stopErrors []error for _, container := range containersToStop { - if err := s.cli.ContainerStop(context.Background(), container.ID, nil); err != nil { + if err := s.cli.ContainerStop(context.Background(), container.ID, ctr.StopOptions{}); err != nil { stopErrors = append(stopErrors, err) } else { stoppedContainers = append(stoppedContainers, container) diff --git a/go.mod b/go.mod index ebbcbaa..efc041d 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.1.0 github.com/containrrr/shoutrrr v0.7.1 github.com/cosiner/argv v0.1.0 - github.com/docker/docker v20.10.24+incompatible + github.com/docker/docker v24.0.5+incompatible github.com/gofrs/flock v0.8.1 github.com/kelseyhightower/envconfig v1.4.0 github.com/leekchan/timeutil v0.0.0-20150802142658-28917288c48d diff --git a/go.sum b/go.sum index b115d42..ffb9230 100644 --- a/go.sum +++ b/go.sum @@ -249,8 +249,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v20.10.24+incompatible h1:Ugvxm7a8+Gz6vqQYQQ2W7GYq5EUPaAiuPgIfVyI3dYE= -github.com/docker/docker v20.10.24+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v24.0.5+incompatible h1:WmgcE4fxyI6EEXxBRxsHnZXrO1pQ3smi0k/jho4HLeY= +github.com/docker/docker v24.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw=