You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by lz...@apache.org on 2017/06/02 02:15:56 UTC
[incubator-openwhisk-wskdeploy] branch master updated: Fixing zip
action creation (#275)
This is an automated email from the ASF dual-hosted git repository.
lz1982 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 ed72774 Fixing zip action creation (#275)
ed72774 is described below
commit ed72774af8fbd0e4bcc0c34d1a698ca5fad3ff02
Author: Priti Desai <pd...@us.ibm.com>
AuthorDate: Thu Jun 1 19:15:54 2017 -0700
Fixing zip action creation (#275)
* Fixing zip action creation
Base64 encoding zipfile content so thataction payload is sent in expected format via HTTP request.
Also, added integration test for a simple zip action.
Fixes #273
* Update manifest_parser.go
Fixing formatting issue
* Update zipaction_test.go
Fixing manifest file extension
* Update manifest_parser.go
one more formatting off at the import statement
* Update zipaction_test.go
---
parsers/manifest_parser.go | 16 +++++++++-----
tests/src/integration/manifest.yaml | 6 +++++
tests/src/integration/zipaction/src/index.js | 5 +++++
tests/src/integration/zipaction/zipaction_test.go | 27 +++++++++++++++++++++++
4 files changed, 48 insertions(+), 6 deletions(-)
diff --git a/parsers/manifest_parser.go b/parsers/manifest_parser.go
index 895d0bc..ad7489e 100644
--- a/parsers/manifest_parser.go
+++ b/parsers/manifest_parser.go
@@ -25,6 +25,7 @@ import (
"path"
"strings"
+ "encoding/base64"
"encoding/json"
"github.com/apache/incubator-openwhisk-client-go/whisk"
@@ -243,12 +244,6 @@ func (dm *YAMLParser) ComposeActions(mani *ManifestYAML, manipath string) (ar []
// To do: support docker and main entry as did by go cli?
wskaction.Exec, err = utils.GetExec(zipName, action.Runtime, false, "")
} else {
- action.Location = filePath
- dat, err := utils.Read(filePath)
- utils.Check(err)
- code := string(dat)
- wskaction.Exec.Code = &code
-
ext := path.Ext(filePath)
kind := "nodejs:default"
@@ -262,6 +257,15 @@ func (dm *YAMLParser) ComposeActions(mani *ManifestYAML, manipath string) (ar []
}
wskaction.Exec.Kind = kind
+
+ action.Location = filePath
+ dat, err := utils.Read(filePath)
+ utils.Check(err)
+ code := string(dat)
+ if ext == ".zip" || ext == ".jar" {
+ code = base64.StdEncoding.EncodeToString([]byte(dat))
+ }
+ wskaction.Exec.Code = &code
}
}
diff --git a/tests/src/integration/manifest.yaml b/tests/src/integration/manifest.yaml
new file mode 100644
index 0000000..f03bfa1
--- /dev/null
+++ b/tests/src/integration/manifest.yaml
@@ -0,0 +1,6 @@
+package:
+ name: helloworld
+ actions:
+ helloworld:
+ location: src/helloworld.zip
+ kind: nodejs:6
diff --git a/tests/src/integration/zipaction/src/index.js b/tests/src/integration/zipaction/src/index.js
new file mode 100644
index 0000000..ad8a3ca
--- /dev/null
+++ b/tests/src/integration/zipaction/src/index.js
@@ -0,0 +1,5 @@
+function helloworld(params) {
+ return { payload: 'Hello World!' };
+}
+
+exports.main = helloworld;
diff --git a/tests/src/integration/zipaction/zipaction_test.go b/tests/src/integration/zipaction/zipaction_test.go
new file mode 100644
index 0000000..bf2fb23
--- /dev/null
+++ b/tests/src/integration/zipaction/zipaction_test.go
@@ -0,0 +1,27 @@
+// +build integration
+
+package tests
+
+import (
+ "github.com/apache/incubator-openwhisk-wskdeploy/tests/src/integration/common"
+ "github.com/stretchr/testify/assert"
+ "os"
+ "testing"
+)
+
+
+var wskprops = common.GetWskprops()
+
+func TestZipAction(t *testing.T) {
+ os.Setenv("__OW_API_HOST", wskprops.APIHost)
+ wskdeploy := common.NewWskdeploy()
+ _, err := wskdeploy.Deploy(manifestPath, deploymentPath)
+ assert.Equal(t, nil, err, "Failed to deploy based on the manifest and deployment files.")
+ _, err = wskdeploy.Undeploy(manifestPath, deploymentPath)
+ assert.Equal(t, nil, err, "Failed to undeploy based on the manifest and deployment files.")
+}
+
+var (
+ manifestPath = os.Getenv("GOPATH") + "/src/github.com/apache/incubator-openwhisk-wskdeploy/tests/src/integration/zipaction/manifest.yaml"
+ deploymentPath = ""
+)
--
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>'].