@@ -57,16 +57,19 @@ var (
5757 }
5858)
5959
60+ // Validator represents a validator for runtime bundle
6061type Validator struct {
6162 spec * rspec.Spec
6263 bundlePath string
6364 HostSpecific bool
6465}
6566
67+ // NewValidator creates a Validator
6668func NewValidator (spec * rspec.Spec , bundlePath string , hostSpecific bool ) Validator {
6769 return Validator {spec : spec , bundlePath : bundlePath , HostSpecific : hostSpecific }
6870}
6971
72+ // NewValidatorFromPath creates a Validator with specified bundle path
7073func NewValidatorFromPath (bundlePath string , hostSpecific bool ) (Validator , error ) {
7174 if bundlePath == "" {
7275 return Validator {}, fmt .Errorf ("Bundle path shouldn't be empty" )
@@ -92,6 +95,7 @@ func NewValidatorFromPath(bundlePath string, hostSpecific bool) (Validator, erro
9295 return NewValidator (& spec , bundlePath , hostSpecific ), nil
9396}
9497
98+ // CheckAll checks all parts of runtime bundle
9599func (v * Validator ) CheckAll () (msgs []string ) {
96100 msgs = append (msgs , v .CheckRootfsPath ()... )
97101 msgs = append (msgs , v .CheckMandatoryFields ()... )
@@ -105,6 +109,7 @@ func (v *Validator) CheckAll() (msgs []string) {
105109 return
106110}
107111
112+ // CheckRootfsPath checks status of v.spec.Root.Path
108113func (v * Validator ) CheckRootfsPath () (msgs []string ) {
109114 logrus .Debugf ("check rootfs path" )
110115
@@ -124,6 +129,8 @@ func (v *Validator) CheckRootfsPath() (msgs []string) {
124129 return
125130
126131}
132+
133+ // CheckSemVer checks v.sepc.Version
127134func (v * Validator ) CheckSemVer () (msgs []string ) {
128135 logrus .Debugf ("check semver" )
129136
@@ -139,6 +146,7 @@ func (v *Validator) CheckSemVer() (msgs []string) {
139146 return
140147}
141148
149+ // CheckSemVer checks v.spec.Platform
142150func (v * Validator ) CheckPlatform () (msgs []string ) {
143151 logrus .Debugf ("check platform" )
144152
@@ -168,6 +176,7 @@ func (v *Validator) CheckPlatform() (msgs []string) {
168176 return
169177}
170178
179+ // CheckHooks check v.spec.Hooks
171180func (v * Validator ) CheckHooks () (msgs []string ) {
172181 logrus .Debugf ("check hooks" )
173182
@@ -204,6 +213,7 @@ func checkEventHooks(hookType string, hooks []rspec.Hook, hostSpecific bool) (ms
204213 return
205214}
206215
216+ // CheckProcess checks v.spec.process
207217func (v * Validator ) CheckProcess () (msgs []string ) {
208218 logrus .Debugf ("check process" )
209219
@@ -282,6 +292,7 @@ func supportedMountTypes(OS string, hostSpecific bool) (map[string]bool, error)
282292 return nil , nil
283293}
284294
295+ // CheckMounts checks v.spec.Mounts
285296func (v * Validator ) CheckMounts () (msgs []string ) {
286297 logrus .Debugf ("check mounts" )
287298
@@ -384,6 +395,7 @@ func (v *Validator) CheckLinux() (msgs []string) {
384395 return
385396}
386397
398+ // CheckLinuxResources checks v.spec.Linux.Resources
387399func (v * Validator ) CheckLinuxResources () (msgs []string ) {
388400 logrus .Debugf ("check linux resources" )
389401
@@ -400,6 +412,7 @@ func (v *Validator) CheckLinuxResources() (msgs []string) {
400412 return
401413}
402414
415+ // CheckSeccomp checkc v.spec.Linux.Seccomp
403416func (v * Validator ) CheckSeccomp () (msgs []string ) {
404417 logrus .Debugf ("check linux seccomp" )
405418
@@ -438,6 +451,7 @@ func (v *Validator) CheckSeccomp() (msgs []string) {
438451 return
439452}
440453
454+ // CapValid checks whether a capability is valid
441455func CapValid (c string , hostSpecific bool ) error {
442456 isValid := false
443457
@@ -460,6 +474,7 @@ func CapValid(c string, hostSpecific bool) error {
460474 return nil
461475}
462476
477+ // LastCap return last cap of system
463478func LastCap () capability.Cap {
464479 last := capability .CAP_LAST_CAP
465480 // hack for RHEL6 which has no /proc/sys/kernel/cap_last_cap
@@ -643,6 +658,7 @@ func checkMandatory(obj interface{}) (msgs []string) {
643658 return
644659}
645660
661+ // CheckMandatoryFields checks mandatory field of container's config file
646662func (v * Validator ) CheckMandatoryFields () []string {
647663 logrus .Debugf ("check mandatory fields" )
648664
0 commit comments