@@ -597,8 +597,8 @@ func (v *Validator) CheckLinux() (errs error) {
597597
598598 for index := 0 ; index < len (v .spec .Linux .Namespaces ); index ++ {
599599 ns := v .spec .Linux .Namespaces [index ]
600- if ! v .namespaceValid (ns ) {
601- errs = multierror .Append (errs , fmt . Errorf ( "namespace %v is invalid" , ns ) )
600+ if err := v .namespaceValid (ns ); err != nil {
601+ errs = multierror .Append (errs , err )
602602 }
603603
604604 tmpItem := nsTypeList [ns .Type ]
@@ -936,7 +936,7 @@ func (v *Validator) rlimitValid(rlimit rspec.POSIXRlimit) (errs error) {
936936 return
937937}
938938
939- func (v * Validator ) namespaceValid (ns rspec.LinuxNamespace ) bool {
939+ func (v * Validator ) namespaceValid (ns rspec.LinuxNamespace ) error {
940940 switch ns .Type {
941941 case rspec .PIDNamespace :
942942 case rspec .NetworkNamespace :
@@ -946,14 +946,14 @@ func (v *Validator) namespaceValid(ns rspec.LinuxNamespace) bool {
946946 case rspec .UserNamespace :
947947 case rspec .CgroupNamespace :
948948 default :
949- return false
949+ return specerror . NewError ( specerror . NSTypeValueError , fmt . Errorf ( "namespace type %s may not be valid" , ns . Type ), rspec . Version )
950950 }
951951
952952 if ns .Path != "" && ! osFilepath .IsAbs (v .platform , ns .Path ) {
953- return false
953+ return specerror . NewError ( specerror . NSPathAbs , fmt . Errorf ( "path %v of namespace %v is not absolute path" , ns . Path , ns ), rspec . Version )
954954 }
955955
956- return true
956+ return nil
957957}
958958
959959func deviceValid (d rspec.LinuxDevice ) bool {
0 commit comments