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 3092f1f Introducing include and exclude in zip action (#991)
3092f1f is described below
commit 3092f1f2d7d591cbdc953876dca0cfaccb75e493
Author: Priti Desai <[email protected]>
AuthorDate: Tue Oct 16 14:33:53 2018 -0700
Introducing include and exclude in zip action (#991)
* adding include in yaml parser
* wip include
* wip
* wip - dir level include
* wip - dir level include
* wip - dir level include
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* include
* deleting debugging statement
* cleaning up
* adding unit test
* adding unit test
* wip
* refactoring
* wip
* wip
* wip
* wip
* adding more unit tests
* fixing unit test
* fixing unit test
* fixing unit test
* adding exclude
* fixing unit test
* adding warning
* adding exclude
* refactoring exclude code
* adding exclude test case
* exclude integration test
* cleaning up
* adding wski18 strings
---
parsers/manifest_parser.go | 2 +-
parsers/yamlparser.go | 4 +-
tests/dat/manifest_validate_inputs.yaml | 13 +
.../zipactionwithexclude/actions/common/utils.js | 9 +
.../zipactionwithexclude/actions/greeting/index.js | 21 ++
.../actions/greeting/package.json | 6 +
.../zipactionwithexclude/actions/index.js | 21 ++
.../actions/libs/lib1/utils.js | 9 +
.../actions/libs/lib2/utils.js | 9 +
.../actions/libs/lib3/utils.js | 9 +
.../zipactionwithexclude/actions/package.json | 6 +
.../integration/zipactionwithexclude/manifest.yml | 18 +
.../zipactionwithexclude_test.go | 40 +++
.../zipactionwithinclude/actions/common/utils.js | 9 +
.../actions/greeting1/index.js | 21 ++
.../actions/greeting1/package.json | 6 +
.../actions/greeting10/index.js | 23 ++
.../actions/greeting10/package.json | 6 +
.../actions/greeting2/index.js | 23 ++
.../actions/greeting2/package.json | 6 +
.../actions/greeting3/index.js | 22 ++
.../actions/greeting3/package.json | 6 +
.../actions/greeting4/index.js | 21 ++
.../actions/greeting4/package.json | 6 +
.../actions/greeting5/index.js | 21 ++
.../actions/greeting5/package.json | 6 +
.../actions/greeting6/index.js | 21 ++
.../actions/greeting6/package.json | 6 +
.../actions/greeting7/index.js | 23 ++
.../actions/greeting7/package.json | 6 +
.../actions/greeting8/index.js | 23 ++
.../actions/greeting8/package.json | 6 +
.../actions/greeting9/index.js | 23 ++
.../actions/greeting9/package.json | 6 +
.../actions/libs/lib1/utils.js | 9 +
.../actions/libs/lib2/utils.js | 9 +
.../actions/libs/lib3/utils.js | 9 +
.../zipactionwithinclude/deployment.yml | 28 ++
.../integration/zipactionwithinclude/manifest.yml | 63 ++++
.../zipactionwithinclude_test.go | 40 +++
utils/file.go | 152 +++++++++
utils/file_test.go | 85 +++++
utils/misc.go | 59 ----
utils/misc_test.go | 2 +-
utils/zip.go | 363 +++++++++++++++++++++
wski18n/i18n_ids.go | 18 +-
wski18n/i18n_resources.go | 56 ++--
wski18n/resources/en_US.all.json | 28 ++
48 files changed, 1283 insertions(+), 95 deletions(-)
diff --git a/parsers/manifest_parser.go b/parsers/manifest_parser.go
index ff2124b..619cf91 100644
--- a/parsers/manifest_parser.go
+++ b/parsers/manifest_parser.go
@@ -649,7 +649,7 @@ func (dm *YAMLParser) readActionFunction(manifestFilePath
string, manifestFileNa
if utils.IsDirectory(actionFilePath) {
zipFileName = actionFilePath + "." + runtimes.ZIP_FILE_EXTENSION
- err := utils.NewZipWritter(actionFilePath, zipFileName).Zip()
+ err := utils.NewZipWritter(actionFilePath, zipFileName,
action.Include, action.Exclude, filepath.Dir(manifestFilePath)).Zip()
if err != nil {
return actionFilePath, nil, err
}
diff --git a/parsers/yamlparser.go b/parsers/yamlparser.go
index 5f12370..4776e6e 100644
--- a/parsers/yamlparser.go
+++ b/parsers/yamlparser.go
@@ -114,8 +114,8 @@ type Action struct {
Inputs map[string]Parameter `yaml:"inputs"`
Outputs map[string]Parameter `yaml:"outputs"`
Annotations map[string]interface{} `yaml:"annotations,omitempty"`
- // TODO() this is propoagated from package to every action within that
package
- //Parameters map[string]interface{} `yaml:parameters`
+ Include [][]string `yaml:"include,omitempty"`
+ Exclude []string `yaml:"exclude,omitempty"`
}
type Limits struct {
diff --git a/tests/dat/manifest_validate_inputs.yaml
b/tests/dat/manifest_validate_inputs.yaml
new file mode 100644
index 0000000..4c721c8
--- /dev/null
+++ b/tests/dat/manifest_validate_inputs.yaml
@@ -0,0 +1,13 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
contributor
+# license agreements; and to You under the Apache License, Version 2.0.
+
+packages:
+ helloworld:
+ actions:
+ helloNodejs:
+ function: actions/
+ runtime: nodejs:6
+ include:
+ - ["actions/hello.js"]
+ - ["actions/hello.js", "actions/hello.js"]
+ - ["actions/hello.js", "actions/hello.js", "actions/hello.js"]
diff --git a/tests/src/integration/zipactionwithexclude/actions/common/utils.js
b/tests/src/integration/zipactionwithexclude/actions/common/utils.js
new file mode 100644
index 0000000..9abcf16
--- /dev/null
+++ b/tests/src/integration/zipactionwithexclude/actions/common/utils.js
@@ -0,0 +1,9 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
contributor
+// license agreements; and to You under the Apache License, Version 2.0.
+
+const hello = "Hello Dear";
+
+module.exports = {
+ hello: hello
+};
+
diff --git
a/tests/src/integration/zipactionwithexclude/actions/greeting/index.js
b/tests/src/integration/zipactionwithexclude/actions/greeting/index.js
new file mode 100644
index 0000000..e61d71a
--- /dev/null
+++ b/tests/src/integration/zipactionwithexclude/actions/greeting/index.js
@@ -0,0 +1,21 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
contributor
+// license agreements; and to You under the Apache License, Version 2.0.
+
+/**
+ * Return a simple greeting message for someone.
+ *
+ * @param name A person's name.
+ * @param place Where the person is from.
+ */
+
+
+var common = require('./common/utils.js')
+
+function main(params) {
+ var name = params.name || params.payload || 'stranger';
+ var place = params.place || 'somewhere';
+ var hello = common.hello || 'Hello';
+ return {payload: hello + ', ' + name + ' from ' + place + '!'};
+}
+exports.main = main;
+
diff --git
a/tests/src/integration/zipactionwithexclude/actions/greeting/package.json
b/tests/src/integration/zipactionwithexclude/actions/greeting/package.json
new file mode 100644
index 0000000..80cb6cd
--- /dev/null
+++ b/tests/src/integration/zipactionwithexclude/actions/greeting/package.json
@@ -0,0 +1,6 @@
+{
+ "name": "my-action",
+ "main": "index.js",
+ "dependencies" : {
+ }
+}
diff --git a/tests/src/integration/zipactionwithexclude/actions/index.js
b/tests/src/integration/zipactionwithexclude/actions/index.js
new file mode 100644
index 0000000..e61d71a
--- /dev/null
+++ b/tests/src/integration/zipactionwithexclude/actions/index.js
@@ -0,0 +1,21 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
contributor
+// license agreements; and to You under the Apache License, Version 2.0.
+
+/**
+ * Return a simple greeting message for someone.
+ *
+ * @param name A person's name.
+ * @param place Where the person is from.
+ */
+
+
+var common = require('./common/utils.js')
+
+function main(params) {
+ var name = params.name || params.payload || 'stranger';
+ var place = params.place || 'somewhere';
+ var hello = common.hello || 'Hello';
+ return {payload: hello + ', ' + name + ' from ' + place + '!'};
+}
+exports.main = main;
+
diff --git
a/tests/src/integration/zipactionwithexclude/actions/libs/lib1/utils.js
b/tests/src/integration/zipactionwithexclude/actions/libs/lib1/utils.js
new file mode 100644
index 0000000..9abcf16
--- /dev/null
+++ b/tests/src/integration/zipactionwithexclude/actions/libs/lib1/utils.js
@@ -0,0 +1,9 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
contributor
+// license agreements; and to You under the Apache License, Version 2.0.
+
+const hello = "Hello Dear";
+
+module.exports = {
+ hello: hello
+};
+
diff --git
a/tests/src/integration/zipactionwithexclude/actions/libs/lib2/utils.js
b/tests/src/integration/zipactionwithexclude/actions/libs/lib2/utils.js
new file mode 100644
index 0000000..9abcf16
--- /dev/null
+++ b/tests/src/integration/zipactionwithexclude/actions/libs/lib2/utils.js
@@ -0,0 +1,9 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
contributor
+// license agreements; and to You under the Apache License, Version 2.0.
+
+const hello = "Hello Dear";
+
+module.exports = {
+ hello: hello
+};
+
diff --git
a/tests/src/integration/zipactionwithexclude/actions/libs/lib3/utils.js
b/tests/src/integration/zipactionwithexclude/actions/libs/lib3/utils.js
new file mode 100644
index 0000000..9abcf16
--- /dev/null
+++ b/tests/src/integration/zipactionwithexclude/actions/libs/lib3/utils.js
@@ -0,0 +1,9 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
contributor
+// license agreements; and to You under the Apache License, Version 2.0.
+
+const hello = "Hello Dear";
+
+module.exports = {
+ hello: hello
+};
+
diff --git a/tests/src/integration/zipactionwithexclude/actions/package.json
b/tests/src/integration/zipactionwithexclude/actions/package.json
new file mode 100644
index 0000000..80cb6cd
--- /dev/null
+++ b/tests/src/integration/zipactionwithexclude/actions/package.json
@@ -0,0 +1,6 @@
+{
+ "name": "my-action",
+ "main": "index.js",
+ "dependencies" : {
+ }
+}
diff --git a/tests/src/integration/zipactionwithexclude/manifest.yml
b/tests/src/integration/zipactionwithexclude/manifest.yml
new file mode 100644
index 0000000..c79b83c
--- /dev/null
+++ b/tests/src/integration/zipactionwithexclude/manifest.yml
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
contributor
+# license agreements; and to You under the Apache License, Version 2.0.
+
+packages:
+ zipactionwithexclude:
+ version: 1.0
+ license: Apache-2.0
+ actions:
+ greeting1:
+ function: actions
+ runtime: nodejs:6
+ exclude:
+ - actions/*
+ include:
+ - ["actions/common/utils.js", "common/utils.js"]
+ - ["actions/index.js", "index.js"]
+ - ["actions/package.json", "package.json"]
+
diff --git
a/tests/src/integration/zipactionwithexclude/zipactionwithexclude_test.go
b/tests/src/integration/zipactionwithexclude/zipactionwithexclude_test.go
new file mode 100644
index 0000000..027285b
--- /dev/null
+++ b/tests/src/integration/zipactionwithexclude/zipactionwithexclude_test.go
@@ -0,0 +1,40 @@
+// +build integration
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests
+
+import (
+
"github.com/apache/incubator-openwhisk-wskdeploy/tests/src/integration/common"
+ "github.com/stretchr/testify/assert"
+ "os"
+ "testing"
+)
+
+func TestZipActionWithExclude(t *testing.T) {
+ 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/zipactionwithexclude/manifest.yml"
+ deploymentPath = ""
+)
diff --git a/tests/src/integration/zipactionwithinclude/actions/common/utils.js
b/tests/src/integration/zipactionwithinclude/actions/common/utils.js
new file mode 100644
index 0000000..9abcf16
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/actions/common/utils.js
@@ -0,0 +1,9 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
contributor
+// license agreements; and to You under the Apache License, Version 2.0.
+
+const hello = "Hello Dear";
+
+module.exports = {
+ hello: hello
+};
+
diff --git
a/tests/src/integration/zipactionwithinclude/actions/greeting1/index.js
b/tests/src/integration/zipactionwithinclude/actions/greeting1/index.js
new file mode 100644
index 0000000..af3597b
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/actions/greeting1/index.js
@@ -0,0 +1,21 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
contributor
+// license agreements; and to You under the Apache License, Version 2.0.
+
+/**
+ * Return a simple greeting message for someone.
+ *
+ * @param name A person's name.
+ * @param place Where the person is from.
+ */
+
+
+var common = require('./actions/common/utils.js')
+
+function main(params) {
+ var name = params.name || params.payload || 'stranger';
+ var place = params.place || 'somewhere';
+ var hello = common.hello || 'Hello';
+ return {payload: hello + ', ' + name + ' from ' + place + '!'};
+}
+exports.main = main;
+
diff --git
a/tests/src/integration/zipactionwithinclude/actions/greeting1/package.json
b/tests/src/integration/zipactionwithinclude/actions/greeting1/package.json
new file mode 100644
index 0000000..80cb6cd
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/actions/greeting1/package.json
@@ -0,0 +1,6 @@
+{
+ "name": "my-action",
+ "main": "index.js",
+ "dependencies" : {
+ }
+}
diff --git
a/tests/src/integration/zipactionwithinclude/actions/greeting10/index.js
b/tests/src/integration/zipactionwithinclude/actions/greeting10/index.js
new file mode 100644
index 0000000..85e3ed7
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/actions/greeting10/index.js
@@ -0,0 +1,23 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
contributor
+// license agreements; and to You under the Apache License, Version 2.0.
+
+/**
+ * Return a simple greeting message for someone.
+ *
+ * @param name A person's name.
+ * @param place Where the person is from.
+ */
+
+
+var lib1 = require('./actions/libs/lib1/utils.js')
+var lib2 = require('./actions/libs/lib2/utils.js')
+var lib3 = require('./actions/libs/lib3/utils.js')
+
+function main(params) {
+ var name = params.name || params.payload || 'stranger';
+ var place = params.place || 'somewhere';
+ var hello = lib1.hello || lib2.hello || lib3.hello || 'Hello';
+ return {payload: hello + ', ' + name + ' from ' + place + '!'};
+}
+exports.main = main;
+
diff --git
a/tests/src/integration/zipactionwithinclude/actions/greeting10/package.json
b/tests/src/integration/zipactionwithinclude/actions/greeting10/package.json
new file mode 100644
index 0000000..80cb6cd
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/actions/greeting10/package.json
@@ -0,0 +1,6 @@
+{
+ "name": "my-action",
+ "main": "index.js",
+ "dependencies" : {
+ }
+}
diff --git
a/tests/src/integration/zipactionwithinclude/actions/greeting2/index.js
b/tests/src/integration/zipactionwithinclude/actions/greeting2/index.js
new file mode 100644
index 0000000..3836539
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/actions/greeting2/index.js
@@ -0,0 +1,23 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
contributor
+// license agreements; and to You under the Apache License, Version 2.0.
+
+/**
+ * Return a simple greeting message for someone.
+ *
+ * @param name A person's name.
+ * @param place Where the person is from.
+ */
+
+
+var common1 = require('./common/utils.js')
+var common2 = require('./common/common1/utils.js')
+var common3 = require('./common/common1/copyUtils.js')
+
+function main(params) {
+ var name = params.name || params.payload || 'stranger';
+ var place = params.place || 'somewhere';
+ var hello = common1.hello || common2.hello || common3.hello || 'Hello';
+ return {payload: hello + ', ' + name + ' from ' + place + '!'};
+}
+exports.main = main;
+
diff --git
a/tests/src/integration/zipactionwithinclude/actions/greeting2/package.json
b/tests/src/integration/zipactionwithinclude/actions/greeting2/package.json
new file mode 100644
index 0000000..80cb6cd
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/actions/greeting2/package.json
@@ -0,0 +1,6 @@
+{
+ "name": "my-action",
+ "main": "index.js",
+ "dependencies" : {
+ }
+}
diff --git
a/tests/src/integration/zipactionwithinclude/actions/greeting3/index.js
b/tests/src/integration/zipactionwithinclude/actions/greeting3/index.js
new file mode 100644
index 0000000..ab9b3df
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/actions/greeting3/index.js
@@ -0,0 +1,22 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
contributor
+// license agreements; and to You under the Apache License, Version 2.0.
+
+/**
+ * Return a simple greeting message for someone.
+ *
+ * @param name A person's name.
+ * @param place Where the person is from.
+ */
+
+
+var common1 = require('./common/utils.js')
+var common2 = require('./common/common1/utils.js')
+
+function main(params) {
+ var name = params.name || params.payload || 'stranger';
+ var place = params.place || 'somewhere';
+ var hello = common1.hello || common2.hello || 'Hello';
+ return {payload: hello + ', ' + name + ' from ' + place + '!'};
+}
+exports.main = main;
+
diff --git
a/tests/src/integration/zipactionwithinclude/actions/greeting3/package.json
b/tests/src/integration/zipactionwithinclude/actions/greeting3/package.json
new file mode 100644
index 0000000..80cb6cd
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/actions/greeting3/package.json
@@ -0,0 +1,6 @@
+{
+ "name": "my-action",
+ "main": "index.js",
+ "dependencies" : {
+ }
+}
diff --git
a/tests/src/integration/zipactionwithinclude/actions/greeting4/index.js
b/tests/src/integration/zipactionwithinclude/actions/greeting4/index.js
new file mode 100644
index 0000000..e61d71a
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/actions/greeting4/index.js
@@ -0,0 +1,21 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
contributor
+// license agreements; and to You under the Apache License, Version 2.0.
+
+/**
+ * Return a simple greeting message for someone.
+ *
+ * @param name A person's name.
+ * @param place Where the person is from.
+ */
+
+
+var common = require('./common/utils.js')
+
+function main(params) {
+ var name = params.name || params.payload || 'stranger';
+ var place = params.place || 'somewhere';
+ var hello = common.hello || 'Hello';
+ return {payload: hello + ', ' + name + ' from ' + place + '!'};
+}
+exports.main = main;
+
diff --git
a/tests/src/integration/zipactionwithinclude/actions/greeting4/package.json
b/tests/src/integration/zipactionwithinclude/actions/greeting4/package.json
new file mode 100644
index 0000000..80cb6cd
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/actions/greeting4/package.json
@@ -0,0 +1,6 @@
+{
+ "name": "my-action",
+ "main": "index.js",
+ "dependencies" : {
+ }
+}
diff --git
a/tests/src/integration/zipactionwithinclude/actions/greeting5/index.js
b/tests/src/integration/zipactionwithinclude/actions/greeting5/index.js
new file mode 100644
index 0000000..e61d71a
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/actions/greeting5/index.js
@@ -0,0 +1,21 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
contributor
+// license agreements; and to You under the Apache License, Version 2.0.
+
+/**
+ * Return a simple greeting message for someone.
+ *
+ * @param name A person's name.
+ * @param place Where the person is from.
+ */
+
+
+var common = require('./common/utils.js')
+
+function main(params) {
+ var name = params.name || params.payload || 'stranger';
+ var place = params.place || 'somewhere';
+ var hello = common.hello || 'Hello';
+ return {payload: hello + ', ' + name + ' from ' + place + '!'};
+}
+exports.main = main;
+
diff --git
a/tests/src/integration/zipactionwithinclude/actions/greeting5/package.json
b/tests/src/integration/zipactionwithinclude/actions/greeting5/package.json
new file mode 100644
index 0000000..80cb6cd
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/actions/greeting5/package.json
@@ -0,0 +1,6 @@
+{
+ "name": "my-action",
+ "main": "index.js",
+ "dependencies" : {
+ }
+}
diff --git
a/tests/src/integration/zipactionwithinclude/actions/greeting6/index.js
b/tests/src/integration/zipactionwithinclude/actions/greeting6/index.js
new file mode 100644
index 0000000..af3597b
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/actions/greeting6/index.js
@@ -0,0 +1,21 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
contributor
+// license agreements; and to You under the Apache License, Version 2.0.
+
+/**
+ * Return a simple greeting message for someone.
+ *
+ * @param name A person's name.
+ * @param place Where the person is from.
+ */
+
+
+var common = require('./actions/common/utils.js')
+
+function main(params) {
+ var name = params.name || params.payload || 'stranger';
+ var place = params.place || 'somewhere';
+ var hello = common.hello || 'Hello';
+ return {payload: hello + ', ' + name + ' from ' + place + '!'};
+}
+exports.main = main;
+
diff --git
a/tests/src/integration/zipactionwithinclude/actions/greeting6/package.json
b/tests/src/integration/zipactionwithinclude/actions/greeting6/package.json
new file mode 100644
index 0000000..80cb6cd
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/actions/greeting6/package.json
@@ -0,0 +1,6 @@
+{
+ "name": "my-action",
+ "main": "index.js",
+ "dependencies" : {
+ }
+}
diff --git
a/tests/src/integration/zipactionwithinclude/actions/greeting7/index.js
b/tests/src/integration/zipactionwithinclude/actions/greeting7/index.js
new file mode 100644
index 0000000..3461c69
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/actions/greeting7/index.js
@@ -0,0 +1,23 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
contributor
+// license agreements; and to You under the Apache License, Version 2.0.
+
+/**
+ * Return a simple greeting message for someone.
+ *
+ * @param name A person's name.
+ * @param place Where the person is from.
+ */
+
+
+var lib1 = require('./libs/lib1/utils.js')
+var lib2 = require('./libs/lib2/utils.js')
+var lib3 = require('./libs/lib3/utils.js')
+
+function main(params) {
+ var name = params.name || params.payload || 'stranger';
+ var place = params.place || 'somewhere';
+ var hello = lib1.hello || lib2.hello || lib3.hello || 'Hello';
+ return {payload: hello + ', ' + name + ' from ' + place + '!'};
+}
+exports.main = main;
+
diff --git
a/tests/src/integration/zipactionwithinclude/actions/greeting7/package.json
b/tests/src/integration/zipactionwithinclude/actions/greeting7/package.json
new file mode 100644
index 0000000..80cb6cd
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/actions/greeting7/package.json
@@ -0,0 +1,6 @@
+{
+ "name": "my-action",
+ "main": "index.js",
+ "dependencies" : {
+ }
+}
diff --git
a/tests/src/integration/zipactionwithinclude/actions/greeting8/index.js
b/tests/src/integration/zipactionwithinclude/actions/greeting8/index.js
new file mode 100644
index 0000000..3461c69
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/actions/greeting8/index.js
@@ -0,0 +1,23 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
contributor
+// license agreements; and to You under the Apache License, Version 2.0.
+
+/**
+ * Return a simple greeting message for someone.
+ *
+ * @param name A person's name.
+ * @param place Where the person is from.
+ */
+
+
+var lib1 = require('./libs/lib1/utils.js')
+var lib2 = require('./libs/lib2/utils.js')
+var lib3 = require('./libs/lib3/utils.js')
+
+function main(params) {
+ var name = params.name || params.payload || 'stranger';
+ var place = params.place || 'somewhere';
+ var hello = lib1.hello || lib2.hello || lib3.hello || 'Hello';
+ return {payload: hello + ', ' + name + ' from ' + place + '!'};
+}
+exports.main = main;
+
diff --git
a/tests/src/integration/zipactionwithinclude/actions/greeting8/package.json
b/tests/src/integration/zipactionwithinclude/actions/greeting8/package.json
new file mode 100644
index 0000000..80cb6cd
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/actions/greeting8/package.json
@@ -0,0 +1,6 @@
+{
+ "name": "my-action",
+ "main": "index.js",
+ "dependencies" : {
+ }
+}
diff --git
a/tests/src/integration/zipactionwithinclude/actions/greeting9/index.js
b/tests/src/integration/zipactionwithinclude/actions/greeting9/index.js
new file mode 100644
index 0000000..85e3ed7
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/actions/greeting9/index.js
@@ -0,0 +1,23 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
contributor
+// license agreements; and to You under the Apache License, Version 2.0.
+
+/**
+ * Return a simple greeting message for someone.
+ *
+ * @param name A person's name.
+ * @param place Where the person is from.
+ */
+
+
+var lib1 = require('./actions/libs/lib1/utils.js')
+var lib2 = require('./actions/libs/lib2/utils.js')
+var lib3 = require('./actions/libs/lib3/utils.js')
+
+function main(params) {
+ var name = params.name || params.payload || 'stranger';
+ var place = params.place || 'somewhere';
+ var hello = lib1.hello || lib2.hello || lib3.hello || 'Hello';
+ return {payload: hello + ', ' + name + ' from ' + place + '!'};
+}
+exports.main = main;
+
diff --git
a/tests/src/integration/zipactionwithinclude/actions/greeting9/package.json
b/tests/src/integration/zipactionwithinclude/actions/greeting9/package.json
new file mode 100644
index 0000000..80cb6cd
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/actions/greeting9/package.json
@@ -0,0 +1,6 @@
+{
+ "name": "my-action",
+ "main": "index.js",
+ "dependencies" : {
+ }
+}
diff --git
a/tests/src/integration/zipactionwithinclude/actions/libs/lib1/utils.js
b/tests/src/integration/zipactionwithinclude/actions/libs/lib1/utils.js
new file mode 100644
index 0000000..308416b
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/actions/libs/lib1/utils.js
@@ -0,0 +1,9 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
contributor
+// license agreements; and to You under the Apache License, Version 2.0.
+
+const hello = "Good Morning";
+
+module.exports = {
+ hello: hello
+};
+
diff --git
a/tests/src/integration/zipactionwithinclude/actions/libs/lib2/utils.js
b/tests/src/integration/zipactionwithinclude/actions/libs/lib2/utils.js
new file mode 100644
index 0000000..031e63e
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/actions/libs/lib2/utils.js
@@ -0,0 +1,9 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
contributor
+// license agreements; and to You under the Apache License, Version 2.0.
+
+const hello = "Good Evening";
+
+module.exports = {
+ hello: hello
+};
+
diff --git
a/tests/src/integration/zipactionwithinclude/actions/libs/lib3/utils.js
b/tests/src/integration/zipactionwithinclude/actions/libs/lib3/utils.js
new file mode 100644
index 0000000..1fd7cf3
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/actions/libs/lib3/utils.js
@@ -0,0 +1,9 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
contributor
+// license agreements; and to You under the Apache License, Version 2.0.
+
+const hello = "Hello Afternoon";
+
+module.exports = {
+ hello: hello
+};
+
diff --git a/tests/src/integration/zipactionwithinclude/deployment.yml
b/tests/src/integration/zipactionwithinclude/deployment.yml
new file mode 100644
index 0000000..dcd26c8
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/deployment.yml
@@ -0,0 +1,28 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
contributor
+# license agreements; and to You under the Apache License, Version 2.0.
+
+project:
+ packages:
+ zipactionwithinclude:
+ actions:
+ greeting1:
+ inputs:
+ name: Amy
+ place: Vermont
+ greeting2:
+ inputs:
+ name: Bernie
+ place: Paris
+ greeting3:
+ inputs:
+ name: Cindy
+ place: New York
+ greeting4:
+ inputs:
+ name: Dough
+ place: Spain
+ greeting5:
+ inputs:
+ name: Evya
+ place: Japan
+
diff --git a/tests/src/integration/zipactionwithinclude/manifest.yml
b/tests/src/integration/zipactionwithinclude/manifest.yml
new file mode 100644
index 0000000..6f0c298
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/manifest.yml
@@ -0,0 +1,63 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
contributor
+# license agreements; and to You under the Apache License, Version 2.0.
+
+packages:
+ zipactionwithinclude:
+ version: 1.0
+ license: Apache-2.0
+ actions:
+ greeting1:
+ function: actions/greeting1
+ runtime: nodejs:6
+ include:
+ - []
+ - ["actions/common/utils.js"]
+ greeting2:
+ function: actions/greeting2
+ runtime: nodejs:6
+ include:
+ - ["actions/common/utils.js", "common/utils.js"]
+ - ["actions/common/utils.js", "common/common1/utils.js"]
+ - ["actions/common/utils.js",
"common/common1/copyUtils.js"]
+ greeting3:
+ function: actions/greeting3
+ runtime: nodejs:6
+ include:
+ - ["actions/common/", "common/"]
+ - ["actions/common/", "common/common1/"]
+ greeting4:
+ function: actions/greeting4
+ runtime: nodejs:6
+ include:
+ - ["actions/common/*.js", "common/"]
+ greeting5:
+ function: actions/greeting5
+ runtime: nodejs:6
+ include:
+ - ["actions/common/utils.js", "./common/"]
+ greeting6:
+ function: actions/greeting6
+ runtime: nodejs:6
+ include:
+ - ["actions/common/*.js"]
+ greeting7:
+ function: actions/greeting7
+ runtime: nodejs:6
+ include:
+ - ["actions/libs/*", "libs/"]
+ greeting8:
+ function: actions/greeting8
+ runtime: nodejs:6
+ include:
+ - ["actions/libs/*/utils.js", "libs/"]
+ greeting9:
+ function: actions/greeting9
+ runtime: nodejs:6
+ include:
+ - ["actions/*/*/utils.js"]
+ greeting10:
+ function: actions/greeting10
+ runtime: nodejs:6
+ include:
+ - ["actions/*/*/utils.js", "actions/"]
+
diff --git
a/tests/src/integration/zipactionwithinclude/zipactionwithinclude_test.go
b/tests/src/integration/zipactionwithinclude/zipactionwithinclude_test.go
new file mode 100644
index 0000000..4032f53
--- /dev/null
+++ b/tests/src/integration/zipactionwithinclude/zipactionwithinclude_test.go
@@ -0,0 +1,40 @@
+// +build integration
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests
+
+import (
+
"github.com/apache/incubator-openwhisk-wskdeploy/tests/src/integration/common"
+ "github.com/stretchr/testify/assert"
+ "os"
+ "testing"
+)
+
+func TestZipActionWithInclude(t *testing.T) {
+ 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/zipactionwithinclude/manifest.yml"
+ deploymentPath = os.Getenv("GOPATH") +
"/src/github.com/apache/incubator-openwhisk-wskdeploy/tests/src/integration/zipactionwithinclude/deployment.yml"
+)
diff --git a/utils/file.go b/utils/file.go
new file mode 100644
index 0000000..4155358
--- /dev/null
+++ b/utils/file.go
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package utils
+
+import (
+ "io"
+ "io/ioutil"
+ "os"
+ "path"
+ "path/filepath"
+
+ "github.com/apache/incubator-openwhisk-wskdeploy/wskprint"
+)
+
+// check if the path represents file path or dir path
+func isFilePath(path string) bool {
+ // when split returns dir and file, splitting path on the final "/"
+ // check if file is not empty to classify that path as a file path
+ _, file := filepath.Split(path)
+ if len(file) == 0 {
+ return false
+ }
+ return true
+}
+
+// check if the given path exists as a file
+func isFile(path string) (bool, error) {
+ var err error
+ var info os.FileInfo
+ // run stat on the file and if the it returns no error,
+ // read the fileInfo to check if its a file or not
+ if info, err = os.Stat(path); err == nil {
+ if info.Mode().IsRegular() {
+ return true, nil
+ }
+ }
+ // stat returned an error and here we are chekcking if it was
os.PathError
+ if !os.IsNotExist(err) {
+ return false, nil
+ }
+ // after running through all the possible checks, return false and an
err
+ return false, err
+}
+
+// copy one single source file to the destination path
+func copyFile(src, dst string) error {
+ var err error
+ var sourceFD *os.File
+ var destFD *os.File
+ var srcInfo os.FileInfo
+ var srcDirInfo os.FileInfo
+
+ wskprint.PrintlnOpenWhiskVerbose(Flags.Verbose, "Source File ["+src+"]
is being copied to ["+dst+"]")
+
+ // open source file to read it from disk and defer to close the file
+ // once this function is done executing
+ if sourceFD, err = os.Open(src); err != nil {
+ return err
+ }
+ defer sourceFD.Close()
+
+ // running stat on Dir(src), Dir returns all but the last element of
the src
+ // this info is needed in case when a destination path has a directory
structure which does not exist
+ if srcDirInfo, err = os.Stat(filepath.Dir(src)); err != nil {
+ return err
+ }
+
+ // check if the parent directory exist before creating a destination
file
+ // create specified path along with creating any parent directory
+ // e.g. when destination is greeting/common/utils.js and parent dir
common
+ // doesn't exist, its getting created here at greeting/common
+ if _, err = os.Stat(filepath.Dir(dst)); os.IsNotExist(err) {
+ wskprint.PrintlnOpenWhiskVerbose(Flags.Verbose, "Creating
directory pattern ["+filepath.Dir(dst)+"] before creating destination file")
+ if err = os.MkdirAll(filepath.Dir(dst), srcDirInfo.Mode()); err
!= nil {
+ return err
+ }
+ }
+
+ // create destination file before copying source content
+ // defer closing the destination file until the function is done
executing
+ if destFD, err = os.Create(dst); err != nil {
+ return err
+ }
+ defer destFD.Close()
+
+ // now, actually copy the source file content into destination file
+ if _, err = io.Copy(destFD, sourceFD); err != nil {
+ return err
+ }
+
+ // retrieve the file mode bits of the source file
+ // so that the bits can be set to the destination file
+ if srcInfo, err = os.Stat(src); err != nil {
+ return err
+ }
+ return os.Chmod(dst, srcInfo.Mode())
+}
+
+// recursively copy the entire source directory to destination path
+func copyDir(src, dst string) error {
+ var err error
+ var fileDescriptors []os.FileInfo
+ var srcInfo os.FileInfo
+
+ // retrieve os.fileInfo of the source directory
+ if srcInfo, err = os.Stat(src); err != nil {
+ return err
+ }
+
+ // create destination directory with parent directories
+ if err = os.MkdirAll(dst, srcInfo.Mode()); err != nil {
+ return err
+ }
+
+ // now, retrieve all the directory/file entries under the source
directory
+ if fileDescriptors, err = ioutil.ReadDir(src); err != nil {
+ return err
+ }
+
+ // iterating over the entire list of files/directories under the
destination path
+ // run copyFile or recursive copyDir based on if its file or dir
+ for _, fd := range fileDescriptors {
+ srcFilePath := path.Join(src, fd.Name())
+ dstFilePath := path.Join(dst, fd.Name())
+
+ if fd.IsDir() {
+ if err = copyDir(srcFilePath, dstFilePath); err != nil {
+ return err
+ }
+ } else {
+ if err = copyFile(srcFilePath, dstFilePath); err != nil
{
+ return err
+ }
+ }
+ }
+ return nil
+}
diff --git a/utils/file_test.go b/utils/file_test.go
new file mode 100644
index 0000000..cb8f98d
--- /dev/null
+++ b/utils/file_test.go
@@ -0,0 +1,85 @@
+// +build unit
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package utils
+
+import (
+ "fmt"
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+const IS_FILE_PATH_FAILURE_FOR_FILE = "Failed to classify the file path [%s]
as file."
+const IS_FILE_PATH_FAILURE_FOR_DIR = "Failed to classify the dir path [%s] as
dir."
+const IS_FILE_PATH_FAILURE_FOR_EMPTY_PATH = "Failed to classify empty path
[%s] as dir."
+const IS_FILE_FAILURE_FOR_FILE = "Failed to detect if the path [%s] is a valid
file."
+const IS_FILE_FAILURE_FOR_DIR = "Failed to detect if the path [%s] is a dir."
+const TEST_ERROR_IS_FILE_FAILURE = "Failed to run isFile on [%s] Error: %s"
+
+func TestIsFilePath(t *testing.T) {
+ paths := []string{
+ "",
+ "/home/arnie/amelia.jpg",
+ "/mnt/photos/",
+ "rabbit.jpg",
+ "/usr/local//go",
+ "common/actions/*.js/",
+ "common/*/actions/*/code/*.js",
+ "common/actions/",
+ }
+ for _, p := range paths {
+ switch p {
+ case "":
+ assert.False(t, isFilePath(p),
fmt.Sprintf(IS_FILE_PATH_FAILURE_FOR_EMPTY_PATH, p))
+ case "/home/arnie/amelia.jpg":
+ assert.True(t, isFilePath(p),
fmt.Sprintf(IS_FILE_PATH_FAILURE_FOR_FILE, p))
+ case "/mnt/photos/":
+ assert.False(t, isFilePath(p),
fmt.Sprintf(IS_FILE_PATH_FAILURE_FOR_DIR, p))
+ case "rabbit.jpg":
+ assert.True(t, isFilePath(p),
fmt.Sprintf(IS_FILE_PATH_FAILURE_FOR_FILE, p))
+ case "/usr/local//go":
+ assert.True(t, isFilePath(p),
fmt.Sprintf(IS_FILE_PATH_FAILURE_FOR_FILE, p))
+ case "common/actions/*.js/":
+ assert.False(t, isFilePath(p),
fmt.Sprintf(IS_FILE_PATH_FAILURE_FOR_DIR, p))
+ case "common/*/actions/*/code/*.js":
+ assert.True(t, isFilePath(p),
fmt.Sprintf(IS_FILE_PATH_FAILURE_FOR_FILE, p))
+ case "common/actions/":
+ assert.False(t, isFilePath(p),
fmt.Sprintf(IS_FILE_PATH_FAILURE_FOR_DIR, p))
+ }
+ }
+}
+
+func TestIsFile(t *testing.T) {
+ paths := []string{
+ "../tests/dat/",
+ "../tests/dat/manifest_hello_swift.yaml",
+ }
+ for _, p := range paths {
+ f, err := isFile(p)
+ if err != nil {
+ assert.Fail(t, fmt.Sprintf(TEST_ERROR_IS_FILE_FAILURE,
p, err.Error()))
+ }
+ switch p {
+ case "tests/dat/":
+ assert.False(t, f,
fmt.Sprintf(IS_FILE_FAILURE_FOR_FILE, p))
+ case "tests/dat/manifest_hello_swift.yaml":
+ assert.True(t, f, fmt.Sprintf(IS_FILE_FAILURE_FOR_FILE,
p))
+ }
+ }
+}
diff --git a/utils/misc.go b/utils/misc.go
index 81ea403..715db30 100644
--- a/utils/misc.go
+++ b/utils/misc.go
@@ -18,15 +18,12 @@
package utils
import (
- "archive/zip"
"encoding/json"
- "io"
"io/ioutil"
"net/http"
"os"
"os/user"
"path"
- "path/filepath"
"strings"
"github.com/apache/incubator-openwhisk-client-go/whisk"
@@ -99,62 +96,6 @@ func PrettyJSON(j interface{}) (string, error) {
return string(bytes), nil
}
-func NewZipWritter(src, des string) *ZipWritter {
- zw := &ZipWritter{src: src, des: des}
- return zw
-}
-
-type ZipWritter struct {
- src string
- des string
- zipWritter *zip.Writer
-}
-
-func (zw *ZipWritter) zipFile(path string, f os.FileInfo, err error) error {
- if err != nil {
- return err
- }
- if !f.Mode().IsRegular() || f.Size() == 0 {
- return nil
- }
- file, err := os.Open(path)
- if err != nil {
- return err
- }
- defer file.Close()
-
- fileName := strings.TrimPrefix(path, zw.src+"/")
- wr, err := zw.zipWritter.Create(fileName)
- if err != nil {
- return err
- }
-
- _, err = io.Copy(wr, file)
- if err != nil {
- return err
- }
- return nil
-}
-
-func (zw *ZipWritter) Zip() error {
- // create zip file
- zipFile, err := os.Create(zw.des)
- if err != nil {
- return err
- }
- defer zipFile.Close()
- zw.zipWritter = zip.NewWriter(zipFile)
- err = filepath.Walk(zw.src, zw.zipFile)
- if err != nil {
- return nil
- }
- err = zw.zipWritter.Close()
- if err != nil {
- return err
- }
- return nil
-}
-
func GetManifestFilePath(projectPath string) string {
if _, err := os.Stat(path.Join(projectPath, ManifestFileNameYaml)); err
== nil {
return path.Join(projectPath, ManifestFileNameYaml)
diff --git a/utils/misc_test.go b/utils/misc_test.go
index 72d518b..4f92be2 100644
--- a/utils/misc_test.go
+++ b/utils/misc_test.go
@@ -61,7 +61,7 @@ func TestDependencies(t *testing.T) {
func TestNewZipWritter(t *testing.T) {
filePath := "../tests/src/integration/zipaction/actions/cat"
zipName := filePath + ".zip"
- err := NewZipWritter(filePath, zipName).Zip()
+ err := NewZipWritter(filePath, zipName, make([][]string, 0),
make([]string, 0), "").Zip()
defer os.Remove(zipName)
assert.Equal(t, nil, err, "zip folder error happened.")
}
diff --git a/utils/zip.go b/utils/zip.go
new file mode 100644
index 0000000..a818bc0
--- /dev/null
+++ b/utils/zip.go
@@ -0,0 +1,363 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package utils
+
+import (
+ "archive/zip"
+ "io"
+ "os"
+ "path/filepath"
+ "strings"
+
+ "github.com/apache/incubator-openwhisk-wskdeploy/wski18n"
+ "github.com/apache/incubator-openwhisk-wskdeploy/wskprint"
+)
+
+const PATH_WILDCARD = "*"
+const ONE_DIR_UP = "../"
+
+func NewZipWritter(src string, des string, include [][]string, exclude
[]string, manifestFilePath string) *ZipWritter {
+ zw := &ZipWritter{
+ src: src,
+ des: des,
+ include: include,
+ exclude: exclude,
+ excludedFiles: make(map[string]bool, 0),
+ manifestFilePath: manifestFilePath,
+ }
+ return zw
+}
+
+type ZipWritter struct {
+ src string
+ des string
+ include [][]string
+ exclude []string
+ excludedFiles map[string]bool
+ manifestFilePath string
+ zipWritter *zip.Writer
+}
+
+type Include struct {
+ source string
+ destination string
+}
+
+func (zw *ZipWritter) zipFile(path string, f os.FileInfo, err error) error {
+ var file *os.File
+ var wr io.Writer
+ var verboseMsg string
+
+ if err != nil {
+ return err
+ }
+
+ if zw.excludedFiles[filepath.Clean(path)] {
+ verboseMsg =
wski18n.T(wski18n.ID_VERBOSE_ZIP_EXCLUDING_FILE_X_path_X,
+ map[string]interface{}{
+ wski18n.KEY_PATH: path,
+ })
+ wskprint.PrintlnOpenWhiskVerbose(Flags.Verbose, verboseMsg)
+ return nil
+ }
+
+ if !f.Mode().IsRegular() || f.Size() == 0 {
+ return nil
+ }
+ if file, err = os.Open(path); err != nil {
+ return err
+ }
+ defer file.Close()
+
+ fileName := strings.TrimPrefix(path, zw.src+"/")
+ if wr, err = zw.zipWritter.Create(fileName); err != nil {
+ return err
+ }
+
+ if _, err = io.Copy(wr, file); err != nil {
+ return err
+ }
+ verboseMsg = wski18n.T(wski18n.ID_VERBOSE_ZIP_ADDING_FILE_X_path_X,
+ map[string]interface{}{
+ wski18n.KEY_PATH: path,
+ })
+ wskprint.PrintlnOpenWhiskVerbose(Flags.Verbose, verboseMsg)
+ return nil
+}
+
+func (zw *ZipWritter) buildIncludeMetadata() ([]Include, error) {
+ var includeInfo []Include
+ var listOfSourceFiles []string
+ var err error
+ var verboseMsg string
+
+ // iterate over set of included files specified in manifest YAML e.g.
+ // include:
+ // - ["source"]
+ // - ["source", "destination"]
+ for _, includeData := range zw.include {
+ var i Include
+ // if "destination" is not specified, its considered same as
"source"
+ // "source" is relative to where manifest.yaml file is located
+ // relative source path is converted to absolute path by
appending manifest path
+ // since the relative source path might not be accessible from
where wskdeploy is invoked
+ // "destination" is relative to the action directory, the one
specified in function
+ // relative path is converted to absolute path by appending
function directory
+ if len(includeData) == 1 {
+ i.source = filepath.Join(zw.manifestFilePath,
includeData[0])
+ i.destination = filepath.Join(zw.src, includeData[0])
+ verboseMsg =
wski18n.T(wski18n.ID_VERBOSE_ZIP_INCLUDE_SOURCE_PATH_X_path_X,
+ map[string]interface{}{
+ wski18n.KEY_PATH: includeData[0],
+ })
+ wskprint.PrintlnOpenWhiskVerbose(Flags.Verbose,
verboseMsg)
+ } else if len(includeData) == 2 {
+ i.source = filepath.Join(zw.manifestFilePath,
includeData[0])
+ i.destination = zw.src + "/" + includeData[1]
+ verboseMsg =
wski18n.T(wski18n.ID_VERBOSE_ZIP_INCLUDE_SOURCE_PATH_X_path_X_DESTINATION_PATH_X_dest_X,
+ map[string]interface{}{
+ wski18n.KEY_PATH: includeData[0],
+ wski18n.KEY_DESTINATION: includeData[1],
+ })
+ } else {
+ if len(includeData) == 0 {
+ verboseMsg =
wski18n.T(wski18n.ID_VERBOSE_INVALID_INCLUDE_ENTRY,
+ map[string]interface{}{
+ wski18n.KEY_INCLUDE: "",
+ })
+ wskprint.PrintlnOpenWhiskVerbose(Flags.Verbose,
verboseMsg)
+ } else {
+ for index, d := range includeData {
+ includeData[index] = "\"" + d + "\""
+ }
+ includeEntry := strings.Join(includeData, ", ")
+ verboseMsg =
wski18n.T(wski18n.ID_VERBOSE_INVALID_INCLUDE_ENTRY,
+ map[string]interface{}{
+ wski18n.KEY_INCLUDE:
includeEntry,
+ })
+ wskprint.PrintlnOpenWhiskVerbose(Flags.Verbose,
verboseMsg)
+ }
+ continue
+ }
+
+ // set destDir to the destination location
+ // check if its a file than change it to the Dir of destination
file
+ destDir := i.destination
+ if isFilePath(destDir) {
+ destDir = filepath.Dir(destDir)
+ }
+ // trim path wildcard "*" from the destination path as if it
has any
+ destDirs := strings.Split(destDir, PATH_WILDCARD)
+ destDir = destDirs[0]
+
+ // retrieve the name of all files matching pattern or nil if
there is no matching file
+ // listOfSourceFiles will hold a list of files matching
patterns such as
+ // actions/* or actions/libs/* or actions/libs/*/utils.js or
actions/*/*/utils.js
+ if listOfSourceFiles, err = filepath.Glob(i.source); err != nil
{
+ return includeInfo, err
+ }
+
+ // handle the scenarios where included path is something
similar to actions/common/*.js
+ // or actions/libs/* or actions/libs/*/utils.js
+ // and destination is set to libs/ or libs/* or ./libs/* or
libs/*/utils.js or libs/ or ./libs/
+ if strings.ContainsAny(i.source, PATH_WILDCARD) {
+ wskprint.PrintlnOpenWhiskVerbose(Flags.Verbose,
wski18n.T(wski18n.ID_VERBOSE_LIST_OF_FILES_MATCHING_PATTERN))
+ for _, file := range listOfSourceFiles {
+ var relPath string
+ if relPath, err = filepath.Rel(i.source, file);
err != nil {
+ return includeInfo, err
+ }
+ relPath = strings.TrimLeft(relPath, ONE_DIR_UP)
+ j := Include{
+ source: file,
+ destination: filepath.Join(destDir,
relPath),
+ }
+ includeInfo = append(includeInfo, j)
+ zw.excludedFiles[j.source] = false
+ verboseMsg =
wski18n.T(wski18n.ID_VERBOSE_ZIP_INCLUDE_SOURCE_PATH_X_path_X_DESTINATION_PATH_X_dest_X,
+ map[string]interface{}{
+ wski18n.KEY_PATH:
j.source,
+ wski18n.KEY_DESTINATION:
j.destination,
+ })
+ wskprint.PrintlnOpenWhiskVerbose(Flags.Verbose,
verboseMsg)
+ }
+ // handle scenarios where included path is something
similar to actions/common/utils.js
+ // and destination is set to ./common/ i.e. no file
name specified in the destination
+ } else {
+ if f, err := isFile(i.source); err == nil && f {
+ if _, file := filepath.Split(i.destination);
len(file) == 0 {
+ _, sFile := filepath.Split(i.source)
+ i.destination = i.destination + sFile
+ }
+ }
+ // append just parsed include info to the list for
further processing
+ wskprint.PrintlnOpenWhiskVerbose(Flags.Verbose,
wski18n.T(wski18n.ID_VERBOSE_LIST_OF_FILES_MATCHING_PATTERN))
+ verboseMsg =
wski18n.T(wski18n.ID_VERBOSE_ZIP_INCLUDE_SOURCE_PATH_X_path_X_DESTINATION_PATH_X_dest_X,
+ map[string]interface{}{
+ wski18n.KEY_PATH: i.source,
+ wski18n.KEY_DESTINATION: i.destination,
+ })
+ wskprint.PrintlnOpenWhiskVerbose(Flags.Verbose,
verboseMsg)
+ includeInfo = append(includeInfo, i)
+ zw.excludedFiles[i.source] = false
+ }
+ }
+ return includeInfo, nil
+}
+
+func (zw *ZipWritter) buildExcludeMetadata() error {
+ var err error
+ for _, exclude := range zw.exclude {
+ exclude = filepath.Join(zw.manifestFilePath, exclude)
+ if err = zw.findExcludedIncludedFiles(exclude, true); err !=
nil {
+ return err
+ }
+ }
+ return err
+}
+
+func (zw *ZipWritter) findExcludedIncludedFiles(functionPath string, flag
bool) error {
+ var err error
+ var files []string
+ var excludedFiles []string
+ var f bool
+
+ if !strings.HasSuffix(functionPath, PATH_WILDCARD) {
+ functionPath = filepath.Join(functionPath, PATH_WILDCARD)
+ }
+ if excludedFiles, err = filepath.Glob(functionPath); err != nil {
+ return err
+ }
+ for _, file := range excludedFiles {
+ err = filepath.Walk(file, func(path string, info os.FileInfo,
err error) error {
+ files = append(files, path)
+ return nil
+ })
+ if err != nil {
+ return err
+ }
+ }
+ for _, file := range files {
+ if f, err = isFile(file); err != nil {
+ return err
+ } else if f {
+ zw.excludedFiles[file] = flag
+ } else {
+ if err = zw.findExcludedIncludedFiles(file, flag); err
!= nil {
+ return err
+ }
+ }
+ }
+ return err
+}
+
+func (zw *ZipWritter) Zip() error {
+
+ var zipFile *os.File
+ var err error
+ var fileInfo os.FileInfo
+ var verboseMsg string
+
+ // create zip file e.g. greeting.zip
+ if zipFile, err = os.Create(zw.des); err != nil {
+ return err
+ }
+ defer zipFile.Close()
+
+ verboseMsg = wski18n.T(wski18n.ID_VERBOSE_CREATING_ZIP_FILE_X_path_X,
+ map[string]interface{}{
+ wski18n.KEY_PATH: zipFile.Name(),
+ })
+ wskprint.PrintlnOpenWhiskVerbose(Flags.Verbose, verboseMsg)
+
+ // creating a new zip writter for greeting.zip
+ zw.zipWritter = zip.NewWriter(zipFile)
+
+ // build a map of file names and bool indicating whether the file is
included or excluded
+ // iterate over the directory specified in "function", find the list of
files and mark them as not excluded
+ if err = zw.findExcludedIncludedFiles(zw.src, false); err != nil {
+ return err
+ }
+
+ if err = zw.buildExcludeMetadata(); err != nil {
+ return err
+ }
+
+ // walk file system rooted at the directory specified in "function"
+ // walk over each file and dir under root directory e.g. function:
actions/greeting
+ // add actions/greeting/index.js and actions/greeting/package.json to
zip file
+ if err = filepath.Walk(zw.src, zw.zipFile); err != nil {
+ return nil
+ }
+
+ // maintain a list of included files and/or directories with their
destination
+ var includeInfo []Include
+ includeInfo, err = zw.buildIncludeMetadata()
+ if err != nil {
+ return err
+ }
+
+ for _, i := range includeInfo {
+ if i.source != i.destination {
+ // now determine whether the included item is file or
dir
+ // it could list something like this as well,
"actions/common/*.js"
+ if fileInfo, err = os.Stat(i.source); err != nil {
+ return err
+ }
+
+ // if the included item is a directory, call a function
to copy the
+ // entire directory recursively including its
subdirectories and files
+ if fileInfo.Mode().IsDir() {
+ if err = copyDir(i.source, i.destination); err
!= nil {
+ return err
+ }
+ // if the included item is a file, call a
function to copy the file
+ // along with its path by creating the parent
directories
+ } else if fileInfo.Mode().IsRegular() {
+ if err = copyFile(i.source, i.destination); err
!= nil {
+ return err
+ }
+ }
+ }
+ // add included item into zip file greeting.zip
+ if err = filepath.Walk(i.destination, zw.zipFile); err != nil {
+ return nil
+ }
+ }
+
+ // now close the zip file greeting.zip as all the included items
+ // are added into the zip file along with the action root dir
+ if err = zw.zipWritter.Close(); err != nil {
+ return err
+ }
+
+ // and its safe to delete the files/directories which we copied earlier
+ // to include them in the zip file greeting.zip
+ for _, i := range includeInfo {
+ if filepath.Clean(i.source) != filepath.Clean(i.destination) {
+ verboseMsg =
wski18n.T(wski18n.ID_VERBOSE_DELETING_FILE_X_path_X,
+ map[string]interface{}{
+ wski18n.KEY_PATH: i.destination,
+ })
+ wskprint.PrintlnOpenWhiskVerbose(Flags.Verbose,
verboseMsg)
+ os.RemoveAll(i.destination)
+ }
+ }
+
+ return nil
+}
diff --git a/wski18n/i18n_ids.go b/wski18n/i18n_ids.go
index 0cdd2dd..1203516 100644
--- a/wski18n/i18n_ids.go
+++ b/wski18n/i18n_ids.go
@@ -86,6 +86,8 @@ const (
KEY_API_BASE_PATH = "apibasepath"
KEY_RESPONSE = "response"
KEY_API_RELATIVE_PATH = "apirelativepath"
+ KEY_DESTINATION = "destination"
+ KEY_INCLUDE = "include"
)
// DO NOT TRANSLATE
@@ -241,10 +243,18 @@ const (
**/
// Verbose (Debug/Trace) messages
- ID_DEBUG_PROJECT_SEARCH_X_path_X_key_X =
"msg_dbg_searching_project_directory"
- ID_DEBUG_DEPLOYMENT_NAME_FOUND_X_key_X_name_X =
"msg_dbg_deployment_name_found"
- ID_DEBUG_PACKAGES_FOUND_UNDER_ROOT_X_path_X =
"msg_dbg_packages_found_root"
- ID_DEBUG_PACKAGES_FOUND_UNDER_PROJECT_X_path_X_name_X =
"msg_dbg_packages_found_project"
+ ID_DEBUG_PROJECT_SEARCH_X_path_X_key_X =
"msg_dbg_searching_project_directory"
+ ID_DEBUG_DEPLOYMENT_NAME_FOUND_X_key_X_name_X =
"msg_dbg_deployment_name_found"
+ ID_DEBUG_PACKAGES_FOUND_UNDER_ROOT_X_path_X =
"msg_dbg_packages_found_root"
+ ID_DEBUG_PACKAGES_FOUND_UNDER_PROJECT_X_path_X_name_X =
"msg_dbg_packages_found_project"
+ ID_VERBOSE_ZIP_EXCLUDING_FILE_X_path_X =
"msg_verbose_zip_exclude_file_path"
+ ID_VERBOSE_ZIP_ADDING_FILE_X_path_X =
"msg_verbose_zip_adding_file_path"
+ ID_VERBOSE_ZIP_INCLUDE_SOURCE_PATH_X_path_X =
"msg_verbose_zip_include_source_path"
+ ID_VERBOSE_ZIP_INCLUDE_SOURCE_PATH_X_path_X_DESTINATION_PATH_X_dest_X =
"msg_verbose_zip_include_source_path_destination_path"
+ ID_VERBOSE_INVALID_INCLUDE_ENTRY =
"msg_verbose_invalid_include_entry"
+ ID_VERBOSE_CREATING_ZIP_FILE_X_path_X =
"msg_verbose_creating_zip_file"
+ ID_VERBOSE_DELETING_FILE_X_path_X =
"msg_verbose_deleting_file"
+ ID_VERBOSE_LIST_OF_FILES_MATCHING_PATTERN =
"msg_verbose_list_of_files_matching_pattern"
)
// DO NOT TRANSLATE
diff --git a/wski18n/i18n_resources.go b/wski18n/i18n_resources.go
index 72285a7..164bc68 100644
--- a/wski18n/i18n_resources.go
+++ b/wski18n/i18n_resources.go
@@ -92,12 +92,12 @@ func wski18nResourcesDe_deAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/de_DE.all.json", size:
0, mode: os.FileMode(420), modTime: time.Unix(1537087727, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/de_DE.all.json", size:
0, mode: os.FileMode(420), modTime: time.Unix(1520374115, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
-var _wski18nResourcesEn_usAllJson =
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xcc\x7c\x7b\x6f\x1b\xb7\x96\xf8\xff\xf9\x14\x07\xc5\x05\xd2\x02\xb6\xdc\xde\x1f\x7e\xc0\x22\xd8\x2c\xe0\x4d\xdc\x5e\xdf\x26\x71\xe0\x38\x2d\x8a\x24\x98\x50\x33\x47\x12\xaf\x67\xc8\xb9\x24\x47\x8a\x6a\xe8\xbb\x2f\xce\x21\x39\x0f\x59\xf3\x90\x92\x62\x37\xff\x44\x12\xc9\xf3\xe2\xe1\x79\x92\xfe\xf0\x04\xe0\xe1\x09\x00\xc0\x77\x32\xfb\xee\x19\x7c\x57\xd8\x65\x52\x1a\x5c\xc8\x2f\x09\x1a\xa3\xcd\x77\x67\x7e\xd4
[...]
+var _wski18nResourcesEn_usAllJson =
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xcc\x3c\xfd\x6f\x1b\xb7\x92\xbf\xe7\xaf\x18\x14\x0f\x48\x0b\xd8\x72\xfb\x0e\x07\x1c\x8c\xcb\x01\xbe\xc4\xe9\xf3\x6b\x12\x1b\xb6\xd3\xa2\x97\x04\x1b\x6a\x77\x24\xf1\x79\x97\xdc\x92\x5c\x29\xaa\xa1\xff\xfd\x30\x43\x72\x77\x25\x6b\x3f\xa4\xa4\xb8\xcb\x2f\x91\xb4\xe4\x7c\x71\x38\xdf\xeb\x0f\xcf\x00\x1e\x9f\x01\x00\x7c\x27\xb3\xef\xce\xe1\xbb\xc2\xce\x93\xd2\xe0\x4c\x7e\x49\xd0\x18\x6d\xbe\x3b\xf1\x4f\x9d\x11
[...]
func wski18nResourcesEn_usAllJsonBytes() ([]byte, error) {
return bindataRead(
@@ -112,7 +112,7 @@ func wski18nResourcesEn_usAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/en_US.all.json", size:
19741, mode: os.FileMode(420), modTime: time.Unix(1537092250, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/en_US.all.json", size:
20708, mode: os.FileMode(420), modTime: time.Unix(1539294171, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -132,7 +132,7 @@ func wski18nResourcesEs_esAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/es_ES.all.json", size:
0, mode: os.FileMode(420), modTime: time.Unix(1537087727, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/es_ES.all.json", size:
0, mode: os.FileMode(420), modTime: time.Unix(1520374115, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -152,7 +152,7 @@ func wski18nResourcesFr_frAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/fr_FR.all.json", size:
101, mode: os.FileMode(420), modTime: time.Unix(1537087727, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/fr_FR.all.json", size:
101, mode: os.FileMode(420), modTime: time.Unix(1520374115, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -172,7 +172,7 @@ func wski18nResourcesIt_itAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/it_IT.all.json", size:
0, mode: os.FileMode(420), modTime: time.Unix(1537087727, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/it_IT.all.json", size:
0, mode: os.FileMode(420), modTime: time.Unix(1520374115, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -192,7 +192,7 @@ func wski18nResourcesJa_jaAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/ja_JA.all.json", size:
0, mode: os.FileMode(420), modTime: time.Unix(1537087727, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/ja_JA.all.json", size:
0, mode: os.FileMode(420), modTime: time.Unix(1520374115, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -212,7 +212,7 @@ func wski18nResourcesKo_krAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/ko_KR.all.json", size:
0, mode: os.FileMode(420), modTime: time.Unix(1537087727, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/ko_KR.all.json", size:
0, mode: os.FileMode(420), modTime: time.Unix(1520374115, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -232,7 +232,7 @@ func wski18nResourcesPt_brAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/pt_BR.all.json", size:
0, mode: os.FileMode(420), modTime: time.Unix(1537087727, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/pt_BR.all.json", size:
0, mode: os.FileMode(420), modTime: time.Unix(1520374115, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -252,7 +252,7 @@ func wski18nResourcesZh_hansAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/zh_Hans.all.json",
size: 0, mode: os.FileMode(420), modTime: time.Unix(1537087727, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/zh_Hans.all.json",
size: 0, mode: os.FileMode(420), modTime: time.Unix(1520374115, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -272,7 +272,7 @@ func wski18nResourcesZh_hantAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/zh_Hant.all.json",
size: 0, mode: os.FileMode(420), modTime: time.Unix(1537087727, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/zh_Hant.all.json",
size: 0, mode: os.FileMode(420), modTime: time.Unix(1520374115, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -329,14 +329,14 @@ func AssetNames() []string {
// _bindata is a table, holding each asset generator, mapped to its name.
var _bindata = map[string]func() (*asset, error){
- "wski18n/resources/de_DE.all.json": wski18nResourcesDe_deAllJson,
- "wski18n/resources/en_US.all.json": wski18nResourcesEn_usAllJson,
- "wski18n/resources/es_ES.all.json": wski18nResourcesEs_esAllJson,
- "wski18n/resources/fr_FR.all.json": wski18nResourcesFr_frAllJson,
- "wski18n/resources/it_IT.all.json": wski18nResourcesIt_itAllJson,
- "wski18n/resources/ja_JA.all.json": wski18nResourcesJa_jaAllJson,
- "wski18n/resources/ko_KR.all.json": wski18nResourcesKo_krAllJson,
- "wski18n/resources/pt_BR.all.json": wski18nResourcesPt_brAllJson,
+ "wski18n/resources/de_DE.all.json": wski18nResourcesDe_deAllJson,
+ "wski18n/resources/en_US.all.json": wski18nResourcesEn_usAllJson,
+ "wski18n/resources/es_ES.all.json": wski18nResourcesEs_esAllJson,
+ "wski18n/resources/fr_FR.all.json": wski18nResourcesFr_frAllJson,
+ "wski18n/resources/it_IT.all.json": wski18nResourcesIt_itAllJson,
+ "wski18n/resources/ja_JA.all.json": wski18nResourcesJa_jaAllJson,
+ "wski18n/resources/ko_KR.all.json": wski18nResourcesKo_krAllJson,
+ "wski18n/resources/pt_BR.all.json": wski18nResourcesPt_brAllJson,
"wski18n/resources/zh_Hans.all.json": wski18nResourcesZh_hansAllJson,
"wski18n/resources/zh_Hant.all.json": wski18nResourcesZh_hantAllJson,
}
@@ -380,17 +380,18 @@ type bintree struct {
Func func() (*asset, error)
Children map[string]*bintree
}
+
var _bintree = &bintree{nil, map[string]*bintree{
"wski18n": &bintree{nil, map[string]*bintree{
"resources": &bintree{nil, map[string]*bintree{
- "de_DE.all.json":
&bintree{wski18nResourcesDe_deAllJson, map[string]*bintree{}},
- "en_US.all.json":
&bintree{wski18nResourcesEn_usAllJson, map[string]*bintree{}},
- "es_ES.all.json":
&bintree{wski18nResourcesEs_esAllJson, map[string]*bintree{}},
- "fr_FR.all.json":
&bintree{wski18nResourcesFr_frAllJson, map[string]*bintree{}},
- "it_IT.all.json":
&bintree{wski18nResourcesIt_itAllJson, map[string]*bintree{}},
- "ja_JA.all.json":
&bintree{wski18nResourcesJa_jaAllJson, map[string]*bintree{}},
- "ko_KR.all.json":
&bintree{wski18nResourcesKo_krAllJson, map[string]*bintree{}},
- "pt_BR.all.json":
&bintree{wski18nResourcesPt_brAllJson, map[string]*bintree{}},
+ "de_DE.all.json":
&bintree{wski18nResourcesDe_deAllJson, map[string]*bintree{}},
+ "en_US.all.json":
&bintree{wski18nResourcesEn_usAllJson, map[string]*bintree{}},
+ "es_ES.all.json":
&bintree{wski18nResourcesEs_esAllJson, map[string]*bintree{}},
+ "fr_FR.all.json":
&bintree{wski18nResourcesFr_frAllJson, map[string]*bintree{}},
+ "it_IT.all.json":
&bintree{wski18nResourcesIt_itAllJson, map[string]*bintree{}},
+ "ja_JA.all.json":
&bintree{wski18nResourcesJa_jaAllJson, map[string]*bintree{}},
+ "ko_KR.all.json":
&bintree{wski18nResourcesKo_krAllJson, map[string]*bintree{}},
+ "pt_BR.all.json":
&bintree{wski18nResourcesPt_brAllJson, map[string]*bintree{}},
"zh_Hans.all.json":
&bintree{wski18nResourcesZh_hansAllJson, map[string]*bintree{}},
"zh_Hant.all.json":
&bintree{wski18nResourcesZh_hantAllJson, map[string]*bintree{}},
}},
@@ -443,4 +444,3 @@ func _filePath(dir, name string) string {
cannonicalName := strings.Replace(name, "\\", "/", -1)
return filepath.Join(append([]string{dir},
strings.Split(cannonicalName, "/")...)...)
}
-
diff --git a/wski18n/resources/en_US.all.json b/wski18n/resources/en_US.all.json
index 06e4ed5..9e78b70 100644
--- a/wski18n/resources/en_US.all.json
+++ b/wski18n/resources/en_US.all.json
@@ -510,5 +510,33 @@
{
"id": "msg_config_missing_apigw_access_token",
"translation": "The apigw access token is not configured.\n"
+ },
+ {
+ "id": "msg_verbose_zip_exclude_file_path",
+ "translation": "Excluding Path: [{{.path}}]\n"
+ },
+ {
+ "id": "msg_verbose_zip_adding_file_path",
+ "translation": "Adding [{{.path}}] to Zip File.\n"
+ },
+ {
+ "id": "msg_verbose_zip_include_source_path",
+ "translation": "For the Source Path: [{{.path}}]\n"
+ },
+ {
+ "id": "msg_verbose_zip_include_source_path_destination_path",
+ "translation": "For the Source Path: [{{.path}}] and Destination Path:
[{{.destination}}]\n"
+ },
+ {
+ "id": "msg_verbose_invalid_include_entry",
+ "translation": "Ignoring Include Entry as it is invalid [{{.include}}].
Include entry can either have [Source] or [Source, Destination].\n"
+ },
+ {
+ "id": "msg_verbose_creating_zip_file",
+ "translation": "Creating the Zip File: [{{.path}}]\n"
+ },
+ {
+ "id": "msg_verbose_list_of_files_matching_pattern",
+ "translation": "Found the following files with matching Source File Path
pattern.\n"
}
]