Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Migrate Docker integrations to maintained Moby modules

rcourtmanb666d131b03f
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index 30e668ebae..ca77acec01 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -223,6 +223,14 @@ demo-deploy workflow. Shipped binaries, installable container images, and
governed deployment-build workflows must all carry the same build metadata
contract rather than depending on whichever local ldflags string happened to be
updated last.
+That same dev-runtime dependency-manifest boundary now also owns the maintained
+Docker engine module floor. `go.mod`, `go.sum`, and
+`internal/cloudcp/docker/manager.go` must route hosted runtime orchestration
+through the maintained `github.com/moby/moby/api` and
+`github.com/moby/moby/client` modules instead of reviving the legacy
+`github.com/docker/docker` line, so managed-runtime manifests and hosted
+runtime rollout control do not silently inherit an unfixed Docker SDK
+advisory path.
That same Docker release-build boundary also owns the embedded frontend's
shipped-doc inputs and the Docker context allowlist that makes those files
available to release builds in the first place. When the frontend embed build
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index 0c3d005243..c67f70dec3 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -217,6 +217,13 @@ shared Docker host model, and `internal/monitoring/docker_commands.go` must
refuse Docker daemon-mutating commands when authorization plugins are
configured until the upstream Moby authz-plugin advisory line has a fixed Go
module release.
+That same collector boundary also owns the maintained engine-client seam.
+`internal/dockeragent/docker_client.go`, `internal/dockeragent/collect.go`,
+and `internal/dockeragent/swarm.go` must keep Pulse's package-local
+`dockerClient` interface as the compatibility layer while the underlying
+implementation routes through maintained `github.com/moby/moby/api` and
+`github.com/moby/moby/client` modules, so monitoring runtime collection does
+not drift back onto the legacy `github.com/docker/docker` Go module line.
That same monitoring owner now also governs restart-safe standalone host
continuity for monitored-system usage and admission. `internal/monitoring/monitor_agents.go`
must persist recent host identity at report time, and
diff --git a/go.mod b/go.mod
index 31d03e1422..605aeb4eec 100644
--- a/go.mod
+++ b/go.mod
@@ -6,15 +6,17 @@ toolchain go1.25.9
require (
github.com/IGLOU-EU/go-wildcard/v2 v2.1.0
+ github.com/containerd/errdefs v1.0.0
github.com/coreos/go-oidc/v3 v3.17.0
github.com/crewjam/saml v0.5.1
- github.com/docker/docker v28.5.2+incompatible
github.com/fsnotify/fsnotify v1.9.0
github.com/go-pdf/fpdf v0.9.0
github.com/golang-jwt/jwt/v5 v5.3.1
github.com/google/uuid v1.6.0
github.com/gorilla/websocket v1.5.3
github.com/joho/godotenv v1.5.1
+ github.com/moby/moby/api v1.54.0
+ github.com/moby/moby/client v0.3.0
github.com/oklog/ulid/v2 v2.1.1
github.com/opencontainers/image-spec v1.1.1
github.com/prometheus/client_golang v1.23.2
@@ -37,13 +39,11 @@ require (
)
require (
- github.com/Microsoft/go-winio v0.4.21 // indirect
+ github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/beevik/etree v1.6.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
- github.com/containerd/errdefs v1.0.0 // indirect
github.com/containerd/errdefs/pkg v0.3.0 // indirect
- github.com/containerd/log v0.1.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/go-connections v0.6.0 // indirect
@@ -77,11 +77,8 @@ require (
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
- github.com/moby/sys/atomicwriter v0.1.0 // indirect
- github.com/moby/term v0.5.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
- github.com/morikuni/aec v1.0.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
@@ -92,7 +89,6 @@ require (
github.com/prometheus/procfs v0.19.2 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/russellhaering/goxmldsig v1.6.0 // indirect
- github.com/sirupsen/logrus v1.9.4-0.20230606125235-dd1b4c2e81af // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/tklauser/go-sysconf v0.3.16 // indirect
@@ -102,7 +98,6 @@ require (
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.68.0 // indirect
go.opentelemetry.io/otel v1.43.0 // indirect
- go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.43.0 // indirect
go.opentelemetry.io/otel/metric v1.43.0 // indirect
go.opentelemetry.io/otel/trace v1.43.0 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
@@ -114,7 +109,6 @@ require (
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
- gotest.tools/v3 v3.5.2 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
diff --git a/go.sum b/go.sum
index f887249cb8..d9d802e5d4 100644
--- a/go.sum
+++ b/go.sum
@@ -1,23 +1,17 @@
-github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c h1:udKWzYgxTojEKWjV8V+WSxDXJ4NFATAsZjh8iIbsQIg=
-github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
github.com/IGLOU-EU/go-wildcard/v2 v2.1.0 h1:WFqyYAuIYLJ6mHZ4rp/bYXiR4E1IvXW4+zInYWdQBqI=
github.com/IGLOU-EU/go-wildcard/v2 v2.1.0/go.mod h1:/sUMQ5dk2owR0ZcjRI/4AZ+bUFF5DxGCQrDMNBXUf5o=
-github.com/Microsoft/go-winio v0.4.21 h1:+6mVbXh4wPzUrl1COX9A+ZCvEpYsOBZ6/+kwDnvLyro=
-github.com/Microsoft/go-winio v0.4.21/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
+github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
+github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
github.com/beevik/etree v1.6.0 h1:u8Kwy8pp9D9XeITj2Z0XtA5qqZEmtJtuXZRQi+j03eE=
github.com/beevik/etree v1.6.0/go.mod h1:bh4zJxiIr62SOf9pRzN7UUYaEDa9HEKafK25+sLc0Gc=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
-github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
-github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI=
github.com/containerd/errdefs v1.0.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M=
github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE=
github.com/containerd/errdefs/pkg v0.3.0/go.mod h1:NJw6s9HwNuRhnjJhM7pylWwMyAkmCQvQ4GpJHEqRLVk=
-github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
-github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
github.com/coreos/go-oidc/v3 v3.17.0 h1:hWBGaQfbi0iVviX4ibC7bk8OKT5qNr4klBaCHVNvehc=
github.com/coreos/go-oidc/v3 v3.17.0/go.mod h1:wqPbKFrVnE90vty060SB40FCJ8fTHTxSwyXJqZH+sI8=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
@@ -31,8 +25,6 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
-github.com/docker/docker v28.5.2+incompatible h1:DBX0Y0zAjZbSrm1uzOkdr1onVghKaftjlSWt4AFexzM=
-github.com/docker/docker v28.5.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/go-connections v0.6.0 h1:LlMG9azAe1TqfR7sO+NJttz1gy6KO7VJBh+pMmjSD94=
github.com/docker/go-connections v0.6.0/go.mod h1:AahvXYshr6JgfUJGdDCs2b5EZG/vmaMAntpSFH5BFKE=
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
@@ -94,8 +86,6 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
-github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 h1:HWRh5R2+9EifMyIHV7ZV+MIZqgz+PMpZ14Jynv3O2Zs=
-github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0/go.mod h1:JfhWUomR1baixubs02l85lZYYOm7LV6om4ceouMv45c=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
@@ -134,19 +124,15 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
-github.com/moby/sys/atomicwriter v0.1.0 h1:kw5D/EqkBwsBFi0ss9v1VG3wIkVhzGvLklJ+w3A14Sw=
-github.com/moby/sys/atomicwriter v0.1.0/go.mod h1:Ul8oqv2ZMNHOceF643P6FKPXeCmYtlQMvpizfsSoaWs=
-github.com/moby/sys/sequential v0.6.0 h1:qrx7XFUd/5DxtqcoH1h438hF5TmOvzC/lspjy7zgvCU=
-github.com/moby/sys/sequential v0.6.0/go.mod h1:uyv8EUTrca5PnDsdMGXhZe6CCe8U/UiTWd+lL+7b/Ko=
-github.com/moby/term v0.5.2 h1:6qk3FJAFDs6i/q3W/pQ97SX192qKfZgGjCQqfCJkgzQ=
-github.com/moby/term v0.5.2/go.mod h1:d3djjFCrjnB+fl8NJux+EJzu0msscUP+f8it8hPkFLc=
+github.com/moby/moby/api v1.54.0 h1:7kbUgyiKcoBhm0UrWbdrMs7RX8dnwzURKVbZGy2GnL0=
+github.com/moby/moby/api v1.54.0/go.mod h1:8mb+ReTlisw4pS6BRzCMts5M49W5M7bKt1cJy/YbAqc=
+github.com/moby/moby/client v0.3.0 h1:UUGL5okry+Aomj3WhGt9Aigl3ZOxZGqR7XPo+RLPlKs=
+github.com/moby/moby/client v0.3.0/go.mod h1:HJgFbJRvogDQjbM8fqc1MCEm4mIAGMLjXbgwoZp6jCQ=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
-github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
-github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
@@ -191,9 +177,6 @@ github.com/russellhaering/goxmldsig v1.6.0/go.mod h1:TrnaquDcYxWXfJrOjeMBTX4mLBe
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shirou/gopsutil/v4 v4.25.11 h1:X53gB7muL9Gnwwo2evPSE+SfOrltMoR6V3xJAXZILTY=
github.com/shirou/gopsutil/v4 v4.25.11/go.mod h1:EivAfP5x2EhLp2ovdpKSozecVXn1TmuG7SMzs/Wh4PU=
-github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
-github.com/sirupsen/logrus v1.9.4-0.20230606125235-dd1b4c2e81af h1:Sp5TG9f7K39yfB+If0vjp97vuT74F72r8hfRpP8jLU0=
-github.com/sirupsen/logrus v1.9.4-0.20230606125235-dd1b4c2e81af/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s=
github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0=
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
@@ -204,10 +187,8 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
-github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
@@ -231,10 +212,6 @@ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.68.0 h1:CqXxU8V
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.68.0/go.mod h1:BuhAPThV8PBHBvg8ZzZ/Ok3idOdhWIodywz2xEcRbJo=
go.opentelemetry.io/otel v1.43.0 h1:mYIM03dnh5zfN7HautFE4ieIig9amkNANT+xcVxAj9I=
go.opentelemetry.io/otel v1.43.0/go.mod h1:JuG+u74mvjvcm8vj8pI5XiHy1zDeoCS2LB1spIq7Ay0=
-go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.43.0 h1:88Y4s2C8oTui1LGM6bTWkw0ICGcOLCAI5l6zsD1j20k=
-go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.43.0/go.mod h1:Vl1/iaggsuRlrHf/hfPJPvVag77kKyvrLeD10kpMl+A=
-go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.43.0 h1:3iZJKlCZufyRzPzlQhUIWVmfltrXuGyfjREgGP3UUjc=
-go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.43.0/go.mod h1:/G+nUPfhq2e+qiXMGxMwumDrP5jtzU+mWN7/sjT2rak=
go.opentelemetry.io/otel/metric v1.43.0 h1:d7638QeInOnuwOONPp4JAOGfbCEpYb+K6DVWvdxGzgM=
go.opentelemetry.io/otel/metric v1.43.0/go.mod h1:RDnPtIxvqlgO8GRW18W6Z/4P462ldprJtfxHxyKd2PY=
go.opentelemetry.io/otel/sdk v1.43.0 h1:pi5mE86i5rTeLXqoF/hhiBtUNcrAGHLKQdhg4h4V9Dg=
@@ -243,8 +220,6 @@ go.opentelemetry.io/otel/sdk/metric v1.43.0 h1:S88dyqXjJkuBNLeMcVPRFXpRw2fuwdvfC
go.opentelemetry.io/otel/sdk/metric v1.43.0/go.mod h1:C/RJtwSEJ5hzTiUz5pXF1kILHStzb9zFlIEe85bhj6A=
go.opentelemetry.io/otel/trace v1.43.0 h1:BkNrHpup+4k4w+ZZ86CZoHHEkohws8AY+WTX09nk+3A=
go.opentelemetry.io/otel/trace v1.43.0/go.mod h1:/QJhyVBUUswCphDVxq+8mld+AvhXZLhe+8WVFxiFff0=
-go.opentelemetry.io/proto/otlp v1.10.0 h1:IQRWgT5srOCYfiWnpqUYz9CVmbO8bFmKcwYxpuCSL2g=
-go.opentelemetry.io/proto/otlp v1.10.0/go.mod h1:/CV4QoCR/S9yaPj8utp3lvQPoqMtxXdzn7ozvvozVqk=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0=
@@ -276,11 +251,8 @@ golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -304,12 +276,6 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9 h1:VPWxll4HlMw1Vs/qXtN7BvhZqsS9cdAittCNvVENElA=
-google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9/go.mod h1:7QBABkRtR8z+TEnmXTqIqwJLlzrZKVfAUm7tY3yGv0M=
-google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9 h1:m8qni9SQFH0tJc1X0vmnpw/0t+AImlSvp30sEupozUg=
-google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
-google.golang.org/grpc v1.80.0 h1:Xr6m2WmWZLETvUNvIUmeD5OAagMw3FiKmMlTdViWsHM=
-google.golang.org/grpc v1.80.0/go.mod h1:ho/dLnxwi3EDJA4Zghp7k2Ec1+c2jqup0bFkw07bwF4=
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
@@ -364,6 +330,8 @@ modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
+pgregory.net/rapid v1.2.0 h1:keKAYRcjm+e1F0oAuU5F5+YPAWcyxNNRK2wud503Gnk=
+pgregory.net/rapid v1.2.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04=
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8=
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo=
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA=
diff --git a/internal/cloudcp/docker/manager.go b/internal/cloudcp/docker/manager.go
index 71309965c1..060150c479 100644
--- a/internal/cloudcp/docker/manager.go
+++ b/internal/cloudcp/docker/manager.go
@@ -12,11 +12,11 @@ import (
"strings"
"time"
- "github.com/docker/docker/api/types/container"
- "github.com/docker/docker/api/types/mount"
- "github.com/docker/docker/api/types/network"
- "github.com/docker/docker/client"
- "github.com/docker/docker/errdefs"
+ "github.com/containerd/errdefs"
+ "github.com/moby/moby/api/types/container"
+ "github.com/moby/moby/api/types/mount"
+ "github.com/moby/moby/api/types/network"
+ "github.com/moby/moby/client"
"github.com/rs/zerolog/log"
)
@@ -59,7 +59,7 @@ const (
// NewManager creates a Docker manager connected to the local daemon.
func NewManager(cfg ManagerConfig) (*Manager, error) {
- cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
+ cli, err := client.New(client.FromEnv)
if err != nil {
return nil, fmt.Errorf("create docker client: %w", err)
}
@@ -95,7 +95,7 @@ func (m *Manager) ensureDaemonReachable(ctx context.Context) error {
if m == nil || m.cli == nil {
return fmt.Errorf("docker client unavailable")
}
- if _, err := m.cli.Ping(ctx); err != nil {
+ if _, err := m.cli.Ping(ctx, client.PingOptions{}); err != nil {
return fmt.Errorf("ping docker daemon: %w", err)
}
return nil
@@ -116,13 +116,13 @@ func (m *Manager) CreateAndStart(ctx context.Context, tenantID, tenantDataDir st
containerName := "pulse-" + tenantID
- resp, err := m.cli.ContainerCreate(ctx,
- &container.Config{
+ resp, err := m.cli.ContainerCreate(ctx, client.ContainerCreateOptions{
+ Config: &container.Config{
Image: m.cfg.Image,
Labels: labels,
Env: tenantEnv(tenantID, m.cfg.BaseDomain, m.cfg.TrialActivationPublicKey, m.tenantTrustedProxyCIDRs(ctx)),
},
- &container.HostConfig{
+ HostConfig: &container.HostConfig{
RestartPolicy: container.RestartPolicy{Name: "unless-stopped"},
Resources: container.Resources{
Memory: m.cfg.MemoryLimit,
@@ -130,19 +130,18 @@ func (m *Manager) CreateAndStart(ctx context.Context, tenantID, tenantDataDir st
},
Mounts: tenantMounts(tenantDataDir),
},
- &network.NetworkingConfig{
+ NetworkingConfig: &network.NetworkingConfig{
EndpointsConfig: map[string]*network.EndpointSettings{
m.cfg.Network: {},
},
},
- nil, // platform
- containerName,
- )
+ Name: containerName,
+ })
if err != nil {
return "", fmt.Errorf("create container for %s: %w", tenantID, err)
}
- if err := m.cli.ContainerStart(ctx, resp.ID, container.StartOptions{}); err != nil {
+ if _, err := m.cli.ContainerStart(ctx, resp.ID, client.ContainerStartOptions{}); err != nil {
return resp.ID, fmt.Errorf("start container for %s: %w", tenantID, err)
}
@@ -247,12 +246,12 @@ func (m *Manager) tenantTrustedProxyCIDRs(ctx context.Context) []string {
if m != nil && m.cli != nil && strings.TrimSpace(m.cfg.Network) != "" {
networkName := strings.TrimSpace(m.cfg.Network)
- inspect, err := m.cli.NetworkInspect(ctx, networkName, network.InspectOptions{})
+ inspect, err := m.cli.NetworkInspect(ctx, networkName, client.NetworkInspectOptions{})
if err != nil {
log.Warn().Err(err).Str("network", networkName).Msg("Failed to inspect tenant network for trusted proxy CIDRs")
} else {
- for _, cfg := range inspect.IPAM.Config {
- appendCIDR(cfg.Subnet)
+ for _, cfg := range inspect.Network.IPAM.Config {
+ appendCIDR(cfg.Subnet.String())
}
}
}
@@ -317,19 +316,22 @@ func prepareTenantRuntimeMountSources(tenantDataDir string, uid, gid int) error
// Stop stops a tenant container gracefully.
func (m *Manager) Stop(ctx context.Context, containerID string) error {
timeout := 30
- return m.cli.ContainerStop(ctx, containerID, container.StopOptions{Timeout: &timeout})
+ _, err := m.cli.ContainerStop(ctx, containerID, client.ContainerStopOptions{Timeout: &timeout})
+ return err
}
// Start starts a stopped tenant container.
func (m *Manager) Start(ctx context.Context, containerID string) error {
- return m.cli.ContainerStart(ctx, containerID, container.StartOptions{})
+ _, err := m.cli.ContainerStart(ctx, containerID, client.ContainerStartOptions{})
+ return err
}
// Remove removes a stopped tenant container.
func (m *Manager) Remove(ctx context.Context, containerID string) error {
- return m.cli.ContainerRemove(ctx, containerID, container.RemoveOptions{
+ _, err := m.cli.ContainerRemove(ctx, containerID, client.ContainerRemoveOptions{
Force: true,
})
+ return err
}
// Rename renames a tenant container to the supplied Docker name.
@@ -337,7 +339,7 @@ func (m *Manager) Rename(ctx context.Context, containerIDOrName, newName string)
if err := m.ensureDaemonReachable(ctx); err != nil {
return err
}
- if err := m.cli.ContainerRename(ctx, containerIDOrName, newName); err != nil {
+ if _, err := m.cli.ContainerRename(ctx, containerIDOrName, client.ContainerRenameOptions{NewName: newName}); err != nil {
return fmt.Errorf("rename container %s -> %s: %w", containerIDOrName, newName, err)
}
return nil
@@ -349,10 +351,11 @@ func (m *Manager) Inspect(ctx context.Context, containerIDOrName string) (*Runti
if err := m.ensureDaemonReachable(ctx); err != nil {
return nil, err
}
- inspect, err := m.cli.ContainerInspect(ctx, containerIDOrName)
+ inspectResult, err := m.cli.ContainerInspect(ctx, containerIDOrName, client.ContainerInspectOptions{})
if err != nil {
return nil, fmt.Errorf("inspect container %s: %w", containerIDOrName, err)
}
+ inspect := inspectResult.Container
imageRef := ""
if inspect.Config != nil {
imageRef = strings.TrimSpace(inspect.Config.Image)
@@ -386,10 +389,11 @@ func (m *Manager) StopAndRemove(ctx context.Context, containerID string) error {
// HealthCheck performs an HTTP health check against a running container.
// It connects to the container's published port via the Docker network.
func (m *Manager) HealthCheck(ctx context.Context, containerID string) (bool, error) {
- inspect, err := m.cli.ContainerInspect(ctx, containerID)
+ inspectResult, err := m.cli.ContainerInspect(ctx, containerID, client.ContainerInspectOptions{})
if err != nil {
return false, fmt.Errorf("inspect container: %w", err)
}
+ inspect := inspectResult.Container
if !inspect.State.Running {
return false, nil
@@ -397,11 +401,11 @@ func (m *Manager) HealthCheck(ctx context.Context, containerID string) (bool, er
// Find the container's IP on our network
netSettings, ok := inspect.NetworkSettings.Networks[m.cfg.Network]
- if !ok || netSettings.IPAddress == "" {
+ if !ok || !netSettings.IPAddress.IsValid() {
return false, fmt.Errorf("container not connected to network %s", m.cfg.Network)
}
- healthURL := fmt.Sprintf("http://%s:%d/api/health", netSettings.IPAddress, m.cfg.ContainerPort)
+ healthURL := fmt.Sprintf("http://%s:%d/api/health", netSettings.IPAddress.String(), m.cfg.ContainerPort)
httpClient := &http.Client{Timeout: 5 * time.Second}
resp, err := httpClient.Get(healthURL)
if err != nil {
diff --git a/internal/cloudcp/tenant_runtime_rollout_test.go b/internal/cloudcp/tenant_runtime_rollout_test.go
index c0536203f6..15274143cc 100644
--- a/internal/cloudcp/tenant_runtime_rollout_test.go
+++ b/internal/cloudcp/tenant_runtime_rollout_test.go
@@ -8,7 +8,7 @@ import (
"testing"
"time"
- "github.com/docker/docker/errdefs"
+ "github.com/containerd/errdefs"
cpDocker "github.com/rcourtman/pulse-go-rewrite/internal/cloudcp/docker"
"github.com/rcourtman/pulse-go-rewrite/internal/cloudcp/registry"
)
@@ -575,7 +575,7 @@ func (f *fakeTenantRuntimeRolloutDocker) HealthCheck(_ context.Context, containe
}
info, ok := f.byID[containerID]
if !ok {
- return false, errdefs.NotFound(fmt.Errorf("missing container %s", containerID))
+ return false, errdefs.ErrNotFound.WithMessage(fmt.Sprintf("missing container %s", containerID))
}
return info.Running, nil
}
@@ -589,7 +589,7 @@ func (f *fakeTenantRuntimeRolloutDocker) Inspect(_ context.Context, containerIDO
copy := *info
return &copy, nil
}
- return nil, errdefs.NotFound(fmt.Errorf("missing container %s", containerIDOrName))
+ return nil, errdefs.ErrNotFound.WithMessage(fmt.Sprintf("missing container %s", containerIDOrName))
}
func (f *fakeTenantRuntimeRolloutDocker) Remove(_ context.Context, containerID string) error {
@@ -602,7 +602,7 @@ func (f *fakeTenantRuntimeRolloutDocker) Remove(_ context.Context, containerID s
}
}
if !ok {
- return errdefs.NotFound(fmt.Errorf("missing container %s", containerID))
+ return errdefs.ErrNotFound.WithMessage(fmt.Sprintf("missing container %s", containerID))
}
delete(f.byID, info.ID)
delete(f.byName, info.Name)
diff --git a/internal/dockeragent/agent.go b/internal/dockeragent/agent.go
index dabe2da3dd..c7dc5226fd 100644
--- a/internal/dockeragent/agent.go
+++ b/internal/dockeragent/agent.go
@@ -17,8 +17,8 @@ import (
"sync"
"time"
- systemtypes "github.com/docker/docker/api/types/system"
- "github.com/docker/docker/client"
+ systemtypes "github.com/moby/moby/api/types/system"
+ "github.com/moby/moby/client"
"github.com/rcourtman/pulse-go-rewrite/internal/utils"
agentsdocker "github.com/rcourtman/pulse-go-rewrite/pkg/agents/docker"
"github.com/rs/zerolog"
diff --git a/internal/dockeragent/agent_collect_test.go b/internal/dockeragent/agent_collect_test.go
index 127664fe87..08addb45b2 100644
--- a/internal/dockeragent/agent_collect_test.go
+++ b/internal/dockeragent/agent_collect_test.go
@@ -5,12 +5,13 @@ import (
"errors"
"io"
"net/http"
+ "net/netip"
"strings"
"testing"
"time"
- containertypes "github.com/docker/docker/api/types/container"
- systemtypes "github.com/docker/docker/api/types/system"
+ containertypes "github.com/moby/moby/api/types/container"
+ systemtypes "github.com/moby/moby/api/types/system"
"github.com/rs/zerolog"
)
@@ -64,16 +65,16 @@ func TestCollectContainer(t *testing.T) {
sizeRw := int64(1234)
sizeRoot := int64(5678)
inspect := baseInspect()
- inspect.ContainerJSONBase.SizeRw = &sizeRw
- inspect.ContainerJSONBase.SizeRootFs = &sizeRoot
- inspect.ContainerJSONBase.State = &containertypes.State{
+ inspect.SizeRw = &sizeRw
+ inspect.SizeRootFs = &sizeRoot
+ inspect.State = &containertypes.State{
Running: true,
StartedAt: time.Now().Add(-time.Minute).Format(time.RFC3339Nano),
Health: &containertypes.Health{Status: "healthy"},
}
inspect.Config.Env = []string{"PASSWORD=secret", "PATH=/bin"}
inspect.Config.Image = "nginx@sha256:abc123"
- inspect.NetworkSettings.Networks["net1"].IPAddress = "10.0.0.2"
+ inspect.NetworkSettings.Networks["net1"].IPAddress = netip.MustParseAddr("10.0.0.2")
inspect.Mounts = []containertypes.MountPoint{
{Type: "bind", Source: "/data", Destination: "/data", RW: true},
}
@@ -90,7 +91,7 @@ func TestCollectContainer(t *testing.T) {
containerInspectWithRawFn: func(context.Context, string, bool) (containertypes.InspectResponse, []byte, error) {
return inspect, nil, nil
},
- containerStatsOneShotFn: func(context.Context, string) (containertypes.StatsResponseReader, error) {
+ containerStatsOneShotFn: func(context.Context, string) (dockerStatsResponseReader, error) {
return statsReader(t, stats), nil
},
},
@@ -104,8 +105,8 @@ func TestCollectContainer(t *testing.T) {
Created: time.Now().Add(-time.Hour).Unix(),
State: "running",
Status: "Up",
- Ports: []containertypes.Port{
- {PrivatePort: 80, PublicPort: 8080, Type: "tcp", IP: "0.0.0.0"},
+ Ports: []containertypes.PortSummary{
+ {PrivatePort: 80, PublicPort: 8080, Type: "tcp", IP: netip.MustParseAddr("0.0.0.0")},
},
Labels: map[string]string{
"io.podman.annotations.pod.name": "mypod",
@@ -164,7 +165,7 @@ func TestCollectContainer(t *testing.T) {
containerInspectWithRawFn: func(context.Context, string, bool) (containertypes.InspectResponse, []byte, error) {
return inspect, nil, nil
},
- containerStatsOneShotFn: func(context.Context, string) (containertypes.StatsResponseReader, error) {
+ containerStatsOneShotFn: func(context.Context, string) (dockerStatsResponseReader, error) {
payload := `{
"read":"2026-04-09T12:00:00Z",
"cpu_stats":{
@@ -178,7 +179,7 @@ func TestCollectContainer(t *testing.T) {
"memory_stats":{"usage":1000000,"limit":4000000,"stats":{"cache":200000}},
"blkio_stats":{"io_service_bytes_recursive":[]}
}`
- return containertypes.StatsResponseReader{Body: io.NopCloser(strings.NewReader(payload))}, nil
+ return dockerStatsResponseReader{Body: io.NopCloser(strings.NewReader(payload))}, nil
},
},
}
@@ -209,7 +210,7 @@ func TestCollectContainer(t *testing.T) {
docker: &fakeDockerClient{
containerInspectWithRawFn: func(context.Context, string, bool) (containertypes.InspectResponse, []byte, error) {
inspect := baseInspect()
- inspect.ContainerJSONBase.State = &containertypes.State{Running: false}
+ inspect.State = &containertypes.State{Running: false}
return inspect, nil, nil
},
},
@@ -244,11 +245,11 @@ func TestCollectContainer(t *testing.T) {
docker: &fakeDockerClient{
containerInspectWithRawFn: func(context.Context, string, bool) (containertypes.InspectResponse, []byte, error) {
inspect := baseInspect()
- inspect.ContainerJSONBase.State = &containertypes.State{Running: true}
+ inspect.State = &containertypes.State{Running: true}
return inspect, nil, nil
},
- containerStatsOneShotFn: func(context.Context, string) (containertypes.StatsResponseReader, error) {
- return containertypes.StatsResponseReader{}, errors.New("stats failed")
+ containerStatsOneShotFn: func(context.Context, string) (dockerStatsResponseReader, error) {
+ return dockerStatsResponseReader{}, errors.New("stats failed")
},
},
logger: logger,
@@ -264,11 +265,11 @@ func TestCollectContainer(t *testing.T) {
docker: &fakeDockerClient{
containerInspectWithRawFn: func(context.Context, string, bool) (containertypes.InspectResponse, []byte, error) {
inspect := baseInspect()
- inspect.ContainerJSONBase.State = &containertypes.State{Running: true}
+ inspect.State = &containertypes.State{Running: true}
return inspect, nil, nil
},
- containerStatsOneShotFn: func(context.Context, string) (containertypes.StatsResponseReader, error) {
- return containertypes.StatsResponseReader{Body: io.NopCloser(strings.NewReader("{"))}, nil
+ containerStatsOneShotFn: func(context.Context, string) (dockerStatsResponseReader, error) {
+ return dockerStatsResponseReader{Body: io.NopCloser(strings.NewReader("{"))}, nil
},
},
logger: logger,
@@ -282,7 +283,7 @@ func TestCollectContainer(t *testing.T) {
t.Run("uptime negative clamped", func(t *testing.T) {
future := time.Now().Add(5 * time.Minute).Format(time.RFC3339Nano)
inspect := baseInspect()
- inspect.ContainerJSONBase.State = &containertypes.State{
+ inspect.State = &containertypes.State{
Running: true,
StartedAt: future,
}
@@ -307,7 +308,7 @@ func TestCollectContainer(t *testing.T) {
containerInspectWithRawFn: func(context.Context, string, bool) (containertypes.InspectResponse, []byte, error) {
return inspect, nil, nil
},
- containerStatsOneShotFn: func(context.Context, string) (containertypes.StatsResponseReader, error) {
+ containerStatsOneShotFn: func(context.Context, string) (dockerStatsResponseReader, error) {
return statsReader(t, stats), nil
},
},
@@ -329,7 +330,7 @@ func TestCollectContainers(t *testing.T) {
t.Run("list error", func(t *testing.T) {
agent := &Agent{
docker: &fakeDockerClient{
- containerListFunc: func(context.Context, containertypes.ListOptions) ([]containertypes.Summary, error) {
+ containerListFunc: func(context.Context, dockerContainerListOptions) ([]containertypes.Summary, error) {
return nil, errors.New("list failed")
},
},
@@ -352,7 +353,7 @@ func TestCollectContainers(t *testing.T) {
"stale": {totalUsage: 1},
},
docker: &fakeDockerClient{
- containerListFunc: func(_ context.Context, opts containertypes.ListOptions) ([]containertypes.Summary, error) {
+ containerListFunc: func(_ context.Context, opts dockerContainerListOptions) ([]containertypes.Summary, error) {
if opts.Filters.Len() == 0 {
t.Fatal("expected filters to be set")
}
diff --git a/internal/dockeragent/agent_concurrency_test.go b/internal/dockeragent/agent_concurrency_test.go
index 7a5b1eebc4..475e85d949 100644
--- a/internal/dockeragent/agent_concurrency_test.go
+++ b/internal/dockeragent/agent_concurrency_test.go
@@ -8,8 +8,8 @@ import (
"testing"
"time"
- containertypes "github.com/docker/docker/api/types/container"
- systemtypes "github.com/docker/docker/api/types/system"
+ containertypes "github.com/moby/moby/api/types/container"
+ systemtypes "github.com/moby/moby/api/types/system"
"github.com/rcourtman/pulse-go-rewrite/internal/hostmetrics"
"github.com/rcourtman/pulse-go-rewrite/internal/utils"
agentsdocker "github.com/rcourtman/pulse-go-rewrite/pkg/agents/docker"
@@ -141,7 +141,7 @@ func TestCleanupOrphanedBackupsSkipsOverlappingRuns(t *testing.T) {
agent := &Agent{
docker: &fakeDockerClient{
- containerListFunc: func(context.Context, containertypes.ListOptions) ([]containertypes.Summary, error) {
+ containerListFunc: func(context.Context, dockerContainerListOptions) ([]containertypes.Summary, error) {
atomic.AddInt32(&listCalls, 1)
listStarted <- struct{}{}
<-release
diff --git a/internal/dockeragent/agent_cpu_test.go b/internal/dockeragent/agent_cpu_test.go
index 6a56e3a2ac..f719bff24c 100644
--- a/internal/dockeragent/agent_cpu_test.go
+++ b/internal/dockeragent/agent_cpu_test.go
@@ -5,7 +5,7 @@ import (
"testing"
"time"
- containertypes "github.com/docker/docker/api/types/container"
+ containertypes "github.com/moby/moby/api/types/container"
"github.com/rs/zerolog"
)
diff --git a/internal/dockeragent/agent_flow_test.go b/internal/dockeragent/agent_flow_test.go
index 6f7ba68483..2d275794bf 100644
--- a/internal/dockeragent/agent_flow_test.go
+++ b/internal/dockeragent/agent_flow_test.go
@@ -11,7 +11,7 @@ import (
"testing"
"time"
- systemtypes "github.com/docker/docker/api/types/system"
+ systemtypes "github.com/moby/moby/api/types/system"
"github.com/rcourtman/pulse-go-rewrite/internal/hostmetrics"
"github.com/rcourtman/pulse-go-rewrite/internal/utils"
agentsdocker "github.com/rcourtman/pulse-go-rewrite/pkg/agents/docker"
diff --git a/internal/dockeragent/agent_http_test.go b/internal/dockeragent/agent_http_test.go
index 2f649b9c7e..6e10cd59d5 100644
--- a/internal/dockeragent/agent_http_test.go
+++ b/internal/dockeragent/agent_http_test.go
@@ -15,8 +15,8 @@ import (
"testing"
"time"
- containertypes "github.com/docker/docker/api/types/container"
- systemtypes "github.com/docker/docker/api/types/system"
+ containertypes "github.com/moby/moby/api/types/container"
+ systemtypes "github.com/moby/moby/api/types/system"
agentsdocker "github.com/rcourtman/pulse-go-rewrite/pkg/agents/docker"
"github.com/rs/zerolog"
)
diff --git a/internal/dockeragent/agent_image_digest_test.go b/internal/dockeragent/agent_image_digest_test.go
index 2268691179..f48c12cc58 100644
--- a/internal/dockeragent/agent_image_digest_test.go
+++ b/internal/dockeragent/agent_image_digest_test.go
@@ -6,7 +6,7 @@ import (
"io"
"testing"
- "github.com/docker/docker/api/types/image"
+ "github.com/moby/moby/api/types/image"
"github.com/rs/zerolog"
)
diff --git a/internal/dockeragent/agent_internal_test.go b/internal/dockeragent/agent_internal_test.go
index b99490406d..778ebc4158 100644
--- a/internal/dockeragent/agent_internal_test.go
+++ b/internal/dockeragent/agent_internal_test.go
@@ -9,8 +9,8 @@ import (
"testing"
"time"
- containertypes "github.com/docker/docker/api/types/container"
- systemtypes "github.com/docker/docker/api/types/system"
+ containertypes "github.com/moby/moby/api/types/container"
+ systemtypes "github.com/moby/moby/api/types/system"
agentsdocker "github.com/rcourtman/pulse-go-rewrite/pkg/agents/docker"
)
diff --git a/internal/dockeragent/agent_report_coverage_test.go b/internal/dockeragent/agent_report_coverage_test.go
index 578a511d05..7902214448 100644
--- a/internal/dockeragent/agent_report_coverage_test.go
+++ b/internal/dockeragent/agent_report_coverage_test.go
@@ -6,9 +6,9 @@ import (
"testing"
"time"
- containertypes "github.com/docker/docker/api/types/container"
- swarmtypes "github.com/docker/docker/api/types/swarm"
- systemtypes "github.com/docker/docker/api/types/system"
+ containertypes "github.com/moby/moby/api/types/container"
+ swarmtypes "github.com/moby/moby/api/types/swarm"
+ systemtypes "github.com/moby/moby/api/types/system"
"github.com/rcourtman/pulse-go-rewrite/internal/hostmetrics"
"github.com/rs/zerolog"
)
@@ -22,9 +22,7 @@ func TestBuildReport_RuntimeChangePodman(t *testing.T) {
})
inspect := containertypes.InspectResponse{
- ContainerJSONBase: &containertypes.ContainerJSONBase{
- State: &containertypes.State{Running: false},
- },
+ State: &containertypes.State{Running: false},
Config: &containertypes.Config{},
}
@@ -54,7 +52,7 @@ func TestBuildReport_RuntimeChangePodman(t *testing.T) {
OperatingSystem: "linux",
}, nil
},
- containerListFunc: func(context.Context, containertypes.ListOptions) ([]containertypes.Summary, error) {
+ containerListFunc: func(context.Context, dockerContainerListOptions) ([]containertypes.Summary, error) {
return []containertypes.Summary{
{ID: "container1", Names: []string{"/app"}, State: "exited"},
}, nil
@@ -86,9 +84,7 @@ func TestBuildReport_CollectContainersForcedAndSwarmInfo(t *testing.T) {
})
inspect := containertypes.InspectResponse{
- ContainerJSONBase: &containertypes.ContainerJSONBase{
- State: &containertypes.State{Running: false},
- },
+ State: &containertypes.State{Running: false},
Config: &containertypes.Config{},
}
@@ -120,7 +116,7 @@ func TestBuildReport_CollectContainersForcedAndSwarmInfo(t *testing.T) {
},
}, nil
},
- containerListFunc: func(context.Context, containertypes.ListOptions) ([]containertypes.Summary, error) {
+ containerListFunc: func(context.Context, dockerContainerListOptions) ([]containertypes.Summary, error) {
listCalled = true
return []containertypes.Summary{
{
@@ -227,7 +223,7 @@ func TestBuildReport_CollectContainersError(t *testing.T) {
infoFunc: func(context.Context) (systemtypes.Info, error) {
return systemtypes.Info{ServerVersion: "24.0.0"}, nil
},
- containerListFunc: func(context.Context, containertypes.ListOptions) ([]containertypes.Summary, error) {
+ containerListFunc: func(context.Context, dockerContainerListOptions) ([]containertypes.Summary, error) {
return nil, errors.New("list failed")
},
},
@@ -244,9 +240,7 @@ func TestBuildReport_SwarmServicesTasks(t *testing.T) {
})
inspect := containertypes.InspectResponse{
- ContainerJSONBase: &containertypes.ContainerJSONBase{
- State: &containertypes.State{Running: false},
- },
+ State: &containertypes.State{Running: false},
Config: &containertypes.Config{},
}
@@ -270,7 +264,7 @@ func TestBuildReport_SwarmServicesTasks(t *testing.T) {
},
}, nil
},
- containerListFunc: func(context.Context, containertypes.ListOptions) ([]containertypes.Summary, error) {
+ containerListFunc: func(context.Context, dockerContainerListOptions) ([]containertypes.Summary, error) {
return []containertypes.Summary{
{
ID: "container1",
@@ -311,11 +305,9 @@ func TestCollectContainerFinishedAt(t *testing.T) {
finishedAt := time.Now().Add(-time.Minute).Format(time.RFC3339Nano)
inspect := containertypes.InspectResponse{
- ContainerJSONBase: &containertypes.ContainerJSONBase{
- State: &containertypes.State{
- Running: false,
- FinishedAt: finishedAt,
- },
+ State: &containertypes.State{
+ Running: false,
+ FinishedAt: finishedAt,
},
Config: &containertypes.Config{},
NetworkSettings: nil,
diff --git a/internal/dockeragent/cleanup.go b/internal/dockeragent/cleanup.go
index 49ff7207df..4769823d22 100644
--- a/internal/dockeragent/cleanup.go
+++ b/internal/dockeragent/cleanup.go
@@ -5,7 +5,7 @@ import (
"strings"
"time"
- "github.com/docker/docker/api/types/container"
+ containertypes "github.com/moby/moby/api/types/container"
)
// cleanupOrphanedBackups searches for and removes any Pulse backup containers
@@ -20,8 +20,8 @@ func (a *Agent) cleanupOrphanedBackups(ctx context.Context) {
a.logger.Debug().Msg("Checking for orphaned backup containers")
// List all containers (including stopped ones)
- list, err := dockerCallWithRetry(ctx, dockerCleanupCallTimeout, func(callCtx context.Context) ([]container.Summary, error) {
- return a.docker.ContainerList(callCtx, container.ListOptions{
+ list, err := dockerCallWithRetry(ctx, dockerCleanupCallTimeout, func(callCtx context.Context) ([]containertypes.Summary, error) {
+ return a.docker.ContainerList(callCtx, dockerContainerListOptions{
All: true,
})
})
@@ -63,7 +63,7 @@ func (a *Agent) cleanupOrphanedBackups(ctx context.Context) {
Msg("removing orphaned backup container")
_, err := dockerCallWithRetry(ctx, dockerCleanupCallTimeout, func(callCtx context.Context) (struct{}, error) {
- err := a.docker.ContainerRemove(callCtx, c.ID, container.RemoveOptions{Force: true})
+ err := a.docker.ContainerRemove(callCtx, c.ID, dockerContainerRemoveOptions{Force: true})
return struct{}{}, err
})
if err != nil {
diff --git a/internal/dockeragent/cleanup_coverage_test.go b/internal/dockeragent/cleanup_coverage_test.go
index 19c59e4202..0cb93fe4da 100644
--- a/internal/dockeragent/cleanup_coverage_test.go
+++ b/internal/dockeragent/cleanup_coverage_test.go
@@ -6,7 +6,7 @@ import (
"testing"
"time"
- containertypes "github.com/docker/docker/api/types/container"
+ containertypes "github.com/moby/moby/api/types/container"
"github.com/rs/zerolog"
)
@@ -15,7 +15,7 @@ func TestCleanupOrphanedBackups(t *testing.T) {
agent := &Agent{
logger: zerolog.Nop(),
docker: &fakeDockerClient{
- containerListFunc: func(context.Context, containertypes.ListOptions) ([]containertypes.Summary, error) {
+ containerListFunc: func(context.Context, dockerContainerListOptions) ([]containertypes.Summary, error) {
return nil, errors.New("list failed")
},
},
@@ -30,11 +30,11 @@ func TestCleanupOrphanedBackups(t *testing.T) {
oldCreated := time.Now().Add(-20 * time.Minute).Unix()
recentCreated := time.Now().Add(-5 * time.Minute).Unix()
- removed := make(map[string]containertypes.RemoveOptions)
+ removed := make(map[string]dockerContainerRemoveOptions)
agent := &Agent{
logger: zerolog.Nop(),
docker: &fakeDockerClient{
- containerListFunc: func(_ context.Context, opts containertypes.ListOptions) ([]containertypes.Summary, error) {
+ containerListFunc: func(_ context.Context, opts dockerContainerListOptions) ([]containertypes.Summary, error) {
if !opts.All {
t.Fatal("expected cleanup list query to set All=true")
}
@@ -47,7 +47,7 @@ func TestCleanupOrphanedBackups(t *testing.T) {
{ID: "secondary-name-only", Names: []string{"/service", "/service_pulse_backup_" + oldTimestamp}, Created: oldCreated},
}, nil
},
- containerRemoveFn: func(_ context.Context, id string, opts containertypes.RemoveOptions) error {
+ containerRemoveFn: func(_ context.Context, id string, opts dockerContainerRemoveOptions) error {
removed[id] = opts
if id == "old-fallback" {
return errors.New("remove failed")
diff --git a/internal/dockeragent/collect.go b/internal/dockeragent/collect.go
index 8774e4552e..77cc1a12a4 100644
--- a/internal/dockeragent/collect.go
+++ b/internal/dockeragent/collect.go
@@ -8,13 +8,13 @@ import (
"io"
"math"
"math/big"
+ "net/netip"
"strconv"
"strings"
"time"
- containertypes "github.com/docker/docker/api/types/container"
- "github.com/docker/docker/api/types/filters"
- systemtypes "github.com/docker/docker/api/types/system"
+ containertypes "github.com/moby/moby/api/types/container"
+ systemtypes "github.com/moby/moby/api/types/system"
agentsdocker "github.com/rcourtman/pulse-go-rewrite/pkg/agents/docker"
)
@@ -210,9 +210,9 @@ func normalizedNonEmptyStrings(values []string) []string {
}
func (a *Agent) collectContainers(ctx context.Context) ([]agentsdocker.Container, error) {
- options := containertypes.ListOptions{All: true}
+ options := dockerContainerListOptions{All: true}
if len(a.stateFilters) > 0 {
- filterArgs := filters.NewArgs()
+ filterArgs := newDockerFilters()
for _, state := range a.stateFilters {
filterArgs.Add("status", state)
}
@@ -230,7 +230,7 @@ func (a *Agent) collectContainers(ctx context.Context) ([]agentsdocker.Container
active := make(map[string]struct{}, len(list))
for _, summary := range list {
if len(a.allowedStates) > 0 {
- if _, ok := a.allowedStates[strings.ToLower(summary.State)]; !ok {
+ if _, ok := a.allowedStates[strings.ToLower(string(summary.State))]; !ok {
continue
}
}
@@ -342,7 +342,7 @@ func (a *Agent) collectContainer(ctx context.Context, summary containertypes.Sum
health := ""
if inspect.State.Health != nil {
- health = inspect.State.Health.Status
+ health = string(inspect.State.Health.Status)
}
ports := make([]agentsdocker.ContainerPort, len(summary.Ports))
@@ -351,7 +351,7 @@ func (a *Agent) collectContainer(ctx context.Context, summary containertypes.Sum
PrivatePort: int(port.PrivatePort),
PublicPort: int(port.PublicPort),
Protocol: port.Type,
- IP: port.IP,
+ IP: addrString(port.IP),
}
}
@@ -365,8 +365,8 @@ func (a *Agent) collectContainer(ctx context.Context, summary containertypes.Sum
for name, cfg := range inspect.NetworkSettings.Networks {
networks = append(networks, agentsdocker.ContainerNetwork{
Name: name,
- IPv4: cfg.IPAddress,
- IPv6: cfg.GlobalIPv6Address,
+ IPv4: addrString(cfg.IPAddress),
+ IPv6: addrString(cfg.GlobalIPv6Address),
})
}
}
@@ -414,7 +414,7 @@ func (a *Agent) collectContainer(ctx context.Context, summary containertypes.Sum
Image: summary.Image,
ImageDigest: summary.ImageID, // sha256:... digest of the image
CreatedAt: createdAt,
- State: summary.State,
+ State: string(summary.State),
Status: summary.Status,
Health: health,
CPUPercent: cpuPercent,
@@ -554,6 +554,13 @@ func (a *Agent) getImageRepoDigest(ctx context.Context, imageID, imageName strin
return "", arch, os, variant
}
+func addrString(addr netip.Addr) string {
+ if !addr.IsValid() {
+ return ""
+ }
+ return addr.String()
+}
+
// matchesImageReference checks if a RepoDigest repository matches an image reference.
// It handles Docker Hub's various naming conventions.
func matchesImageReference(imageName, repoRef string) bool {
diff --git a/internal/dockeragent/container_update.go b/internal/dockeragent/container_update.go
index f4c15fb5dd..d4e89dd83f 100644
--- a/internal/dockeragent/container_update.go
+++ b/internal/dockeragent/container_update.go
@@ -9,9 +9,8 @@ import (
"strings"
"time"
- "github.com/docker/docker/api/types/container"
- "github.com/docker/docker/api/types/image"
- "github.com/docker/docker/api/types/network"
+ containertypes "github.com/moby/moby/api/types/container"
+ "github.com/moby/moby/api/types/network"
agentsdocker "github.com/rcourtman/pulse-go-rewrite/pkg/agents/docker"
)
@@ -164,7 +163,7 @@ func (a *Agent) updateContainerWithProgress(ctx context.Context, containerID str
}
// 1. Inspect the current container to get its full configuration
- inspect, err := dockerCallWithRetry(ctx, dockerUpdateCallTimeout, func(callCtx context.Context) (container.InspectResponse, error) {
+ inspect, err := dockerCallWithRetry(ctx, dockerUpdateCallTimeout, func(callCtx context.Context) (containertypes.InspectResponse, error) {
return a.docker.ContainerInspect(callCtx, containerID)
})
if err != nil {
@@ -198,7 +197,7 @@ func (a *Agent) updateContainerWithProgress(ctx context.Context, containerID str
a.logger.Info().Str("image", imageName).Msg("Pulling latest image")
pullCtx, pullCancel := context.WithTimeout(ctx, dockerUpdateCallTimeout)
- pullResp, err := a.docker.ImagePull(pullCtx, imageName, image.PullOptions{})
+ pullResp, err := a.docker.ImagePull(pullCtx, imageName, dockerImagePullOptions{})
if err != nil {
pullCancel()
result.Error = fmt.Sprintf("Failed to pull image %s: %v", imageName, annotateDockerConnectionError(err))
@@ -217,7 +216,7 @@ func (a *Agent) updateContainerWithProgress(ctx context.Context, containerID str
reportProgress(fmt.Sprintf("Stopping container %s...", result.ContainerName))
stopTimeout := 30 // seconds
_, err = dockerCallWithRetry(ctx, dockerUpdateCallTimeout, func(callCtx context.Context) (struct{}, error) {
- err := a.docker.ContainerStop(callCtx, containerID, container.StopOptions{Timeout: &stopTimeout})
+ err := a.docker.ContainerStop(callCtx, containerID, dockerContainerStopOptions{Timeout: &stopTimeout})
return struct{}{}, err
})
if err != nil {
@@ -240,7 +239,7 @@ func (a *Agent) updateContainerWithProgress(ctx context.Context, containerID str
a.logger.Error().Err(err).Str("container", result.ContainerName).Msg("Failed to rename container for backup")
if wasRunning {
// Try to restart the original container.
- if restartErr := a.docker.ContainerStart(ctx, containerID, container.StartOptions{}); restartErr != nil {
+ if restartErr := a.docker.ContainerStart(ctx, containerID, dockerContainerStartOptions{}); restartErr != nil {
a.logger.Warn().
Err(restartErr).
Str("container", result.ContainerName).
@@ -270,9 +269,6 @@ func (a *Agent) updateContainerWithProgress(ctx context.Context, containerID str
IPAMConfig: netConfig.IPAMConfig,
Links: netConfig.Links,
NetworkID: netConfig.NetworkID,
- EndpointID: "", // Will be assigned
- Gateway: "", // Will be assigned
- IPAddress: "", // Will be assigned
MacAddress: netConfig.MacAddress,
DriverOpts: netConfig.DriverOpts,
}
@@ -281,7 +277,7 @@ func (a *Agent) updateContainerWithProgress(ctx context.Context, containerID str
}
// 6. Create a new container with the same configuration
- createResp, err := dockerCallWithRetry(ctx, dockerUpdateCallTimeout, func(callCtx context.Context) (container.CreateResponse, error) {
+ createResp, err := dockerCallWithRetry(ctx, dockerUpdateCallTimeout, func(callCtx context.Context) (containertypes.CreateResponse, error) {
return a.docker.ContainerCreate(
callCtx,
inspect.Config,
@@ -327,7 +323,7 @@ func (a *Agent) updateContainerWithProgress(ctx context.Context, containerID str
if wasRunning {
reportProgress(fmt.Sprintf("Starting container %s...", result.ContainerName))
_, err = dockerCallWithRetry(ctx, dockerUpdateCallTimeout, func(callCtx context.Context) (struct{}, error) {
- err := a.docker.ContainerStart(callCtx, newContainerID, container.StartOptions{})
+ err := a.docker.ContainerStart(callCtx, newContainerID, dockerContainerStartOptions{})
return struct{}{}, err
})
if err != nil {
@@ -346,7 +342,7 @@ func (a *Agent) updateContainerWithProgress(ctx context.Context, containerID str
sleepFn(5 * time.Second)
}
- verifyInspect, err := dockerCallWithRetry(ctx, dockerUpdateCallTimeout, func(callCtx context.Context) (container.InspectResponse, error) {
+ verifyInspect, err := dockerCallWithRetry(ctx, dockerUpdateCallTimeout, func(callCtx context.Context) (containertypes.InspectResponse, error) {
return a.docker.ContainerInspect(callCtx, newContainerID)
})
if err != nil {
@@ -390,7 +386,7 @@ func (a *Agent) updateContainerWithProgress(ctx context.Context, containerID str
if !a.waitForAsyncDelay(5 * time.Minute) {
return
}
- if err := a.docker.ContainerRemove(asyncCtx, backupName, container.RemoveOptions{Force: true}); err != nil {
+ if err := a.docker.ContainerRemove(asyncCtx, backupName, dockerContainerRemoveOptions{Force: true}); err != nil {
a.logger.Warn().Err(err).Str("backup", backupName).Msg("Failed to cleanup backup container")
} else {
a.logger.Info().Str("backup", backupName).Msg("Backup container cleaned up")
@@ -440,7 +436,7 @@ func (a *Agent) rollbackRenameAndRestart(ctx context.Context, backupName, origin
Msg("Rollback step failed: restore original container name")
}
if restart {
- if err := a.docker.ContainerStart(ctx, originalID, container.StartOptions{}); err != nil {
+ if err := a.docker.ContainerStart(ctx, originalID, dockerContainerStartOptions{}); err != nil {
a.logger.Warn().
Err(err).
Str("container", originalName).
@@ -450,7 +446,7 @@ func (a *Agent) rollbackRenameAndRestart(ctx context.Context, backupName, origin
}
func (a *Agent) rollbackRemoveRenameAndRestart(ctx context.Context, newContainerID, backupName, originalName, originalID string, restart bool) {
- if err := a.docker.ContainerRemove(ctx, newContainerID, container.RemoveOptions{Force: true}); err != nil {
+ if err := a.docker.ContainerRemove(ctx, newContainerID, dockerContainerRemoveOptions{Force: true}); err != nil {
a.logger.Warn().
Err(err).
Str("containerId", newContainerID).
diff --git a/internal/dockeragent/container_update_test.go b/internal/dockeragent/container_update_test.go
index 75264ec02d..4a65bbd8a0 100644
--- a/internal/dockeragent/container_update_test.go
+++ b/internal/dockeragent/container_update_test.go
@@ -12,9 +12,8 @@ import (
"testing"
"time"
- containertypes "github.com/docker/docker/api/types/container"
- "github.com/docker/docker/api/types/image"
- "github.com/docker/docker/api/types/network"
+ containertypes "github.com/moby/moby/api/types/container"
+ "github.com/moby/moby/api/types/network"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
agentsdocker "github.com/rcourtman/pulse-go-rewrite/pkg/agents/docker"
"github.com/rs/zerolog"
@@ -25,13 +24,11 @@ func baseInspect() containertypes.InspectResponse {
hostConfig := &containertypes.HostConfig{}
return containertypes.InspectResponse{
- ContainerJSONBase: &containertypes.ContainerJSONBase{
- Name: "/app",
- Image: "sha256:old0000000000",
- State: state,
- RestartCount: 1,
- HostConfig: hostConfig,
- },
+ Name: "/app",
+ Image: "sha256:old0000000000",
+ State: state,
+ RestartCount: 1,
+ HostConfig: hostConfig,
Config: &containertypes.Config{
Image: "nginx:latest",
},
@@ -69,7 +66,7 @@ func TestUpdateContainer_Errors(t *testing.T) {
containerInspectFn: func(context.Context, string) (containertypes.InspectResponse, error) {
return baseInspect(), nil
},
- imagePullFn: func(context.Context, string, image.PullOptions) (io.ReadCloser, error) {
+ imagePullFn: func(context.Context, string, dockerImagePullOptions) (io.ReadCloser, error) {
return nil, errors.New("pull failed")
},
},
@@ -88,10 +85,10 @@ func TestUpdateContainer_Errors(t *testing.T) {
containerInspectFn: func(context.Context, string) (containertypes.InspectResponse, error) {
return baseInspect(), nil
},
- imagePullFn: func(context.Context, string, image.PullOptions) (io.ReadCloser, error) {
+ imagePullFn: func(context.Context, string, dockerImagePullOptions) (io.ReadCloser, error) {
return io.NopCloser(strings.NewReader("{}")), nil
},
- containerStopFn: func(context.Context, string, containertypes.StopOptions) error {
+ containerStopFn: func(context.Context, string, dockerContainerStopOptions) error {
return errors.New("stop failed")
},
},
@@ -111,16 +108,16 @@ func TestUpdateContainer_Errors(t *testing.T) {
containerInspectFn: func(context.Context, string) (containertypes.InspectResponse, error) {
return baseInspect(), nil
},
- imagePullFn: func(context.Context, string, image.PullOptions) (io.ReadCloser, error) {
+ imagePullFn: func(context.Context, string, dockerImagePullOptions) (io.ReadCloser, error) {
return io.NopCloser(strings.NewReader("{}")), nil
},
- containerStopFn: func(context.Context, string, containertypes.StopOptions) error {
+ containerStopFn: func(context.Context, string, dockerContainerStopOptions) error {
return nil
},
containerRenameFn: func(context.Context, string, string) error {
return errors.New("rename failed")
},
- containerStartFn: func(context.Context, string, containertypes.StartOptions) error {
+ containerStartFn: func(context.Context, string, dockerContainerStartOptions) error {
startCalled = true
return nil
},
@@ -145,10 +142,10 @@ func TestUpdateContainer_Errors(t *testing.T) {
containerInspectFn: func(context.Context, string) (containertypes.InspectResponse, error) {
return baseInspect(), nil
},
- imagePullFn: func(context.Context, string, image.PullOptions) (io.ReadCloser, error) {
+ imagePullFn: func(context.Context, string, dockerImagePullOptions) (io.ReadCloser, error) {
return io.NopCloser(strings.NewReader("{}")), nil
},
- containerStopFn: func(context.Context, string, containertypes.StopOptions) error {
+ containerStopFn: func(context.Context, string, dockerContainerStopOptions) error {
return nil
},
containerRenameFn: func(context.Context, string, string) error {
@@ -158,7 +155,7 @@ func TestUpdateContainer_Errors(t *testing.T) {
containerCreateFn: func(context.Context, *containertypes.Config, *containertypes.HostConfig, *network.NetworkingConfig, *v1.Platform, string) (containertypes.CreateResponse, error) {
return containertypes.CreateResponse{}, errors.New("create failed")
},
- containerStartFn: func(context.Context, string, containertypes.StartOptions) error {
+ containerStartFn: func(context.Context, string, dockerContainerStartOptions) error {
startCalled = true
return nil
},
@@ -184,23 +181,23 @@ func TestUpdateContainer_Errors(t *testing.T) {
containerInspectFn: func(context.Context, string) (containertypes.InspectResponse, error) {
return baseInspect(), nil
},
- imagePullFn: func(context.Context, string, image.PullOptions) (io.ReadCloser, error) {
+ imagePullFn: func(context.Context, string, dockerImagePullOptions) (io.ReadCloser, error) {
return io.NopCloser(strings.NewReader("{}")), nil
},
- containerStopFn: func(context.Context, string, containertypes.StopOptions) error {
+ containerStopFn: func(context.Context, string, dockerContainerStopOptions) error {
return nil
},
containerCreateFn: func(context.Context, *containertypes.Config, *containertypes.HostConfig, *network.NetworkingConfig, *v1.Platform, string) (containertypes.CreateResponse, error) {
return containertypes.CreateResponse{ID: "new123"}, nil
},
- containerStartFn: func(_ context.Context, id string, _ containertypes.StartOptions) error {
+ containerStartFn: func(_ context.Context, id string, _ dockerContainerStartOptions) error {
if id == "new123" {
return errors.New("start failed")
}
restarted = true
return nil
},
- containerRemoveFn: func(context.Context, string, containertypes.RemoveOptions) error {
+ containerRemoveFn: func(context.Context, string, dockerContainerRemoveOptions) error {
removed = true
return nil
},
@@ -244,15 +241,15 @@ func TestUpdateContainer_Success(t *testing.T) {
containerInspectFn: func(_ context.Context, id string) (containertypes.InspectResponse, error) {
if id == "new123" {
inspect := baseInspect()
- inspect.ContainerJSONBase.Image = "sha256:new0000000000"
+ inspect.Image = "sha256:new0000000000"
return inspect, nil
}
return baseInspect(), nil
},
- imagePullFn: func(context.Context, string, image.PullOptions) (io.ReadCloser, error) {
+ imagePullFn: func(context.Context, string, dockerImagePullOptions) (io.ReadCloser, error) {
return io.NopCloser(strings.NewReader("{}")), nil
},
- containerStopFn: func(context.Context, string, containertypes.StopOptions) error {
+ containerStopFn: func(context.Context, string, dockerContainerStopOptions) error {
return nil
},
containerRenameFn: func(context.Context, string, string) error {
@@ -264,10 +261,10 @@ func TestUpdateContainer_Success(t *testing.T) {
networkConnectFn: func(context.Context, string, string, *network.EndpointSettings) error {
return errors.New("network connect failed")
},
- containerStartFn: func(context.Context, string, containertypes.StartOptions) error {
+ containerStartFn: func(context.Context, string, dockerContainerStartOptions) error {
return nil
},
- containerRemoveFn: func(context.Context, string, containertypes.RemoveOptions) error {
+ containerRemoveFn: func(context.Context, string, dockerContainerRemoveOptions) error {
mu.Lock()
cleanupCalls++
err := cleanupErr
@@ -319,7 +316,7 @@ func TestUpdateContainer_StoppedContainerPreservesStoppedState(t *testing.T) {
if inspect.State != nil {
inspect.State.Running = false
}
- inspect.ContainerJSONBase.Image = "sha256:new0000000000"
+ inspect.Image = "sha256:new0000000000"
return inspect, nil
}
inspect := baseInspect()
@@ -328,10 +325,10 @@ func TestUpdateContainer_StoppedContainerPreservesStoppedState(t *testing.T) {
}
return inspect, nil
},
- imagePullFn: func(context.Context, string, image.PullOptions) (io.ReadCloser, error) {
+ imagePullFn: func(context.Context, string, dockerImagePullOptions) (io.ReadCloser, error) {
return io.NopCloser(strings.NewReader("{}")), nil
},
- containerStopFn: func(context.Context, string, containertypes.StopOptions) error {
+ containerStopFn: func(context.Context, string, dockerContainerStopOptions) error {
t.Fatalf("did not expect ContainerStop to be called for stopped container")
return nil
},
@@ -344,11 +341,11 @@ func TestUpdateContainer_StoppedContainerPreservesStoppedState(t *testing.T) {
networkConnectFn: func(context.Context, string, string, *network.EndpointSettings) error {
return nil
},
- containerStartFn: func(context.Context, string, containertypes.StartOptions) error {
+ containerStartFn: func(context.Context, string, dockerContainerStartOptions) error {
t.Fatalf("did not expect ContainerStart to be called for stopped container")
return nil
},
- containerRemoveFn: func(context.Context, string, containertypes.RemoveOptions) error {
+ containerRemoveFn: func(context.Context, string, dockerContainerRemoveOptions) error {
close(done)
return nil
},
@@ -385,15 +382,15 @@ func TestUpdateContainer_CleanupError(t *testing.T) {
containerInspectFn: func(_ context.Context, id string) (containertypes.InspectResponse, error) {
if id == "new123" {
inspect := baseInspect()
- inspect.ContainerJSONBase.Image = "sha256:new0000000000"
+ inspect.Image = "sha256:new0000000000"
return inspect, nil
}
return baseInspect(), nil
},
- imagePullFn: func(context.Context, string, image.PullOptions) (io.ReadCloser, error) {
+ imagePullFn: func(context.Context, string, dockerImagePullOptions) (io.ReadCloser, error) {
return io.NopCloser(strings.NewReader("{}")), nil
},
- containerStopFn: func(context.Context, string, containertypes.StopOptions) error {
+ containerStopFn: func(context.Context, string, dockerContainerStopOptions) error {
return nil
},
containerRenameFn: func(context.Context, string, string) error {
@@ -402,10 +399,10 @@ func TestUpdateContainer_CleanupError(t *testing.T) {
containerCreateFn: func(context.Context, *containertypes.Config, *containertypes.HostConfig, *network.NetworkingConfig, *v1.Platform, string) (containertypes.CreateResponse, error) {
return containertypes.CreateResponse{ID: "new123"}, nil
},
- containerStartFn: func(context.Context, string, containertypes.StartOptions) error {
+ containerStartFn: func(context.Context, string, dockerContainerStartOptions) error {
return nil
},
- containerRemoveFn: func(context.Context, string, containertypes.RemoveOptions) error {
+ containerRemoveFn: func(context.Context, string, dockerContainerRemoveOptions) error {
close(done)
return cleanupErr
},
@@ -438,14 +435,14 @@ func TestHandleUpdateContainerCommand(t *testing.T) {
containerInspectFn: func(_ context.Context, id string) (containertypes.InspectResponse, error) {
inspect := baseInspect()
if id == "new123" {
- inspect.ContainerJSONBase.Image = "sha256:new0000000000"
+ inspect.Image = "sha256:new0000000000"
}
return inspect, nil
},
- imagePullFn: func(context.Context, string, image.PullOptions) (io.ReadCloser, error) {
+ imagePullFn: func(context.Context, string, dockerImagePullOptions) (io.ReadCloser, error) {
return io.NopCloser(strings.NewReader("{}")), nil
},
- containerStopFn: func(context.Context, string, containertypes.StopOptions) error {
+ containerStopFn: func(context.Context, string, dockerContainerStopOptions) error {
return nil
},
containerRenameFn: func(context.Context, string, string) error {
@@ -454,7 +451,7 @@ func TestHandleUpdateContainerCommand(t *testing.T) {
containerCreateFn: func(context.Context, *containertypes.Config, *containertypes.HostConfig, *network.NetworkingConfig, *v1.Platform, string) (containertypes.CreateResponse, error) {
return containertypes.CreateResponse{ID: "new123"}, nil
},
- containerStartFn: func(context.Context, string, containertypes.StartOptions) error {
+ containerStartFn: func(context.Context, string, dockerContainerStartOptions) error {
return nil
},
},
@@ -587,14 +584,14 @@ func TestHandleUpdateContainerCommand(t *testing.T) {
containerInspectFn: func(_ context.Context, id string) (containertypes.InspectResponse, error) {
inspect := baseInspect()
if id == "new123" {
- inspect.ContainerJSONBase.Image = "sha256:new0000000000"
+ inspect.Image = "sha256:new0000000000"
}
return inspect, nil
},
- imagePullFn: func(context.Context, string, image.PullOptions) (io.ReadCloser, error) {
+ imagePullFn: func(context.Context, string, dockerImagePullOptions) (io.ReadCloser, error) {
return io.NopCloser(strings.NewReader("{}")), nil
},
- containerStopFn: func(context.Context, string, containertypes.StopOptions) error {
+ containerStopFn: func(context.Context, string, dockerContainerStopOptions) error {
return nil
},
containerRenameFn: func(context.Context, string, string) error {
@@ -603,7 +600,7 @@ func TestHandleUpdateContainerCommand(t *testing.T) {
containerCreateFn: func(context.Context, *containertypes.Config, *containertypes.HostConfig, *network.NetworkingConfig, *v1.Platform, string) (containertypes.CreateResponse, error) {
return containertypes.CreateResponse{ID: "new123"}, nil
},
- containerStartFn: func(context.Context, string, containertypes.StartOptions) error {
+ containerStartFn: func(context.Context, string, dockerContainerStartOptions) error {
return nil
},
},
diff --git a/internal/dockeragent/deps.go b/internal/dockeragent/deps.go
index 7896f3bd83..793cf6fef0 100644
--- a/internal/dockeragent/deps.go
+++ b/internal/dockeragent/deps.go
@@ -11,7 +11,7 @@ import (
"syscall"
"time"
- "github.com/docker/docker/client"
+ "github.com/moby/moby/client"
"github.com/rcourtman/pulse-go-rewrite/internal/hostmetrics"
)
@@ -58,7 +58,7 @@ var (
return os.Open("/proc/uptime")
}
newDockerClientFn = func(opts ...client.Opt) (dockerClient, error) {
- return client.NewClientWithOpts(opts...)
+ return newMobyDockerClient(opts...)
}
selfUpdateFunc = func(a *Agent, ctx context.Context) error {
return a.selfUpdate(ctx)
diff --git a/internal/dockeragent/docker_client.go b/internal/dockeragent/docker_client.go
index 8d8275acac..ed60c93d12 100644
--- a/internal/dockeragent/docker_client.go
+++ b/internal/dockeragent/docker_client.go
@@ -4,30 +4,251 @@ import (
"context"
"io"
- containertypes "github.com/docker/docker/api/types/container"
- "github.com/docker/docker/api/types/image"
- "github.com/docker/docker/api/types/network"
- swarmtypes "github.com/docker/docker/api/types/swarm"
- systemtypes "github.com/docker/docker/api/types/system"
+ containertypes "github.com/moby/moby/api/types/container"
+ "github.com/moby/moby/api/types/image"
+ "github.com/moby/moby/api/types/network"
+ swarmtypes "github.com/moby/moby/api/types/swarm"
+ systemtypes "github.com/moby/moby/api/types/system"
+ "github.com/moby/moby/client"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)
+type dockerFilters map[string]map[string]bool
+
+func newDockerFilters() dockerFilters {
+ return make(dockerFilters)
+}
+
+func (f dockerFilters) Add(key, value string) {
+ if _, ok := f[key]; ok {
+ f[key][value] = true
+ return
+ }
+ f[key] = map[string]bool{value: true}
+}
+
+func (f dockerFilters) Get(key string) []string {
+ values := f[key]
+ if len(values) == 0 {
+ return []string{}
+ }
+
+ result := make([]string, 0, len(values))
+ for value := range values {
+ result = append(result, value)
+ }
+ return result
+}
+
+func (f dockerFilters) Len() int {
+ return len(f)
+}
+
+func (f dockerFilters) toClientFilters() client.Filters {
+ if len(f) == 0 {
+ return nil
+ }
+
+ out := make(client.Filters, len(f))
+ for key, values := range f {
+ copied := make(map[string]bool, len(values))
+ for value, enabled := range values {
+ copied[value] = enabled
+ }
+ out[key] = copied
+ }
+ return out
+}
+
+type dockerContainerListOptions struct {
+ All bool
+ Filters dockerFilters
+}
+
+type dockerStatsResponseReader struct {
+ Body io.ReadCloser
+}
+
+type dockerImagePullOptions struct{}
+
+type dockerContainerStopOptions struct {
+ Signal string
+ Timeout *int
+}
+
+type dockerContainerStartOptions struct {
+ CheckpointID string
+ CheckpointDir string
+}
+
+type dockerContainerRemoveOptions struct {
+ RemoveVolumes bool
+ RemoveLinks bool
+ Force bool
+}
+
+type dockerServiceListOptions struct {
+ Status bool
+}
+
+type dockerTaskListOptions struct {
+ Filters dockerFilters
+}
+
type dockerClient interface {
Info(ctx context.Context) (systemtypes.Info, error)
DaemonHost() string
- ContainerList(ctx context.Context, options containertypes.ListOptions) ([]containertypes.Summary, error)
+ ContainerList(ctx context.Context, options dockerContainerListOptions) ([]containertypes.Summary, error)
ContainerInspectWithRaw(ctx context.Context, containerID string, size bool) (containertypes.InspectResponse, []byte, error)
- ContainerStatsOneShot(ctx context.Context, containerID string) (containertypes.StatsResponseReader, error)
+ ContainerStatsOneShot(ctx context.Context, containerID string) (dockerStatsResponseReader, error)
ContainerInspect(ctx context.Context, containerID string) (containertypes.InspectResponse, error)
- ImagePull(ctx context.Context, ref string, options image.PullOptions) (io.ReadCloser, error)
- ContainerStop(ctx context.Context, containerID string, options containertypes.StopOptions) error
+ ImagePull(ctx context.Context, ref string, options dockerImagePullOptions) (io.ReadCloser, error)
+ ContainerStop(ctx context.Context, containerID string, options dockerContainerStopOptions) error
ContainerRename(ctx context.Context, containerID, newName string) error
ContainerCreate(ctx context.Context, config *containertypes.Config, hostConfig *containertypes.HostConfig, networkingConfig *network.NetworkingConfig, platform *v1.Platform, containerName string) (containertypes.CreateResponse, error)
NetworkConnect(ctx context.Context, networkID, containerID string, config *network.EndpointSettings) error
- ContainerStart(ctx context.Context, containerID string, options containertypes.StartOptions) error
- ContainerRemove(ctx context.Context, containerID string, options containertypes.RemoveOptions) error
- ServiceList(ctx context.Context, options swarmtypes.ServiceListOptions) ([]swarmtypes.Service, error)
- TaskList(ctx context.Context, options swarmtypes.TaskListOptions) ([]swarmtypes.Task, error)
+ ContainerStart(ctx context.Context, containerID string, options dockerContainerStartOptions) error
+ ContainerRemove(ctx context.Context, containerID string, options dockerContainerRemoveOptions) error
+ ServiceList(ctx context.Context, options dockerServiceListOptions) ([]swarmtypes.Service, error)
+ TaskList(ctx context.Context, options dockerTaskListOptions) ([]swarmtypes.Task, error)
ImageInspectWithRaw(ctx context.Context, imageID string) (image.InspectResponse, []byte, error)
Close() error
}
+
+type mobyDockerClient struct {
+ *client.Client
+}
+
+func newMobyDockerClient(opts ...client.Opt) (dockerClient, error) {
+ cli, err := client.New(opts...)
+ if err != nil {
+ return nil, err
+ }
+ return &mobyDockerClient{Client: cli}, nil
+}
+
+func (m *mobyDockerClient) Info(ctx context.Context) (systemtypes.Info, error) {
+ result, err := m.Client.Info(ctx, client.InfoOptions{})
+ if err != nil {
+ return systemtypes.Info{}, err
+ }
+ return result.Info, nil
+}
+
+func (m *mobyDockerClient) ContainerList(ctx context.Context, options dockerContainerListOptions) ([]containertypes.Summary, error) {
+ result, err := m.Client.ContainerList(ctx, client.ContainerListOptions{
+ All: options.All,
+ Filters: options.Filters.toClientFilters(),
+ })
+ if err != nil {
+ return nil, err
+ }
+ return result.Items, nil
+}
+
+func (m *mobyDockerClient) ContainerInspectWithRaw(ctx context.Context, containerID string, size bool) (containertypes.InspectResponse, []byte, error) {
+ result, err := m.Client.ContainerInspect(ctx, containerID, client.ContainerInspectOptions{Size: size})
+ if err != nil {
+ return containertypes.InspectResponse{}, nil, err
+ }
+ return result.Container, result.Raw, nil
+}
+
+func (m *mobyDockerClient) ContainerStatsOneShot(ctx context.Context, containerID string) (dockerStatsResponseReader, error) {
+ result, err := m.Client.ContainerStats(ctx, containerID, client.ContainerStatsOptions{
+ Stream: false,
+ IncludePreviousSample: false,
+ })
+ if err != nil {
+ return dockerStatsResponseReader{}, err
+ }
+ return dockerStatsResponseReader{Body: result.Body}, nil
+}
+
+func (m *mobyDockerClient) ContainerInspect(ctx context.Context, containerID string) (containertypes.InspectResponse, error) {
+ result, err := m.Client.ContainerInspect(ctx, containerID, client.ContainerInspectOptions{})
+ if err != nil {
+ return containertypes.InspectResponse{}, err
+ }
+ return result.Container, nil
+}
+
+func (m *mobyDockerClient) ImagePull(ctx context.Context, ref string, _ dockerImagePullOptions) (io.ReadCloser, error) {
+ return m.Client.ImagePull(ctx, ref, client.ImagePullOptions{})
+}
+
+func (m *mobyDockerClient) ContainerStop(ctx context.Context, containerID string, options dockerContainerStopOptions) error {
+ _, err := m.Client.ContainerStop(ctx, containerID, client.ContainerStopOptions{
+ Signal: options.Signal,
+ Timeout: options.Timeout,
+ })
+ return err
+}
+
+func (m *mobyDockerClient) ContainerRename(ctx context.Context, containerID, newName string) error {
+ _, err := m.Client.ContainerRename(ctx, containerID, client.ContainerRenameOptions{NewName: newName})
+ return err
+}
+
+func (m *mobyDockerClient) ContainerCreate(ctx context.Context, config *containertypes.Config, hostConfig *containertypes.HostConfig, networkingConfig *network.NetworkingConfig, platform *v1.Platform, containerName string) (containertypes.CreateResponse, error) {
+ result, err := m.Client.ContainerCreate(ctx, client.ContainerCreateOptions{
+ Config: config,
+ HostConfig: hostConfig,
+ NetworkingConfig: networkingConfig,
+ Platform: platform,
+ Name: containerName,
+ })
+ if err != nil {
+ return containertypes.CreateResponse{}, err
+ }
+ return containertypes.CreateResponse{ID: result.ID, Warnings: result.Warnings}, nil
+}
+
+func (m *mobyDockerClient) NetworkConnect(ctx context.Context, networkID, containerID string, config *network.EndpointSettings) error {
+ _, err := m.Client.NetworkConnect(ctx, networkID, client.NetworkConnectOptions{
+ Container: containerID,
+ EndpointConfig: config,
+ })
+ return err
+}
+
+func (m *mobyDockerClient) ContainerStart(ctx context.Context, containerID string, options dockerContainerStartOptions) error {
+ _, err := m.Client.ContainerStart(ctx, containerID, client.ContainerStartOptions{
+ CheckpointID: options.CheckpointID,
+ CheckpointDir: options.CheckpointDir,
+ })
+ return err
+}
+
+func (m *mobyDockerClient) ContainerRemove(ctx context.Context, containerID string, options dockerContainerRemoveOptions) error {
+ _, err := m.Client.ContainerRemove(ctx, containerID, client.ContainerRemoveOptions{
+ RemoveVolumes: options.RemoveVolumes,
+ RemoveLinks: options.RemoveLinks,
+ Force: options.Force,
+ })
+ return err
+}
+
+func (m *mobyDockerClient) ServiceList(ctx context.Context, options dockerServiceListOptions) ([]swarmtypes.Service, error) {
+ result, err := m.Client.ServiceList(ctx, client.ServiceListOptions{Status: options.Status})
+ if err != nil {
+ return nil, err
+ }
+ return result.Items, nil
+}
+
+func (m *mobyDockerClient) TaskList(ctx context.Context, options dockerTaskListOptions) ([]swarmtypes.Task, error) {
+ result, err := m.Client.TaskList(ctx, client.TaskListOptions{Filters: options.Filters.toClientFilters()})
+ if err != nil {
+ return nil, err
+ }
+ return result.Items, nil
+}
+
+func (m *mobyDockerClient) ImageInspectWithRaw(ctx context.Context, imageID string) (image.InspectResponse, []byte, error) {
+ result, err := m.Client.ImageInspect(ctx, imageID)
+ if err != nil {
+ return image.InspectResponse{}, nil, err
+ }
+ return result.InspectResponse, nil, nil
+}
diff --git a/internal/dockeragent/runtime_coverage_test.go b/internal/dockeragent/runtime_coverage_test.go
index af652903c0..5af493f710 100644
--- a/internal/dockeragent/runtime_coverage_test.go
+++ b/internal/dockeragent/runtime_coverage_test.go
@@ -6,8 +6,8 @@ import (
"strings"
"testing"
- systemtypes "github.com/docker/docker/api/types/system"
- "github.com/docker/docker/client"
+ systemtypes "github.com/moby/moby/api/types/system"
+ "github.com/moby/moby/client"
"github.com/rs/zerolog"
)
diff --git a/internal/dockeragent/swarm.go b/internal/dockeragent/swarm.go
index e3cd2d7814..899934d2f3 100644
--- a/internal/dockeragent/swarm.go
+++ b/internal/dockeragent/swarm.go
@@ -7,9 +7,8 @@ import (
"strconv"
"strings"
- "github.com/docker/docker/api/types/filters"
- swarmtypes "github.com/docker/docker/api/types/swarm"
- systemtypes "github.com/docker/docker/api/types/system"
+ swarmtypes "github.com/moby/moby/api/types/swarm"
+ systemtypes "github.com/moby/moby/api/types/system"
agentsdocker "github.com/rcourtman/pulse-go-rewrite/pkg/agents/docker"
)
@@ -153,7 +152,7 @@ func (a *Agent) collectSwarmData(ctx context.Context, info systemtypes.Info, con
func (a *Agent) collectSwarmDataFromManager(ctx context.Context, info systemtypes.Info, scope string, containers map[string]agentsdocker.Container, includeServices, includeTasks bool) ([]agentsdocker.Service, []agentsdocker.Task, error) {
serviceList, err := dockerCallWithRetry(ctx, dockerSwarmListCallTimeout, func(callCtx context.Context) ([]swarmtypes.Service, error) {
- return a.docker.ServiceList(callCtx, swarmtypes.ServiceListOptions{Status: true})
+ return a.docker.ServiceList(callCtx, dockerServiceListOptions{Status: true})
})
if err != nil {
return nil, nil, annotateDockerConnectionError(err)
@@ -174,14 +173,14 @@ func (a *Agent) collectSwarmDataFromManager(ctx context.Context, info systemtype
var tasks []agentsdocker.Task
if includeTasks {
- taskFilters := filters.NewArgs()
+ taskFilters := newDockerFilters()
taskFilters.Add("desired-state", string(swarmtypes.TaskStateRunning))
if scope != swarmScopeCluster && info.Swarm.NodeID != "" {
taskFilters.Add("node", info.Swarm.NodeID)
}
taskList, err := dockerCallWithRetry(ctx, dockerSwarmListCallTimeout, func(callCtx context.Context) ([]swarmtypes.Task, error) {
- return a.docker.TaskList(callCtx, swarmtypes.TaskListOptions{Filters: taskFilters})
+ return a.docker.TaskList(callCtx, dockerTaskListOptions{Filters: taskFilters})
})
if err != nil {
return services, nil, annotateDockerConnectionError(err)
diff --git a/internal/dockeragent/swarm_coverage_test.go b/internal/dockeragent/swarm_coverage_test.go
index bd0c7036d4..cb5f0f7af0 100644
--- a/internal/dockeragent/swarm_coverage_test.go
+++ b/internal/dockeragent/swarm_coverage_test.go
@@ -6,8 +6,9 @@ import (
"testing"
"time"
- swarmtypes "github.com/docker/docker/api/types/swarm"
- systemtypes "github.com/docker/docker/api/types/system"
+ networktypes "github.com/moby/moby/api/types/network"
+ swarmtypes "github.com/moby/moby/api/types/swarm"
+ systemtypes "github.com/moby/moby/api/types/system"
agentsdocker "github.com/rcourtman/pulse-go-rewrite/pkg/agents/docker"
)
@@ -72,7 +73,7 @@ func TestMapSwarmService(t *testing.T) {
},
Endpoint: swarmtypes.Endpoint{
Ports: []swarmtypes.PortConfig{
- {Name: "http", Protocol: swarmtypes.PortConfigProtocolTCP, TargetPort: 80, PublishedPort: 8080, PublishMode: swarmtypes.PortConfigPublishModeIngress},
+ {Name: "http", Protocol: networktypes.TCP, TargetPort: 80, PublishedPort: 8080, PublishMode: swarmtypes.PortConfigPublishModeIngress},
},
},
Meta: swarmtypes.Meta{
@@ -206,13 +207,13 @@ func TestMapSwarmTask(t *testing.T) {
func TestCollectSwarmDataFromManager(t *testing.T) {
agent := &Agent{
docker: &fakeDockerClient{
- serviceListFn: func(_ context.Context, _ swarmtypes.ServiceListOptions) ([]swarmtypes.Service, error) {
+ serviceListFn: func(_ context.Context, _ dockerServiceListOptions) ([]swarmtypes.Service, error) {
return []swarmtypes.Service{
{ID: "svc1", Spec: swarmtypes.ServiceSpec{Annotations: swarmtypes.Annotations{Name: "alpha"}}},
{ID: "svc2", Spec: swarmtypes.ServiceSpec{Annotations: swarmtypes.Annotations{Name: "beta"}}},
}, nil
},
- taskListFn: func(_ context.Context, opts swarmtypes.TaskListOptions) ([]swarmtypes.Task, error) {
+ taskListFn: func(_ context.Context, opts dockerTaskListOptions) ([]swarmtypes.Task, error) {
if got := opts.Filters.Get("node"); len(got) != 1 || got[0] != "node1" {
t.Fatalf("expected node filter to include node1, got %v", got)
}
@@ -250,12 +251,12 @@ func TestCollectSwarmDataFromManager(t *testing.T) {
t.Run("task list error", func(t *testing.T) {
agent := &Agent{
docker: &fakeDockerClient{
- serviceListFn: func(_ context.Context, _ swarmtypes.ServiceListOptions) ([]swarmtypes.Service, error) {
+ serviceListFn: func(_ context.Context, _ dockerServiceListOptions) ([]swarmtypes.Service, error) {
return []swarmtypes.Service{
{ID: "svc1", Spec: swarmtypes.ServiceSpec{Annotations: swarmtypes.Annotations{Name: "alpha"}}},
}, nil
},
- taskListFn: func(_ context.Context, _ swarmtypes.TaskListOptions) ([]swarmtypes.Task, error) {
+ taskListFn: func(_ context.Context, _ dockerTaskListOptions) ([]swarmtypes.Task, error) {
return nil, errors.New("task failed")
},
},
@@ -321,7 +322,7 @@ func TestCollectSwarmData(t *testing.T) {
SwarmScope: swarmScopeAuto,
},
docker: &fakeDockerClient{
- serviceListFn: func(context.Context, swarmtypes.ServiceListOptions) ([]swarmtypes.Service, error) {
+ serviceListFn: func(context.Context, dockerServiceListOptions) ([]swarmtypes.Service, error) {
return nil, errors.New("boom")
},
},
@@ -374,13 +375,13 @@ func TestCollectSwarmData(t *testing.T) {
SwarmScope: swarmScopeCluster,
},
docker: &fakeDockerClient{
- serviceListFn: func(context.Context, swarmtypes.ServiceListOptions) ([]swarmtypes.Service, error) {
+ serviceListFn: func(context.Context, dockerServiceListOptions) ([]swarmtypes.Service, error) {
return []swarmtypes.Service{
{ID: "svc1", Spec: swarmtypes.ServiceSpec{Annotations: swarmtypes.Annotations{Name: "zeta"}}},
{ID: "svc2", Spec: swarmtypes.ServiceSpec{Annotations: swarmtypes.Annotations{Name: "alpha"}}},
}, nil
},
- taskListFn: func(context.Context, swarmtypes.TaskListOptions) ([]swarmtypes.Task, error) {
+ taskListFn: func(context.Context, dockerTaskListOptions) ([]swarmtypes.Task, error) {
return []swarmtypes.Task{
{ID: "task2", ServiceID: "svc2", Slot: 2, DesiredState: swarmtypes.TaskStateRunning, Status: swarmtypes.TaskStatus{State: swarmtypes.TaskStateRunning}},
{ID: "task1", ServiceID: "svc2", Slot: 1, DesiredState: swarmtypes.TaskStateRunning, Status: swarmtypes.TaskStatus{State: swarmtypes.TaskStateRunning}},
@@ -492,14 +493,14 @@ func TestCollectSwarmData(t *testing.T) {
SwarmScope: swarmScopeCluster,
},
docker: &fakeDockerClient{
- serviceListFn: func(context.Context, swarmtypes.ServiceListOptions) ([]swarmtypes.Service, error) {
+ serviceListFn: func(context.Context, dockerServiceListOptions) ([]swarmtypes.Service, error) {
return []swarmtypes.Service{
{ID: "b", Spec: swarmtypes.ServiceSpec{Annotations: swarmtypes.Annotations{Name: "web"}}},
{ID: "a", Spec: swarmtypes.ServiceSpec{Annotations: swarmtypes.Annotations{Name: "web"}}},
{ID: "c", Spec: swarmtypes.ServiceSpec{Annotations: swarmtypes.Annotations{Name: "api"}}},
}, nil
},
- taskListFn: func(context.Context, swarmtypes.TaskListOptions) ([]swarmtypes.Task, error) {
+ taskListFn: func(context.Context, dockerTaskListOptions) ([]swarmtypes.Task, error) {
return []swarmtypes.Task{
{ID: "b", ServiceID: "a", Slot: 1, DesiredState: swarmtypes.TaskStateRunning, Status: swarmtypes.TaskStatus{State: swarmtypes.TaskStateRunning}},
{ID: "a", ServiceID: "a", Slot: 1, DesiredState: swarmtypes.TaskStateRunning, Status: swarmtypes.TaskStatus{State: swarmtypes.TaskStateRunning}},
diff --git a/internal/dockeragent/swarm_test.go b/internal/dockeragent/swarm_test.go
index 288daea58c..bf5818ede4 100644
--- a/internal/dockeragent/swarm_test.go
+++ b/internal/dockeragent/swarm_test.go
@@ -4,7 +4,7 @@ import (
"reflect"
"testing"
- swarmtypes "github.com/docker/docker/api/types/swarm"
+ swarmtypes "github.com/moby/moby/api/types/swarm"
agentsdocker "github.com/rcourtman/pulse-go-rewrite/pkg/agents/docker"
)
diff --git a/internal/dockeragent/test_helpers_test.go b/internal/dockeragent/test_helpers_test.go
index 9fd11d5a93..0bfa918540 100644
--- a/internal/dockeragent/test_helpers_test.go
+++ b/internal/dockeragent/test_helpers_test.go
@@ -8,30 +8,30 @@ import (
"io"
"testing"
- containertypes "github.com/docker/docker/api/types/container"
- "github.com/docker/docker/api/types/image"
- "github.com/docker/docker/api/types/network"
- swarmtypes "github.com/docker/docker/api/types/swarm"
- systemtypes "github.com/docker/docker/api/types/system"
+ containertypes "github.com/moby/moby/api/types/container"
+ "github.com/moby/moby/api/types/image"
+ "github.com/moby/moby/api/types/network"
+ swarmtypes "github.com/moby/moby/api/types/swarm"
+ systemtypes "github.com/moby/moby/api/types/system"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)
type fakeDockerClient struct {
daemonHost string
infoFunc func(ctx context.Context) (systemtypes.Info, error)
- containerListFunc func(ctx context.Context, opts containertypes.ListOptions) ([]containertypes.Summary, error)
+ containerListFunc func(ctx context.Context, opts dockerContainerListOptions) ([]containertypes.Summary, error)
containerInspectWithRawFn func(ctx context.Context, id string, size bool) (containertypes.InspectResponse, []byte, error)
- containerStatsOneShotFn func(ctx context.Context, id string) (containertypes.StatsResponseReader, error)
+ containerStatsOneShotFn func(ctx context.Context, id string) (dockerStatsResponseReader, error)
containerInspectFn func(ctx context.Context, id string) (containertypes.InspectResponse, error)
- imagePullFn func(ctx context.Context, ref string, opts image.PullOptions) (io.ReadCloser, error)
- containerStopFn func(ctx context.Context, id string, opts containertypes.StopOptions) error
+ imagePullFn func(ctx context.Context, ref string, opts dockerImagePullOptions) (io.ReadCloser, error)
+ containerStopFn func(ctx context.Context, id string, opts dockerContainerStopOptions) error
containerRenameFn func(ctx context.Context, id, newName string) error
containerCreateFn func(ctx context.Context, config *containertypes.Config, hostConfig *containertypes.HostConfig, networkingConfig *network.NetworkingConfig, platform *v1.Platform, containerName string) (containertypes.CreateResponse, error)
networkConnectFn func(ctx context.Context, netName, containerID string, endpoint *network.EndpointSettings) error
- containerStartFn func(ctx context.Context, id string, opts containertypes.StartOptions) error
- containerRemoveFn func(ctx context.Context, id string, opts containertypes.RemoveOptions) error
- serviceListFn func(ctx context.Context, opts swarmtypes.ServiceListOptions) ([]swarmtypes.Service, error)
- taskListFn func(ctx context.Context, opts swarmtypes.TaskListOptions) ([]swarmtypes.Task, error)
+ containerStartFn func(ctx context.Context, id string, opts dockerContainerStartOptions) error
+ containerRemoveFn func(ctx context.Context, id string, opts dockerContainerRemoveOptions) error
+ serviceListFn func(ctx context.Context, opts dockerServiceListOptions) ([]swarmtypes.Service, error)
+ taskListFn func(ctx context.Context, opts dockerTaskListOptions) ([]swarmtypes.Task, error)
imageInspectWithRawFn func(ctx context.Context, imageID string) (image.InspectResponse, []byte, error)
closeFn func() error
}
@@ -47,7 +47,7 @@ func (f *fakeDockerClient) DaemonHost() string {
return f.daemonHost
}
-func (f *fakeDockerClient) ContainerList(ctx context.Context, opts containertypes.ListOptions) ([]containertypes.Summary, error) {
+func (f *fakeDockerClient) ContainerList(ctx context.Context, opts dockerContainerListOptions) ([]containertypes.Summary, error) {
if f.containerListFunc == nil {
return nil, errors.New("unexpected ContainerList call")
}
@@ -61,9 +61,9 @@ func (f *fakeDockerClient) ContainerInspectWithRaw(ctx context.Context, id strin
return f.containerInspectWithRawFn(ctx, id, size)
}
-func (f *fakeDockerClient) ContainerStatsOneShot(ctx context.Context, id string) (containertypes.StatsResponseReader, error) {
+func (f *fakeDockerClient) ContainerStatsOneShot(ctx context.Context, id string) (dockerStatsResponseReader, error) {
if f.containerStatsOneShotFn == nil {
- return containertypes.StatsResponseReader{}, errors.New("unexpected ContainerStatsOneShot call")
+ return dockerStatsResponseReader{}, errors.New("unexpected ContainerStatsOneShot call")
}
return f.containerStatsOneShotFn(ctx, id)
}
@@ -75,14 +75,14 @@ func (f *fakeDockerClient) ContainerInspect(ctx context.Context, id string) (con
return f.containerInspectFn(ctx, id)
}
-func (f *fakeDockerClient) ImagePull(ctx context.Context, ref string, opts image.PullOptions) (io.ReadCloser, error) {
+func (f *fakeDockerClient) ImagePull(ctx context.Context, ref string, opts dockerImagePullOptions) (io.ReadCloser, error) {
if f.imagePullFn == nil {
return nil, errors.New("unexpected ImagePull call")
}
return f.imagePullFn(ctx, ref, opts)
}
-func (f *fakeDockerClient) ContainerStop(ctx context.Context, id string, opts containertypes.StopOptions) error {
+func (f *fakeDockerClient) ContainerStop(ctx context.Context, id string, opts dockerContainerStopOptions) error {
if f.containerStopFn == nil {
return errors.New("unexpected ContainerStop call")
}
@@ -110,28 +110,28 @@ func (f *fakeDockerClient) NetworkConnect(ctx context.Context, netName, containe
return f.networkConnectFn(ctx, netName, containerID, endpoint)
}
-func (f *fakeDockerClient) ContainerStart(ctx context.Context, id string, opts containertypes.StartOptions) error {
+func (f *fakeDockerClient) ContainerStart(ctx context.Context, id string, opts dockerContainerStartOptions) error {
if f.containerStartFn == nil {
return errors.New("unexpected ContainerStart call")
}
return f.containerStartFn(ctx, id, opts)
}
-func (f *fakeDockerClient) ContainerRemove(ctx context.Context, id string, opts containertypes.RemoveOptions) error {
+func (f *fakeDockerClient) ContainerRemove(ctx context.Context, id string, opts dockerContainerRemoveOptions) error {
if f.containerRemoveFn == nil {
return errors.New("unexpected ContainerRemove call")
}
return f.containerRemoveFn(ctx, id, opts)
}
-func (f *fakeDockerClient) ServiceList(ctx context.Context, opts swarmtypes.ServiceListOptions) ([]swarmtypes.Service, error) {
+func (f *fakeDockerClient) ServiceList(ctx context.Context, opts dockerServiceListOptions) ([]swarmtypes.Service, error) {
if f.serviceListFn == nil {
return nil, errors.New("unexpected ServiceList call")
}
return f.serviceListFn(ctx, opts)
}
-func (f *fakeDockerClient) TaskList(ctx context.Context, opts swarmtypes.TaskListOptions) ([]swarmtypes.Task, error) {
+func (f *fakeDockerClient) TaskList(ctx context.Context, opts dockerTaskListOptions) ([]swarmtypes.Task, error) {
if f.taskListFn == nil {
return nil, errors.New("unexpected TaskList call")
}
@@ -153,7 +153,7 @@ func (f *fakeDockerClient) Close() error {
return f.closeFn()
}
-func statsReader(t *testing.T, stats containertypes.StatsResponse) containertypes.StatsResponseReader {
+func statsReader(t *testing.T, stats containertypes.StatsResponse) dockerStatsResponseReader {
t.Helper()
payload, err := json.Marshal(stats)
@@ -161,7 +161,7 @@ func statsReader(t *testing.T, stats containertypes.StatsResponse) containertype
t.Fatalf("marshal stats: %v", err)
}
- return containertypes.StatsResponseReader{
+ return dockerStatsResponseReader{
Body: io.NopCloser(bytes.NewReader(payload)),
}
}
diff --git a/scripts/tests/test-hot-dev-bg.sh b/scripts/tests/test-hot-dev-bg.sh
index 211d1a2827..6b725e887a 100755
--- a/scripts/tests/test-hot-dev-bg.sh
+++ b/scripts/tests/test-hot-dev-bg.sh
@@ -591,6 +591,7 @@ path_env = {
"go.mod": "GO_MOD_PATH",
"go.sum": "GO_SUM_PATH",
}
+go_mod = Path(os.environ["GO_MOD_PATH"]).read_text(encoding="utf-8")
subsystem = next(item for item in registry["subsystems"] if item["id"] == "deployment-installability")
policy = next(
@@ -607,6 +608,10 @@ for path in paths:
print(f"{path}:owned={path in owned}")
print(f"{path}:policy={path in matched}")
print(f"{path}:contract={f'`{path}`' in contract}")
+
+print(f"go.mod:uses_moby_api={'github.com/moby/moby/api' in go_mod}")
+print(f"go.mod:uses_moby_client={'github.com/moby/moby/client' in go_mod}")
+print(f"go.mod:uses_legacy_docker={'github.com/docker/docker' in go_mod}")
PY
)"
@@ -623,6 +628,10 @@ PY
assert_contains "dev runtime manifest has proof policy: ${manifest_path}" "${output}" "${manifest_path}:policy=True"
assert_contains "dev runtime manifest is in contract: ${manifest_path}" "${output}" "${manifest_path}:contract=True"
done
+
+ assert_contains "go.mod uses maintained moby api module" "${output}" "go.mod:uses_moby_api=True"
+ assert_contains "go.mod uses maintained moby client module" "${output}" "go.mod:uses_moby_client=True"
+ assert_contains "go.mod drops legacy docker module" "${output}" "go.mod:uses_legacy_docker=False"
}
test_makefile_routes_managed_runtime_through_npm() {