diff --git a/app/app.go b/app/app.go index 583eb369..e7178279 100644 --- a/app/app.go +++ b/app/app.go @@ -3,6 +3,7 @@ package app import ( "fmt" "path" + "regexp" "runtime/debug" "strings" @@ -18,12 +19,15 @@ import ( type Option func(*App) error +var flogoImportPattern = regexp.MustCompile(`^(([^ ]*)[ ]+)?([^@:]*)@?([^:]*)?:?(.*)?$`) // extract import path even if there is an alias and/or a version + func New(config *Config, runner action.Runner, options ...Option) (*App, error) { app := &App{stopOnError: true, name: config.Name, version: config.Version} for _, anImport := range config.Imports { - registerImport(anImport) + matches := flogoImportPattern.FindStringSubmatch(anImport) + registerImport(matches[1] + matches[3] + matches[5]) // alias + module path + relative import path } properties := make(map[string]interface{}, len(config.Properties)) diff --git a/examples/alt/engine/flogo.json b/examples/alt/engine/flogo.json new file mode 100644 index 00000000..e8830750 --- /dev/null +++ b/examples/alt/engine/flogo.json @@ -0,0 +1,71 @@ +{ + "name": "_APP_NAME_", + "type": "flogo:app", + "version": "0.0.1", + "description": "My flogo application description", + "appModel": "1.0.0", + "imports": [ + "github.com/project-flogo/contrib@latest:/activity/log", + "github.com/project-flogo/contrib@latest:/trigger/rest", + "github.com/project-flogo/flow@latest" + ], + "triggers": [ + { + "id": "my_rest_trigger", + "type": "rest", + "settings": { + "port": "8888" + }, + "handlers": [ + { + "settings": { + "method": "GET", + "path": "/test/:val" + }, + "actions": [ + { + "type": "flow", + "settings": { + "flowURI": "res://flow:simple_flow" + }, + "input": { + "in": "=$.pathParams.val" + } + } + ] + } + ] + } + ], + "resources": [ + { + "id": "flow:simple_flow", + "data": { + "name": "simple_flow", + "metadata": { + "input": [ + { "name": "in", "type": "string", "value": "test" } + ], + "output": [ + { "name": "out", "type": "string" } + ] + }, + "tasks": [ + { + "id": "log", + "name": "Log Message", + "activity": { + "type": "log", + "input": { + "message": "=$flow.in", + "flowInfo": "false", + "addToFlow": "false" + } + } + } + ], + "links": [] + } + } + ] +}