Skip to content

Commit 03cd8d7

Browse files
committed
switch to newer packages for docker
Signed-off-by: Davanum Srinivas <[email protected]>
1 parent 333c040 commit 03cd8d7

File tree

5 files changed

+22
-16
lines changed

5 files changed

+22
-16
lines changed

container/containerd/client.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ func Client(address, namespace string) (ContainerdClient, error) {
7878
}
7979
connParams.Backoff.BaseDelay = baseBackoffDelay
8080
connParams.Backoff.MaxDelay = maxBackoffDelay
81+
//nolint:staticcheck // SA1019
8182
gopts := []grpc.DialOption{
8283
grpc.WithTransportCredentials(insecure.NewCredentials()),
8384
grpc.WithContextDialer(dialer.ContextDialer),
@@ -93,6 +94,7 @@ func Client(address, namespace string) (ContainerdClient, error) {
9394

9495
ctx, cancel := context.WithTimeout(context.Background(), connectionTimeout)
9596
defer cancel()
97+
//nolint:staticcheck // SA1019
9698
conn, err := grpc.DialContext(ctx, dialer.DialAddress(address), gopts...)
9799
if err != nil {
98100
retErr = err

container/docker/docker.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ import (
2121
"strconv"
2222
"time"
2323

24-
dockertypes "github.com/docker/docker/api/types"
24+
dockerimage "github.com/docker/docker/api/types/image"
25+
dockersystem "github.com/docker/docker/api/types/system"
2526
"golang.org/x/net/context"
2627

2728
"github.com/google/cadvisor/container/docker/utils"
@@ -56,7 +57,7 @@ func StatusWithContext(ctx context.Context) (v1.DockerStatus, error) {
5657
return StatusFromDockerInfo(dockerInfo)
5758
}
5859

59-
func StatusFromDockerInfo(dockerInfo dockertypes.Info) (v1.DockerStatus, error) {
60+
func StatusFromDockerInfo(dockerInfo dockersystem.Info) (v1.DockerStatus, error) {
6061
out := v1.DockerStatus{}
6162
out.KernelVersion = machine.KernelVersion()
6263
out.OS = dockerInfo.OperatingSystem
@@ -88,7 +89,7 @@ func Images() ([]v1.DockerImage, error) {
8889
if err != nil {
8990
return nil, fmt.Errorf("unable to communicate with docker daemon: %v", err)
9091
}
91-
summaries, err := client.ImageList(defaultContext(), dockertypes.ImageListOptions{All: false})
92+
summaries, err := client.ImageList(defaultContext(), dockerimage.ListOptions{All: false})
9293
if err != nil {
9394
return nil, err
9495
}
@@ -97,7 +98,7 @@ func Images() ([]v1.DockerImage, error) {
9798

9899
// Checks whether the dockerInfo reflects a valid docker setup, and returns it if it does, or an
99100
// error otherwise.
100-
func ValidateInfo(GetInfo func() (*dockertypes.Info, error), ServerVersion func() (string, error)) (*dockertypes.Info, error) {
101+
func ValidateInfo(GetInfo func() (*dockersystem.Info, error), ServerVersion func() (string, error)) (*dockersystem.Info, error) {
101102
info, err := GetInfo()
102103
if err != nil {
103104
return nil, err
@@ -128,7 +129,7 @@ func ValidateInfo(GetInfo func() (*dockertypes.Info, error), ServerVersion func(
128129
return info, nil
129130
}
130131

131-
func Info() (*dockertypes.Info, error) {
132+
func Info() (*dockersystem.Info, error) {
132133
client, err := Client()
133134
if err != nil {
134135
return nil, fmt.Errorf("unable to communicate with docker daemon: %v", err)

container/docker/factory.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"time"
2525

2626
"github.com/blang/semver/v4"
27-
dockertypes "github.com/docker/docker/api/types"
27+
dockersystem "github.com/docker/docker/api/types/system"
2828

2929
"github.com/google/cadvisor/container"
3030
dockerutil "github.com/google/cadvisor/container/docker/utils"
@@ -194,7 +194,7 @@ var (
194194
apiVersionRe = regexp.MustCompile(apiVersionRegexpString)
195195
)
196196

197-
func StartThinPoolWatcher(dockerInfo *dockertypes.Info) (*devicemapper.ThinPoolWatcher, error) {
197+
func StartThinPoolWatcher(dockerInfo *dockersystem.Info) (*devicemapper.ThinPoolWatcher, error) {
198198
_, err := devicemapper.ThinLsBinaryPresent()
199199
if err != nil {
200200
return nil, err
@@ -227,7 +227,7 @@ func StartThinPoolWatcher(dockerInfo *dockertypes.Info) (*devicemapper.ThinPoolW
227227
return thinPoolWatcher, nil
228228
}
229229

230-
func StartZfsWatcher(dockerInfo *dockertypes.Info) (*zfs.ZfsWatcher, error) {
230+
func StartZfsWatcher(dockerInfo *dockersystem.Info) (*zfs.ZfsWatcher, error) {
231231
filesystem, err := dockerutil.DockerZfsFilesystem(*dockerInfo)
232232
if err != nil {
233233
return nil, err

container/docker/utils/docker.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ import (
2121
"regexp"
2222
"strings"
2323

24-
dockertypes "github.com/docker/docker/api/types"
24+
dockerimage "github.com/docker/docker/api/types/image"
25+
dockersystem "github.com/docker/docker/api/types/system"
2526
v1 "github.com/google/cadvisor/info/v1"
2627
)
2728

@@ -45,7 +46,7 @@ func DriverStatusValue(status [][2]string, target string) string {
4546
return ""
4647
}
4748

48-
func DockerThinPoolName(info dockertypes.Info) (string, error) {
49+
func DockerThinPoolName(info dockersystem.Info) (string, error) {
4950
poolName := DriverStatusValue(info.DriverStatus, DriverStatusPoolName)
5051
if len(poolName) == 0 {
5152
return "", fmt.Errorf("Could not get devicemapper pool name")
@@ -54,7 +55,7 @@ func DockerThinPoolName(info dockertypes.Info) (string, error) {
5455
return poolName, nil
5556
}
5657

57-
func DockerMetadataDevice(info dockertypes.Info) (string, error) {
58+
func DockerMetadataDevice(info dockersystem.Info) (string, error) {
5859
metadataDevice := DriverStatusValue(info.DriverStatus, DriverStatusMetadataFile)
5960
if len(metadataDevice) != 0 {
6061
return metadataDevice, nil
@@ -74,7 +75,7 @@ func DockerMetadataDevice(info dockertypes.Info) (string, error) {
7475
return metadataDevice, nil
7576
}
7677

77-
func DockerZfsFilesystem(info dockertypes.Info) (string, error) {
78+
func DockerZfsFilesystem(info dockersystem.Info) (string, error) {
7879
filesystem := DriverStatusValue(info.DriverStatus, DriverStatusParentDataset)
7980
if len(filesystem) == 0 {
8081
return "", fmt.Errorf("Could not get zfs filesystem")
@@ -83,7 +84,7 @@ func DockerZfsFilesystem(info dockertypes.Info) (string, error) {
8384
return filesystem, nil
8485
}
8586

86-
func SummariesToImages(summaries []dockertypes.ImageSummary) ([]v1.DockerImage, error) {
87+
func SummariesToImages(summaries []dockerimage.Summary) ([]v1.DockerImage, error) {
8788
var out []v1.DockerImage
8889
const unknownTag = "<none>:<none>"
8990
for _, summary := range summaries {

container/podman/podman.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import (
2323
"time"
2424

2525
dockertypes "github.com/docker/docker/api/types"
26+
dockerimage "github.com/docker/docker/api/types/image"
27+
dockersystem "github.com/docker/docker/api/types/system"
2628
"github.com/pkg/errors"
2729

2830
"github.com/google/cadvisor/container/docker"
@@ -92,7 +94,7 @@ func apiGetRequest(url string, item interface{}) error {
9294
}
9395

9496
func Images() ([]v1.DockerImage, error) {
95-
var summaries []dockertypes.ImageSummary
97+
var summaries []dockerimage.Summary
9698
err := apiGetRequest("http://d/v1.0.0/images/json", &summaries)
9799
if err != nil {
98100
return nil, err
@@ -109,8 +111,8 @@ func Status() (v1.DockerStatus, error) {
109111
return docker.StatusFromDockerInfo(*podmanInfo)
110112
}
111113

112-
func GetInfo() (*dockertypes.Info, error) {
113-
var info dockertypes.Info
114+
func GetInfo() (*dockersystem.Info, error) {
115+
var info dockersystem.Info
114116
err := apiGetRequest("http://d/v1.0.0/info", &info)
115117
return &info, err
116118
}

0 commit comments

Comments
 (0)