Skip to content

Commit 6103192

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

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
@@ -103,6 +103,7 @@ func (v *Validator) CheckAll() (msgs []string) {
103103
msgs = append(msgs, v.CheckMounts()...)
104104
msgs = append(msgs, v.CheckPlatform()...)
105105
msgs = append(msgs, v.CheckProcess()...)
106+
msgs = append(msgs, v.CheckOS()...)
106107
msgs = append(msgs, v.CheckLinux()...)
107108
msgs = append(msgs, v.CheckHooks()...)
108109

@@ -343,6 +344,24 @@ func (v *Validator) CheckMounts() (msgs []string) {
343344
return
344345
}
345346

347+
func (v *Validator) CheckOS() (msgs []string) {
348+
logrus.Debugf("check os")
349+
350+
if v.spec.Platform.OS != "linux" {
351+
if v.spec.Linux != nil {
352+
msgs = append(msgs, fmt.Sprintf("'linux' MUST NOT be set when platform.os is %q", v.spec.Platform.OS))
353+
}
354+
}
355+
356+
if v.spec.Platform.OS != "solaris" {
357+
if v.spec.Solaris != nil {
358+
msgs = append(msgs, fmt.Sprintf("'solaris' MUST NOT be set when platform.os is %q", v.spec.Platform.OS))
359+
}
360+
}
361+
362+
return
363+
}
364+
346365
// CheckLinux checks v.spec.Linux
347366
func (v *Validator) CheckLinux() (msgs []string) {
348367
logrus.Debugf("check linux")

0 commit comments

Comments
 (0)