Skip to content

Commit d1898f7

Browse files
author
zhouhao
committed
validate.go add checkos
Signed-off-by: zhouhao <[email protected]>
1 parent a652af1 commit d1898f7

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

validate/validate.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ func (v *Validator) CheckAll() (msgs []string) {
9898
msgs = append(msgs, v.CheckMounts()...)
9999
msgs = append(msgs, v.CheckPlatform()...)
100100
msgs = append(msgs, v.CheckProcess()...)
101+
msgs = append(msgs, v.CheckOS()...)
101102
msgs = append(msgs, v.CheckLinux()...)
102103
msgs = append(msgs, v.CheckHooks()...)
103104

@@ -335,6 +336,24 @@ func (v *Validator) CheckMounts() (msgs []string) {
335336
return
336337
}
337338

339+
func (v *Validator) CheckOS() (msgs []string) {
340+
logrus.Debugf("check os")
341+
342+
if v.spec.Platform.OS != "linux" {
343+
if v.spec.Linux != nil {
344+
msgs = append(msgs, fmt.Sprintf("When system is not linux, Linux field should be empty"))
345+
}
346+
}
347+
348+
if v.spec.Platform.OS != "solaris" {
349+
if v.spec.Solaris != nil {
350+
msgs = append(msgs, fmt.Sprintf("When system is not solaris, Solaris field should be empty"))
351+
}
352+
}
353+
354+
return
355+
}
356+
338357
//Linux only
339358
func (v *Validator) CheckLinux() (msgs []string) {
340359
logrus.Debugf("check linux")

0 commit comments

Comments
 (0)