Skip to content

Commit 3767027

Browse files
author
Ma Shimiao
authored
Merge pull request #374 from q384566678/linux-devices
validate: add the validation of Resources.devices
2 parents 3db644c + f6e16e8 commit 3767027

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

validate/validate.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,23 @@ func (v *Validator) CheckLinuxResources() (msgs []string) {
687687
}
688688
}
689689
}
690+
for index := 0; index < len(r.Devices); index++ {
691+
switch r.Devices[index].Type {
692+
case "a", "b", "c":
693+
default:
694+
msgs = append(msgs, fmt.Sprintf("type of devices %s is invalid", r.Devices[index].Type))
695+
}
696+
697+
access := []byte(r.Devices[index].Access)
698+
for i := 0; i < len(access); i++ {
699+
switch access[i] {
700+
case 'r', 'w', 'm':
701+
default:
702+
msgs = append(msgs, fmt.Sprintf("access %s is invalid", r.Devices[index].Access))
703+
return
704+
}
705+
}
706+
}
690707

691708
return
692709
}

0 commit comments

Comments
 (0)