@@ -64,19 +64,41 @@ func findConfig(w walker, d *descriptor) (*config, error) {
6464 }
6565}
6666
67- func (c * config ) validate ( w walk ) error {
67+ func validateConfig (c config ) error {
6868
6969 // check if the rootfs type is 'layers'
7070 if c .RootFS .Type != "layers" {
71- return errors . New ("%q is an unknown rootfs type, MUST be 'layers'" , c .RootFS .Type )
71+ return fmt . Errorf ("%q is an unknown rootfs type, MUST be 'layers'" , c .RootFS .Type )
7272 }
7373
74- for _ , d = range c .RootFs .DiffIDs {
75- h := sha256 .New ()
76- DiffIds := "sha256" + hex .EncodeToString (h .Sum (nil ))
74+ //check os and architecture
75+ if err := checkPlatform (c ); err != nil {
76+ return err
77+ }
78+ }
7779
78- if DiffIds != d {
79- return errors .New ("DiffIDs mismatch" )
80+ func checkPlatform (c config ) error {
81+ validCombins := map [string ][]string {
82+ "darwin" : {"386" , "amd64" , "arm" , "arm64" },
83+ "dragonfly" : {"amd64" },
84+ "freebsd" : {"386" , "amd64" , "arm" },
85+ "linux" : {"386" , "amd64" , "arm" , "arm64" , "ppc64" , "ppc64le" , "mips64" , "mips64le" },
86+ "netbsd" : {"386" , "amd64" , "arm" },
87+ "openbsd" : {"386" , "amd64" , "arm" },
88+ "plan9" : {"386" , "amd64" },
89+ "solaris" : {"amd64" },
90+ "windows" : {"386" , "amd64" }}
91+ for os , archs := range validCombins {
92+ if os == c .OS {
93+ for _ , arch := range archs {
94+ if arch == c .Architecture {
95+ return nil
96+ }
97+ }
98+ return fmt .Errorf ("Combination of %q and %q is invalid." , c .OS , c .Architecture )
99+ }
100+ }
101+ return fmt .Errorf ("Operation system %q of the bundle is not supported yet." , c .OS )
80102}
81103
82104func (c * config ) runtimeSpec (rootfs string ) (* specs.Spec , error ) {
0 commit comments