in code/go/internal/validator/semantic/validate_kibana_filter_present.go [29:54]
func ValidateKibanaFilterPresent(fsys fspath.FS) specerrors.ValidationErrors {
var errs specerrors.ValidationErrors
filePaths := path.Join("kibana", "dashboard", "*.json")
dashboardFiles, err := pkgpath.Files(fsys, filePaths)
if err != nil {
errs = append(errs, specerrors.NewStructuredErrorf("error finding Kibana dashboard files: %w", err))
return errs
}
for _, file := range dashboardFiles {
err = checkDashboardHasFilter(file)
if err != nil {
code := specerrors.CodeKibanaDashboardWithoutFilter
if errors.Is(err, errDashboardWithQueryAndNoFilter) {
code = specerrors.CodeKibanaDashboardWithQueryButNoFilter
}
errs = append(errs,
specerrors.NewStructuredError(
fmt.Errorf("file \"%s\" is invalid: expected filter in dashboard: %w", fsys.Path(file.Path()), err),
code),
)
}
}
return errs
}