Skip to content

Commit 1b903e4

Browse files
antitreeclaude
andcommitted
fix: remove moby/moby/v2 dependency for compatibility
Replace the moby/moby/v2 import (used only for DefaultCapabilities() in the bubblewrap runner) with an inlined capabilities list. This removes the dependency on the pre-release moby/moby/v2 module which causes ambiguous import errors in downstream consumers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 54faa68 commit 1b903e4

3 files changed

Lines changed: 27 additions & 8 deletions

File tree

go.mod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ require (
2222
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
2323
github.com/klauspost/compress v1.18.5
2424
github.com/klauspost/pgzip v1.2.6
25-
github.com/moby/moby/v2 v2.0.0-beta.8
2625
github.com/opencontainers/image-spec v1.1.1
2726
github.com/package-url/packageurl-go v0.1.5
2827
github.com/pkg/errors v0.9.1
@@ -55,15 +54,19 @@ require (
5554
github.com/clipperhouse/uax29/v2 v2.6.0 // indirect
5655
github.com/containerd/errdefs v1.0.0 // indirect
5756
github.com/containerd/errdefs/pkg v0.3.0 // indirect
57+
github.com/fsnotify/fsnotify v1.9.0 // indirect
5858
github.com/google/martian/v3 v3.3.3 // indirect
5959
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.1.0 // indirect
6060
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.3 // indirect
6161
github.com/ijt/goparsify v0.0.0-20221203142333-3a5276334b8d // indirect
6262
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
6363
github.com/moby/moby/api v1.54.0 // indirect
6464
github.com/moby/moby/client v0.3.0 // indirect
65+
github.com/moby/sys/atomicwriter v0.1.0 // indirect
66+
github.com/morikuni/aec v1.1.0 // indirect
6567
github.com/pavlo-v-chernykh/keystore-go/v4 v4.5.0 // indirect
6668
go.opencensus.io v0.24.0 // indirect
69+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.40.0 // indirect
6770
go.yaml.in/yaml/v3 v3.0.4 // indirect
6871
golang.org/x/tools v0.43.0 // indirect
6972
k8s.io/klog/v2 v2.130.1 // indirect
@@ -96,7 +99,6 @@ require (
9699
github.com/charmbracelet/x/term v0.2.1 // indirect
97100
github.com/cloudflare/circl v1.6.3 // indirect
98101
github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be // indirect
99-
github.com/containerd/containerd/v2 v2.2.1 // indirect
100102
github.com/containerd/log v0.1.0 // indirect
101103
github.com/containerd/stargz-snapshotter/estargz v0.18.2 // indirect
102104
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ github.com/cloudflare/circl v1.6.3/go.mod h1:2eXP6Qfat4O/Yhh8BznvKnJ+uzEoTQ6jVKJ
6666
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
6767
github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be h1:J5BL2kskAlV9ckgEsNQXscjIaLiOYiZ75d4e94E6dcQ=
6868
github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be/go.mod h1:mk5IQ+Y0ZeO87b858TlA645sVcEcbiX6YqP98kt+7+w=
69-
github.com/containerd/containerd/v2 v2.2.1 h1:TpyxcY4AL5A+07dxETevunVS5zxqzuq7ZqJXknM11yk=
70-
github.com/containerd/containerd/v2 v2.2.1/go.mod h1:NR70yW1iDxe84F2iFWbR9xfAN0N2F0NcjTi1OVth4nU=
7169
github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI=
7270
github.com/containerd/errdefs v1.0.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M=
7371
github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE=
@@ -253,8 +251,6 @@ github.com/moby/moby/api v1.54.0 h1:7kbUgyiKcoBhm0UrWbdrMs7RX8dnwzURKVbZGy2GnL0=
253251
github.com/moby/moby/api v1.54.0/go.mod h1:8mb+ReTlisw4pS6BRzCMts5M49W5M7bKt1cJy/YbAqc=
254252
github.com/moby/moby/client v0.3.0 h1:UUGL5okry+Aomj3WhGt9Aigl3ZOxZGqR7XPo+RLPlKs=
255253
github.com/moby/moby/client v0.3.0/go.mod h1:HJgFbJRvogDQjbM8fqc1MCEm4mIAGMLjXbgwoZp6jCQ=
256-
github.com/moby/moby/v2 v2.0.0-beta.8 h1:3D/xW0DrCNuGPSJ+dnw9A97IJ3qwBmTxqmCWDEYtY38=
257-
github.com/moby/moby/v2 v2.0.0-beta.8/go.mod h1:92sEyRcWIBbM9stp3xl4I2t/gJzOFgrZ8prBT0IfD4g=
258254
github.com/moby/sys/atomicwriter v0.1.0 h1:kw5D/EqkBwsBFi0ss9v1VG3wIkVhzGvLklJ+w3A14Sw=
259255
github.com/moby/sys/atomicwriter v0.1.0/go.mod h1:Ul8oqv2ZMNHOceF643P6FKPXeCmYtlQMvpizfsSoaWs=
260256
github.com/moby/sys/sequential v0.6.0 h1:qrx7XFUd/5DxtqcoH1h438hF5TmOvzC/lspjy7zgvCU=

pkg/container/bubblewrap_runner.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import (
3434
apko_types "chainguard.dev/apko/pkg/build/types"
3535
"github.com/chainguard-dev/clog"
3636
v1 "github.com/google/go-containerregistry/pkg/v1"
37-
moby "github.com/moby/moby/v2/daemon/pkg/oci/caps"
3837
"go.opentelemetry.io/otel"
3938
)
4039

@@ -45,6 +44,26 @@ const (
4544
buildUserID = "1000"
4645
)
4746

47+
// defaultCapabilities is the set of Linux capabilities granted by the
48+
// Docker/Moby runtime by default. Mirrors moby/moby's DefaultCapabilities()
49+
// to avoid depending on moby/moby/v2 (pre-release) for a static list.
50+
var defaultCapabilities = []string{
51+
"CAP_CHOWN",
52+
"CAP_DAC_OVERRIDE",
53+
"CAP_FSETID",
54+
"CAP_FOWNER",
55+
"CAP_MKNOD",
56+
"CAP_NET_RAW",
57+
"CAP_SETGID",
58+
"CAP_SETUID",
59+
"CAP_SETFCAP",
60+
"CAP_SETPCAP",
61+
"CAP_NET_BIND_SERVICE",
62+
"CAP_SYS_CHROOT",
63+
"CAP_KILL",
64+
"CAP_AUDIT_WRITE",
65+
}
66+
4867
type bubblewrap struct {
4968
remove bool // if true, clean up temp dirs on close.
5069
}
@@ -138,7 +157,9 @@ func (bw *bubblewrap) cmd(ctx context.Context, cfg *Config, debug bool, envOverr
138157
}
139158

140159
// Add Docker runner-parity kernel capabilities to the container.
141-
for _, c := range moby.DefaultCapabilities() {
160+
// These are the default Linux capabilities granted by the Docker/Moby
161+
// runtime. Inlined to avoid pulling in moby/moby/v2 (beta) as a dependency.
162+
for _, c := range defaultCapabilities {
142163
baseargs = append(baseargs, "--cap-add", c)
143164
}
144165
// Add additional process kernel capabilities to the container as configured.

0 commit comments

Comments
 (0)