(source string)
| 56 | } |
| 57 | |
| 58 | func (o *PatternsEntity) loadPattern(source string) (pattern *Pattern, err error) { |
| 59 | // Determine if this is a file path |
| 60 | isFilePath := strings.HasPrefix(source, "\\") || |
| 61 | strings.HasPrefix(source, "/") || |
| 62 | strings.HasPrefix(source, "~") || |
| 63 | strings.HasPrefix(source, ".") |
| 64 | |
| 65 | if isFilePath { |
| 66 | // Resolve the file path using GetAbsolutePath |
| 67 | var absPath string |
| 68 | if absPath, err = util.GetAbsolutePath(source); err != nil { |
| 69 | return nil, fmt.Errorf(i18n.T("patterns_error_resolve_file_path"), err) |
| 70 | } |
| 71 | |
| 72 | // Use the resolved absolute path to get the pattern |
| 73 | if pattern, err = o.getFromFile(absPath); err != nil { |
| 74 | return nil, fmt.Errorf(i18n.T("patterns_error_load_from_file"), absPath, err) |
| 75 | } |
| 76 | } else { |
| 77 | // Otherwise, get the pattern from the database |
| 78 | pattern, err = o.getFromDB(source) |
| 79 | } |
| 80 | |
| 81 | return |
| 82 | } |
| 83 | |
| 84 | func (o *PatternsEntity) ensureInput(pattern *Pattern) { |
| 85 | if !strings.Contains(pattern.Pattern, "{{input}}") { |
no test coverage detected