Store workflow definitions as table rows and drop YAML
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package workflow
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"g.fc.run/ai/byre/internal/api"
|
||||
)
|
||||
|
||||
func Parse(data []byte) (api.WorkflowDefinition, error) {
|
||||
def := api.WorkflowDefinition{}
|
||||
dec := json.NewDecoder(bytes.NewReader(data))
|
||||
dec.DisallowUnknownFields()
|
||||
err := dec.Decode(&def)
|
||||
if err != nil {
|
||||
return api.WorkflowDefinition{}, fmt.Errorf("%w: %v", ErrInvalid, err)
|
||||
}
|
||||
return def, Validate(def)
|
||||
}
|
||||
Reference in New Issue
Block a user