Skip to content

Commit e5011e1

Browse files
author
Ma Shimiao
authored
Merge pull request #433 from q384566678/nil-check
validate: Add non-empty checks
2 parents 8178fda + 18c5678 commit e5011e1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

validate/validate.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,7 @@ func (v *Validator) CheckAll() (msgs []string) {
102102
msgs = append(msgs, v.CheckMounts()...)
103103
msgs = append(msgs, v.CheckProcess()...)
104104
msgs = append(msgs, v.CheckHooks()...)
105-
if v.spec.Linux != nil {
106-
msgs = append(msgs, v.CheckLinux()...)
107-
}
105+
msgs = append(msgs, v.CheckLinux()...)
108106

109107
return
110108
}
@@ -222,6 +220,10 @@ func checkEventHooks(hookType string, hooks []rspec.Hook, hostSpecific bool) (ms
222220
func (v *Validator) CheckProcess() (msgs []string) {
223221
logrus.Debugf("check process")
224222

223+
if v.spec.Process == nil {
224+
return
225+
}
226+
225227
process := v.spec.Process
226228
if !filepath.IsAbs(process.Cwd) {
227229
msgs = append(msgs, fmt.Sprintf("cwd %q is not an absolute path", process.Cwd))
@@ -436,6 +438,10 @@ func (v *Validator) CheckPlatform() (msgs []string) {
436438
func (v *Validator) CheckLinux() (msgs []string) {
437439
logrus.Debugf("check linux")
438440

441+
if v.spec.Linux == nil {
442+
return
443+
}
444+
439445
var typeList = map[rspec.LinuxNamespaceType]struct {
440446
num int
441447
newExist bool

0 commit comments

Comments
 (0)