@@ -171,16 +171,21 @@ func (v *Validator) CheckJSONSchema() (errs error) {
171171func (v * Validator ) CheckRoot () (errs error ) {
172172 logrus .Debugf ("check root" )
173173
174- if v .platform == "windows" && v .spec .Windows != nil && v .spec .Windows .HyperV != nil {
175- if v .spec .Root != nil {
174+ if v .platform == "windows" && v .spec .Windows != nil {
175+ if v .spec .Windows .HyperV != nil {
176+ if v .spec .Root != nil {
177+ errs = multierror .Append (errs ,
178+ specerror .NewError (specerror .RootOnHyperVNotSet , fmt .Errorf ("for Hyper-V containers, Root must not be set" ), rspec .Version ))
179+ }
180+ return
181+ } else if v .spec .Root == nil {
176182 errs = multierror .Append (errs ,
177- specerror .NewError (specerror .RootOnHyperVNotSet , fmt .Errorf ("for Hyper-V containers, Root must not be set " ), rspec .Version ))
183+ specerror .NewError (specerror .RootOnWindowsRequired , fmt .Errorf ("on Windows, for Windows Server Containers, this field is REQUIRED " ), rspec .Version ))
178184 return
179185 }
180- return
181- } else if v .spec .Root == nil {
186+ } else if v .platform != "windows" && v .spec .Root == nil {
182187 errs = multierror .Append (errs ,
183- specerror .NewError (specerror .RootOnNonHyperVRequired , fmt .Errorf ("for non-Hyper-V containers, Root must be set " ), rspec .Version ))
188+ specerror .NewError (specerror .RootOnNonWindowsRequired , fmt .Errorf ("on all other platforms, this field is REQUIRED " ), rspec .Version ))
184189 return
185190 }
186191
0 commit comments