Skip to content

Commit

Permalink
validate: With --host-specific, compare config platform vs. runtime
Browse files Browse the repository at this point in the history
This is a bit aggressive.  For example, maybe a Linux kernel was
compiled with CONFIG_64BIT, CONFIG_X86, and CONFIG_X86_X32.  Your
ocitools build may be 386 and validating an amd64 image (or vice
versa) and both would run fine.  I'm not sure x32 is supported by Go,
but you could have and x32 container if somebody submits it to the OCI
specs as an extention arch.  So I'd rather have an arch mismatch be a
warning than a fatal error.

But in most cases, you'll want the arch to match (e.g. no arm configs
if ocitools is amd64), so I don't want to ignore the missmatch
completely.  In the absence of warning-support, an overly strict check
seems safer than an overly lax check, because the caller can always
read the error messages and decide if they care ;).

Signed-off-by: W. Trevor King <wking@tremily.us>
  • Loading branch information
wking committed Nov 14, 2016
1 parent 081f39d commit e3df0d5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"path/filepath"
"reflect"
"runtime"
"strings"
"unicode"
"unicode/utf8"
Expand Down Expand Up @@ -164,6 +165,16 @@ func (v *Validator) CheckPlatform() (msgs []string) {
}
msgs = append(msgs, fmt.Sprintf("Operation system %q of the bundle is not supported yet.", platform.OS))

if hostCheck {
if platform.OS != runtime.GOOS {
msgs = append(msgs, fmt.Sprintf("platform.os is %s, not %s", platform.OS, runtime.GOOS))
}
if platform.Arch != runtime.GOARCH {
// warning, not an error, since kernels can support multiple architectures
msgs = append(msgs, fmt.Sprintf("platform.arch is %s, not %s", platform.Arch, runtime.GOARCH))
}
}

return
}

Expand Down

0 comments on commit e3df0d5

Please sign in to comment.