@@ -29,20 +29,36 @@ import (
2929 "github.com/containerd/containerd/metadata"
3030 "github.com/containerd/containerd/mount"
3131 "github.com/containerd/containerd/namespaces"
32+ "github.com/containerd/containerd/platforms"
3233 "github.com/containerd/containerd/plugin"
3334 "github.com/containerd/containerd/runtime"
35+ ocispec "github.com/opencontainers/image-spec/specs-go/v1"
3436 bolt "go.etcd.io/bbolt"
3537)
3638
39+ // Config for the v2 runtime
40+ type Config struct {
41+ // Supported platforms
42+ Platforms []string `toml:"platforms"`
43+ }
44+
3745func init () {
3846 plugin .Register (& plugin.Registration {
3947 Type : plugin .RuntimePluginV2 ,
4048 ID : "task" ,
4149 Requires : []plugin.Type {
4250 plugin .MetadataPlugin ,
4351 },
52+ Config : & Config {
53+ Platforms : defaultPlatforms (),
54+ },
4455 InitFn : func (ic * plugin.InitContext ) (interface {}, error ) {
45- ic .Meta .Platforms = supportedPlatforms ()
56+ supportedPlatforms , err := parsePlatforms (ic .Config .(* Config ).Platforms )
57+ if err != nil {
58+ return nil , err
59+ }
60+
61+ ic .Meta .Platforms = supportedPlatforms
4662 if err := os .MkdirAll (ic .Root , 0711 ); err != nil {
4763 return nil , err
4864 }
@@ -262,3 +278,15 @@ func (m *TaskManager) cleanupWorkDirs(ctx context.Context) error {
262278 }
263279 return nil
264280}
281+
282+ func parsePlatforms (platformStr []string ) ([]ocispec.Platform , error ) {
283+ p := make ([]ocispec.Platform , len (platformStr ))
284+ for i , v := range platformStr {
285+ parsed , err := platforms .Parse (v )
286+ if err != nil {
287+ return nil , err
288+ }
289+ p [i ] = parsed
290+ }
291+ return p , nil
292+ }
0 commit comments