|
@@ -79,6 +79,9 @@ func (l *tarexporter) Load(inTar io.ReadCloser, outStream io.Writer, quiet bool)
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
|
|
+ if err := checkCompatibleOS(img.OS); err != nil {
|
|
|
|
+ return err
|
|
|
|
+ }
|
|
var rootFS image.RootFS
|
|
var rootFS image.RootFS
|
|
rootFS = *img.RootFS
|
|
rootFS = *img.RootFS
|
|
rootFS.DiffIDs = nil
|
|
rootFS.DiffIDs = nil
|
|
@@ -292,11 +295,18 @@ func (l *tarexporter) legacyLoadImage(oldID, sourceDir string, loadedMap map[str
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
|
|
|
|
- var img struct{ Parent string }
|
|
|
|
|
|
+ var img struct {
|
|
|
|
+ OS string
|
|
|
|
+ Parent string
|
|
|
|
+ }
|
|
if err := json.Unmarshal(imageJSON, &img); err != nil {
|
|
if err := json.Unmarshal(imageJSON, &img); err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if err := checkCompatibleOS(img.OS); err != nil {
|
|
|
|
+ return err
|
|
|
|
+ }
|
|
|
|
+
|
|
var parentID image.ID
|
|
var parentID image.ID
|
|
if img.Parent != "" {
|
|
if img.Parent != "" {
|
|
for {
|
|
for {
|
|
@@ -402,3 +412,20 @@ func checkValidParent(img, parent *image.Image) bool {
|
|
}
|
|
}
|
|
return true
|
|
return true
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+func checkCompatibleOS(os string) error {
|
|
|
|
+ // TODO @jhowardmsft LCOW - revisit for simultaneous platforms
|
|
|
|
+ platform := runtime.GOOS
|
|
|
|
+ if system.LCOWSupported() {
|
|
|
|
+ platform = "linux"
|
|
|
|
+ }
|
|
|
|
+ // always compatible if the OS matches; also match an empty OS
|
|
|
|
+ if os == platform || os == "" {
|
|
|
|
+ return nil
|
|
|
|
+ }
|
|
|
|
+ // for compatibility, only fail if the image or runtime OS is Windows
|
|
|
|
+ if os == "windows" || platform == "windows" {
|
|
|
|
+ return fmt.Errorf("cannot load %s image on %s", os, platform)
|
|
|
|
+ }
|
|
|
|
+ return nil
|
|
|
|
+}
|