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

Method loadPattern

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

Source from the content-addressed store, hash-verified

66}
67
68func (o *PatternsEntity) loadPattern(source string) (pattern *Pattern, err error) {
69 if LooksLikePatternFilePath(source) {
70 // Resolve the file path using GetAbsolutePath
71 var absPath string
72 if absPath, err = util.GetAbsolutePath(source); err != nil {
73 return nil, fmt.Errorf(i18n.T("patterns_error_resolve_file_path"), err)
74 }
75
76 // Use the resolved absolute path to get the pattern
77 if pattern, err = o.getFromFile(absPath); err != nil {
78 return nil, fmt.Errorf(i18n.T("patterns_error_load_from_file"), absPath, err)
79 }
80 } else {
81 // Otherwise, get the pattern from the database
82 pattern, err = o.getFromDB(source)
83 }
84
85 return
86}
87
88func (o *PatternsEntity) ensureInput(pattern *Pattern) {
89 if !strings.Contains(pattern.Pattern, "{{input}}") {

Callers 2

GetApplyVariablesMethod · 0.95
GetWithoutVariablesMethod · 0.95

Calls 5

getFromFileMethod · 0.95
getFromDBMethod · 0.95
GetAbsolutePathFunction · 0.92
TFunction · 0.92
LooksLikePatternFilePathFunction · 0.85

Tested by

no test coverage detected