Skip to content

Commit c8a87d3

Browse files
committed
Add check for the input platform
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
1 parent 023cbd6 commit c8a87d3

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

validate/validate.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ func NewValidatorFromPath(bundlePath string, hostSpecific bool, platform string)
8888

8989
// CheckAll checks all parts of runtime bundle
9090
func (v *Validator) CheckAll() (msgs []string) {
91+
msgs = append(msgs, v.CheckPlatform()...)
9192
msgs = append(msgs, v.CheckRootfsPath()...)
9293
msgs = append(msgs, v.CheckMandatoryFields()...)
9394
msgs = append(msgs, v.CheckSemVer()...)
9495
msgs = append(msgs, v.CheckMounts()...)
9596
msgs = append(msgs, v.CheckProcess()...)
96-
msgs = append(msgs, v.CheckOS()...)
9797
msgs = append(msgs, v.CheckHooks()...)
9898
if v.spec.Linux != nil {
9999
msgs = append(msgs, v.CheckLinux()...)
@@ -396,9 +396,14 @@ func (v *Validator) CheckMounts() (msgs []string) {
396396
return
397397
}
398398

399-
// CheckOS checks v.platform
400-
func (v *Validator) CheckOS() (msgs []string) {
401-
logrus.Debugf("check os")
399+
// CheckPlatform checks v.platform
400+
func (v *Validator) CheckPlatform() (msgs []string) {
401+
logrus.Debugf("check platform")
402+
403+
if v.platform != "linux" && v.platform != "solaris" && v.platform != "windows" {
404+
msgs = append(msgs, fmt.Sprintf("platform %q is not supported", v.platform))
405+
return
406+
}
402407

403408
if v.platform != "linux" {
404409
if v.spec.Linux != nil {

0 commit comments

Comments
 (0)