You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/04/17 18:50:33 UTC
[GitHub] pritidesai closed pull request #866: Export blackbox
pritidesai closed pull request #866: Export blackbox
URL: https://github.com/apache/incubator-openwhisk-wskdeploy/pull/866
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/cmd/export.go b/cmd/export.go
index 3585da51..51129473 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 a4a8b792..551733a6 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
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services