Skip to content

Commit ab914df

Browse files
authored
Merge pull request #74 from infosiftr/avoid-platforms.Default
Avoid platforms.Default by passing arch down earlier
2 parents e2e6171 + 706a814 commit ab914df

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

cmd/bashbrew/containerd.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
"github.com/containerd/containerd/content/local"
1111
"github.com/containerd/containerd/metadata"
1212
"github.com/containerd/containerd/namespaces"
13+
"github.com/containerd/containerd/platforms"
14+
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
1315

1416
"go.etcd.io/bbolt"
1517
)
@@ -64,6 +66,11 @@ func newContainerdClient(ctx context.Context) (context.Context, *containerd.Clie
6466
return ctx, containerdClientCache, nil
6567
}
6668

69+
opts := []containerd.ClientOpt{
70+
// we want to avoid "platforms.Default()" from trying to do detection (and sometimes erroring about "getCPUInfo" not having a variant), so we'll pass an explicit platform matcher
71+
containerd.WithDefaultPlatform(platforms.OnlyStrict(ocispec.Platform(ociArch))),
72+
}
73+
6774
for _, envKey := range []string{
6875
`BASHBREW_CONTAINERD_CONTENT_ADDRESS`, // TODO if we ever need to connnect to a containerd instance for something more interesting like running containers, we need to have *that* codepath not use _CONTENT_ variants
6976
`BASHBREW_CONTAINERD_ADDRESS`,
@@ -75,7 +82,7 @@ func newContainerdClient(ctx context.Context) (context.Context, *containerd.Clie
7582
// we'll use a set-but-empty variable as an explicit request to use our built-in implementation
7683
break
7784
}
78-
client, err := containerd.New(socket)
85+
client, err := containerd.New(socket, opts...)
7986
containerdClientCache = client
8087
return ctx, client, err
8188
}
@@ -86,7 +93,9 @@ func newContainerdClient(ctx context.Context) (context.Context, *containerd.Clie
8693
if err != nil {
8794
return ctx, nil, err
8895
}
89-
client, err := containerd.New("", services)
96+
opts = append(opts, services)
97+
98+
client, err := containerd.New("", opts...)
9099
containerdClientCache = client
91100
return ctx, client, err
92101
}

0 commit comments

Comments
 (0)