You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by pd...@apache.org on 2018/04/17 18:50:34 UTC
[incubator-openwhisk-wskdeploy] branch master updated: Export
blackbox (#866)
This is an automated email from the ASF dual-hosted git repository.
pdesai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-wskdeploy.git
The following commit(s) were added to refs/heads/master by this push:
new d981b36 Export blackbox (#866)
d981b36 is described below
commit d981b364a65f3f30aaf0869a997326255acf7f00
Author: Pavel Kravchenko <kp...@il.ibm.com>
AuthorDate: Tue Apr 17 21:50:31 2018 +0300
Export blackbox (#866)
* Resolves #730
- Provides support to export projects with dependencies
- Optimizes rule export (leveraging added rule annotations)
- Adds MANAGED annotation to dependencies in OW package bindings
* bug fix
* Added integration tests for export
* bug fix
* bug fix
* added undeployments to export test case
* minor bug fixes
* change export attribute ProjectPath to ProjectName
* support blackbox action export
add blackbox action definition to exported manifest
* bug fix
added support to export blackbox action with code
* Bug fix, set runtime to empty
in case of blackbox docker type
* resolving gofmt issue
---
cmd/export.go | 21 ++++++++++-----------
parsers/yamlparser.go | 13 ++++++++++++-
2 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/cmd/export.go b/cmd/export.go
index 3585da5..5112947 100644
--- a/cmd/export.go
+++ b/cmd/export.go
@@ -29,7 +29,6 @@ import (
"github.com/apache/incubator-openwhisk-wskdeploy/deployers"
"github.com/apache/incubator-openwhisk-wskdeploy/parsers"
"github.com/apache/incubator-openwhisk-wskdeploy/utils"
- "github.com/apache/incubator-openwhisk-wskdeploy/wskderrors"
"github.com/apache/incubator-openwhisk-wskdeploy/wski18n"
"github.com/spf13/cobra"
)
@@ -83,16 +82,18 @@ func ExportAction(actionName string, packageName string, maniyaml *parsers.YAML,
// store function file under action package name subdirectory in the specified manifest folder
functionDir := filepath.Join(manifestDir, packageName)
- os.MkdirAll(functionDir, os.ModePerm)
- // save code file at the full path
+ // save the code in file
filename, err := saveCode(*wskAction, functionDir)
if err != nil {
return err
}
- // store function in manifest under path relative to manifest root
- parsedAction.Function = filepath.Join(packageName, filename)
+ if filename != "" {
+ // store function in manifest if action has code section
+ parsedAction.Function = filepath.Join(packageName, filename)
+ }
+
pkg.Actions[wskAction.Name] = parsedAction
}
@@ -307,7 +308,6 @@ func ExportCmdImp(cmd *cobra.Command, args []string) error {
const (
JAVA_EXT = ".jar"
ZIP_EXT = ".zip"
- BLACKBOX = "blackbox"
JAVA = "java"
)
@@ -330,13 +330,10 @@ func saveCode(action whisk.Action, directory string) (string, error) {
exec = *action.Exec
runtime = strings.Split(exec.Kind, ":")[0]
- if strings.ToLower(runtime) == BLACKBOX {
- return "", wskderrors.NewInvalidRuntimeError(wski18n.T(wski18n.ID_ERR_CANT_SAVE_DOCKER_RUNTIME),
- directory, action.Name, BLACKBOX, utils.ListOfSupportedRuntimes(utils.SupportedRunTimes))
- }
-
if exec.Code != nil {
code = *exec.Code
+ } else {
+ return "", nil
}
var filename = ""
@@ -349,6 +346,8 @@ func saveCode(action whisk.Action, directory string) (string, error) {
filename = action.Name + "." + utils.FileRuntimeExtensionsMap[action.Exec.Kind]
}
+ os.MkdirAll(directory, os.ModePerm)
+
path := filepath.Join(directory, filename)
if err := utils.WriteFile(path, code); err != nil {
diff --git a/parsers/yamlparser.go b/parsers/yamlparser.go
index a4a8b79..551733a 100644
--- a/parsers/yamlparser.go
+++ b/parsers/yamlparser.go
@@ -18,6 +18,8 @@
package parsers
import (
+ "strings"
+
"github.com/apache/incubator-openwhisk-client-go/whisk"
"github.com/apache/incubator-openwhisk-wskdeploy/utils"
"github.com/apache/incubator-openwhisk-wskdeploy/wskenv"
@@ -39,6 +41,7 @@ const (
YAML_KEY_SEQUENCE = "sequence"
YAML_KEY_TRIGGER = "trigger"
YAML_KEY_SOURCE = "source"
+ YAML_KEY_BLACKBOX = "blackbox"
)
// YAML schema key values
@@ -400,7 +403,6 @@ func (yaml *YAML) ComposeParsersAction(wskact whisk.Action) *Action {
action.Name = wskact.Name
action.Namespace = wskact.Namespace
action.Version = wskact.Version
- action.Runtime = wskact.Exec.Kind
action.Inputs = make(map[string]Parameter)
for _, keyval := range wskact.Parameters {
@@ -410,6 +412,15 @@ func (yaml *YAML) ComposeParsersAction(wskact whisk.Action) *Action {
}
action.Annotations = filterAnnotations(wskact.Annotations)
+
+ runtime := strings.Split(wskact.Exec.Kind, ":")[0]
+ if strings.ToLower(runtime) == YAML_KEY_BLACKBOX {
+ // storing blackbox image reference without saving the code as its impossible
+ action.Docker = wskact.Exec.Image
+ } else {
+ action.Runtime = wskact.Exec.Kind
+ }
+
return action
}
--
To stop receiving notification emails like this one, please contact
pdesai@apache.org.