MCPcopy Create free account
hub / github.com/danielmiessler/Fabric / loadPattern

Method loadPattern

internal/plugins/db/fsdb/patterns.go:58–82  ·  view source on GitHub ↗
(source string)

Source from the content-addressed store, hash-verified

56}
57
58func (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
84func (o *PatternsEntity) ensureInput(pattern *Pattern) {
85 if !strings.Contains(pattern.Pattern, "{{input}}") {

Callers 2

GetApplyVariablesMethod · 0.95
GetWithoutVariablesMethod · 0.95

Calls 4

getFromFileMethod · 0.95
getFromDBMethod · 0.95
GetAbsolutePathFunction · 0.92
TFunction · 0.92

Tested by

no test coverage detected