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

Function LoadWorkflow

internal/cli/workflow.go:47–63  ·  view source on GitHub ↗

LoadWorkflow parses a workflow definition from a YAML or JSON file (JSON is valid YAML). It does not validate the contents – call Validate before running.

(path string)

Source from the content-addressed store, hash-verified

45// LoadWorkflow parses a workflow definition from a YAML or JSON file (JSON is
46// valid YAML). It does not validate the contents – call Validate before running.
47func LoadWorkflow(path string) (wf *Workflow, err error) {
48 absPath, err := util.GetAbsolutePath(path)
49 if err != nil {
50 return nil, fmt.Errorf("invalid workflow path: %w", err)
51 }
52
53 data, err := os.ReadFile(absPath)
54 if err != nil {
55 return nil, fmt.Errorf("error reading workflow file: %w", err)
56 }
57
58 wf = &Workflow{}
59 if err = yaml.Unmarshal(data, wf); err != nil {
60 return nil, fmt.Errorf("error parsing workflow file: %w", err)
61 }
62 return
63}
64
65// Validate performs all pre-flight checks on a workflow:
66// - at least one step is defined

Callers 5

handleWorkflowProcessingFunction · 0.85
TestLoadWorkflowYAMLFunction · 0.85
TestLoadWorkflowJSONFunction · 0.85
TestLoadWorkflowBadPathFunction · 0.85

Calls 1

GetAbsolutePathFunction · 0.92

Tested by 4

TestLoadWorkflowYAMLFunction · 0.68
TestLoadWorkflowJSONFunction · 0.68
TestLoadWorkflowBadPathFunction · 0.68