From b5bcf5c74be0084aea108ecaff8979bf1839261c Mon Sep 17 00:00:00 2001 From: Mathieu Debove Date: Fri, 22 Feb 2019 16:56:26 +0100 Subject: [PATCH 1/3] Update imports in flogo.json to the new Flogo import syntax (cf. https://github.com/project-flogo/cli/pull/32) --- examples/engine/flogo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/engine/flogo.json b/examples/engine/flogo.json index 99546239..8d2b23e8 100644 --- a/examples/engine/flogo.json +++ b/examples/engine/flogo.json @@ -5,8 +5,8 @@ "description": "My flogo application description", "appModel": "1.0.0", "imports": [ - "github.com/project-flogo/contrib/activity/log", - "github.com/project-flogo/contrib/trigger/rest", + "github.com/project-flogo/contrib:/activity/log", + "github.com/project-flogo/contrib:/trigger/rest", "github.com/project-flogo/flow" ], "triggers": [ From f5d0c008be4e5c0146b62b7ae72adcc73845cb0a Mon Sep 17 00:00:00 2001 From: Mathieu Debove Date: Fri, 22 Feb 2019 17:31:21 +0100 Subject: [PATCH 2/3] Register imports with correct (Go) import path --- app/app.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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)) From 5f2c8b8f5bc95628929e20a28a65979fbbab8594 Mon Sep 17 00:00:00 2001 From: Mathieu Debove Date: Thu, 28 Feb 2019 13:34:00 +0100 Subject: [PATCH 3/3] Put alternative flogo.json syntax in a separate alternative directory --- examples/alt/engine/flogo.json | 71 ++++++++++++++++++++++++++++++++++ examples/engine/flogo.json | 4 +- 2 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 examples/alt/engine/flogo.json 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": [] + } + } + ] +} diff --git a/examples/engine/flogo.json b/examples/engine/flogo.json index 8d2b23e8..99546239 100644 --- a/examples/engine/flogo.json +++ b/examples/engine/flogo.json @@ -5,8 +5,8 @@ "description": "My flogo application description", "appModel": "1.0.0", "imports": [ - "github.com/project-flogo/contrib:/activity/log", - "github.com/project-flogo/contrib:/trigger/rest", + "github.com/project-flogo/contrib/activity/log", + "github.com/project-flogo/contrib/trigger/rest", "github.com/project-flogo/flow" ], "triggers": [