in pkg/repo/validate.go [30:110]
func (r *Repo) Validate() (
warnings []string,
valErrMap map[string][]error,
err error,
) {
valErrMap = map[string][]error{}
if r.ProposalPath == "" {
return warnings, valErrMap, errors.New("proposal path cannot be empty")
}
kepDir := r.ProposalPath
files := []string{}
// Find all the KEPs
err = filepath.Walk(
kepDir,
func(path string, info os.FileInfo, err error) error {
logrus.Debugf("processing filename %s", info.Name())
if err != nil {
return err
}
if info.IsDir() {
if info.Name() == PRRApprovalPathStub {
return filepath.SkipDir
}
return nil
}
dir := filepath.Dir(path)
metadataFilename := ProposalMetadataFilename
metadataFilepath := filepath.Join(dir, metadataFilename)
if _, err := os.Stat(metadataFilepath); err == nil {
// There is KEP metadata file in this directory, only that one should be processed.
if info.Name() == metadataFilename {
files = append(files, metadataFilepath)
return filepath.SkipDir
}
}
return nil
},
)
// This indicates a problem walking the filepath, not a validation error.
if err != nil {
return warnings, valErrMap, errors.Wrap(err, "walking repository")
}
if len(files) == 0 {
return warnings, valErrMap, errors.New("must find more than zero KEPs")
}
prrDir := r.PRRApprovalPath
logrus.Infof("PRR directory: %s", prrDir)
for _, filename := range files {
if err := validateFile(r, prrDir, filename); err != nil {
fvErr := &fatalValidationError{}
if errors.As(err, fvErr) {
return warnings, valErrMap, err
}
valErrMap[filename] = append(valErrMap[filename], err)
}
}
if len(valErrMap) > 0 {
for filename, errs := range valErrMap {
logrus.Infof("the following PRR validation errors occurred in %s:", filename)
for _, e := range errs {
logrus.Infof("%v", e)
}
}
}
return warnings, valErrMap, nil
}