diff --git a/spec.go b/spec.go index 7834aa2a..617d99ea 100644 --- a/spec.go +++ b/spec.go @@ -240,6 +240,9 @@ func loadSpec(cPath string) (spec *specs.Spec, err error) { if err = json.NewDecoder(cf).Decode(&spec); err != nil { return nil, err } + if err = validatePlatform(&spec.Platform); err != nil { + return nil, err + } return spec, validateProcessSpec(&spec.Process) } @@ -254,3 +257,13 @@ func createLibContainerRlimit(rlimit specs.Rlimit) (configs.Rlimit, error) { Soft: uint64(rlimit.Soft), }, nil } + +func validatePlatform(platform *specs.Platform) error { + if platform.OS != runtime.GOOS { + return fmt.Errorf("target os %s mismatch with current os %s", platform.OS, runtime.GOOS) + } + if platform.Arch != runtime.GOARCH { + return fmt.Errorf("target arch %s mismatch with current arch %s", platform.Arch, runtime.GOARCH) + } + return nil +}