@@ -53,6 +53,15 @@ func findConfig(w walker, d *descriptor) (*config, error) {
5353 if err := json .Unmarshal (buf , & c ); err != nil {
5454 return err
5555 }
56+ // check if the rootfs type is 'layers'
57+ if c .RootFS .Type != "layers" {
58+ return fmt .Errorf ("%q is an unknown rootfs type, MUST be 'layers'" , c .RootFS .Type )
59+ }
60+
61+ //check os and architecture
62+ if err := checkPlatform (c ); err != nil {
63+ return err
64+ }
5665 return errEOW
5766 }); err {
5867 case nil :
@@ -64,19 +73,28 @@ func findConfig(w walker, d *descriptor) (*config, error) {
6473 }
6574}
6675
67- func (c * config ) validate (w walk ) error {
68-
69- // check if the rootfs type is 'layers'
70- if c .RootFS .Type != "layers" {
71- return errors .New ("%q is an unknown rootfs type, MUST be 'layers'" , c .RootFS .Type )
76+ func checkPlatform (c config ) error {
77+ validCombins := map [string ][]string {
78+ "darwin" : {"386" , "amd64" , "arm" , "arm64" },
79+ "dragonfly" : {"amd64" },
80+ "freebsd" : {"386" , "amd64" , "arm" },
81+ "linux" : {"386" , "amd64" , "arm" , "arm64" , "ppc64" , "ppc64le" , "mips64" , "mips64le" },
82+ "netbsd" : {"386" , "amd64" , "arm" },
83+ "openbsd" : {"386" , "amd64" , "arm" },
84+ "plan9" : {"386" , "amd64" },
85+ "solaris" : {"amd64" },
86+ "windows" : {"386" , "amd64" }}
87+ for os , archs := range validCombins {
88+ if os == c .OS {
89+ for _ , arch := range archs {
90+ if arch == c .Architecture {
91+ return nil
92+ }
93+ }
94+ return fmt .Errorf ("Combination of %q and %q is invalid." , c .OS , c .Architecture )
95+ }
7296 }
73-
74- for _ , d = range c .RootFs .DiffIDs {
75- h := sha256 .New ()
76- DiffIds := "sha256" + hex .EncodeToString (h .Sum (nil ))
77-
78- if DiffIds != d {
79- return errors .New ("DiffIDs mismatch" )
97+ return fmt .Errorf ("Operation system %q of the bundle is not supported yet." , c .OS )
8098}
8199
82100func (c * config ) runtimeSpec (rootfs string ) (* specs.Spec , error ) {
0 commit comments