Skip to content

Commit 4e56939

Browse files
committed
Add platform config to proxy plugins
Signed-off-by: Derek McGowan <[email protected]>
1 parent 290a800 commit 4e56939

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

services/server/config/config.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,9 @@ type CgroupConfig struct {
167167

168168
// ProxyPlugin provides a proxy plugin configuration
169169
type ProxyPlugin struct {
170-
Type string `toml:"type"`
171-
Address string `toml:"address"`
170+
Type string `toml:"type"`
171+
Address string `toml:"address"`
172+
Platform string `toml:"platform"`
172173
}
173174

174175
// Decode unmarshals a plugin specific configuration by plugin id

services/server/server.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import (
4545
"github.com/containerd/containerd/log"
4646
"github.com/containerd/containerd/pkg/dialer"
4747
"github.com/containerd/containerd/pkg/timeout"
48+
"github.com/containerd/containerd/platforms"
4849
"github.com/containerd/containerd/plugin"
4950
srvconfig "github.com/containerd/containerd/services/server/config"
5051
ssproxy "github.com/containerd/containerd/snapshots/proxy"
@@ -53,6 +54,7 @@ import (
5354
"github.com/docker/go-metrics"
5455
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
5556
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
57+
v1 "github.com/opencontainers/image-spec/specs-go/v1"
5658
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
5759
"google.golang.org/grpc"
5860
"google.golang.org/grpc/backoff"
@@ -396,6 +398,8 @@ func LoadPlugins(ctx context.Context, config *srvconfig.Config) ([]*plugin.Regis
396398
f func(*grpc.ClientConn) interface{}
397399

398400
address = pp.Address
401+
p v1.Platform
402+
err error
399403
)
400404

401405
switch pp.Type {
@@ -419,12 +423,21 @@ func LoadPlugins(ctx context.Context, config *srvconfig.Config) ([]*plugin.Regis
419423
default:
420424
log.G(ctx).WithField("type", pp.Type).Warn("unknown proxy plugin type")
421425
}
426+
if pp.Platform != "" {
427+
p, err = platforms.Parse(pp.Platform)
428+
if err != nil {
429+
log.G(ctx).WithError(err).WithField("plugin", name).Warn("skipping proxy platform with bad platform")
430+
}
431+
} else {
432+
p = platforms.DefaultSpec()
433+
}
422434

423435
plugin.Register(&plugin.Registration{
424436
Type: t,
425437
ID: name,
426438
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
427439
ic.Meta.Exports["address"] = address
440+
ic.Meta.Platforms = append(ic.Meta.Platforms, p)
428441
conn, err := clients.getClient(address)
429442
if err != nil {
430443
return nil, err

0 commit comments

Comments
 (0)