@@ -560,8 +560,8 @@ func (v *Validator) CheckLinux() (errs error) {
560560
561561 for index := 0 ; index < len (v .spec .Linux .Namespaces ); index ++ {
562562 ns := v .spec .Linux .Namespaces [index ]
563- if ! v .namespaceValid (ns ) {
564- errs = multierror .Append (errs , fmt . Errorf ( "namespace %v is invalid" , ns ) )
563+ if err := v .namespaceValid (ns ); err != nil {
564+ errs = multierror .Append (errs , err )
565565 }
566566
567567 tmpItem := nsTypeList [ns .Type ]
@@ -885,7 +885,7 @@ func (v *Validator) rlimitValid(rlimit rspec.POSIXRlimit) (errs error) {
885885 return
886886}
887887
888- func (v * Validator ) namespaceValid (ns rspec.LinuxNamespace ) bool {
888+ func (v * Validator ) namespaceValid (ns rspec.LinuxNamespace ) error {
889889 switch ns .Type {
890890 case rspec .PIDNamespace :
891891 case rspec .NetworkNamespace :
@@ -895,14 +895,14 @@ func (v *Validator) namespaceValid(ns rspec.LinuxNamespace) bool {
895895 case rspec .UserNamespace :
896896 case rspec .CgroupNamespace :
897897 default :
898- return false
898+ return specerror . NewError ( specerror . NamespacesType , fmt . Errorf ( "namespace type %s may not be valid" , ns . Type ), v . spec . Version )
899899 }
900900
901901 if ns .Path != "" && ! osFilepath .IsAbs (v .platform , ns .Path ) {
902- return false
902+ return specerror . NewError ( specerror . NamespacesPath , fmt . Errorf ( "path %v of namespace %v is not absolute path" , ns . Path , ns ), v . spec . Version )
903903 }
904904
905- return true
905+ return nil
906906}
907907
908908func deviceValid (d rspec.LinuxDevice ) bool {
0 commit comments