Skip to content

Commit 7be6eda

Browse files
committed
merge branch 'pr-1114'
LGTMs: @hqhq @cyphar Closes: opencontainers#1114
2 parents 3abefdf + 1cd0502 commit 7be6eda

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

spec.go

+13
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ func loadSpec(cPath string) (spec *specs.Spec, err error) {
240240
if err = json.NewDecoder(cf).Decode(&spec); err != nil {
241241
return nil, err
242242
}
243+
if err = validatePlatform(&spec.Platform); err != nil {
244+
return nil, err
245+
}
243246
return spec, validateProcessSpec(&spec.Process)
244247
}
245248

@@ -254,3 +257,13 @@ func createLibContainerRlimit(rlimit specs.Rlimit) (configs.Rlimit, error) {
254257
Soft: uint64(rlimit.Soft),
255258
}, nil
256259
}
260+
261+
func validatePlatform(platform *specs.Platform) error {
262+
if platform.OS != runtime.GOOS {
263+
return fmt.Errorf("target os %s mismatch with current os %s", platform.OS, runtime.GOOS)
264+
}
265+
if platform.Arch != runtime.GOARCH {
266+
return fmt.Errorf("target arch %s mismatch with current arch %s", platform.Arch, runtime.GOARCH)
267+
}
268+
return nil
269+
}

0 commit comments

Comments
 (0)