openwhisk-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lz1...@apache.org
Subject [incubator-openwhisk-wskdeploy] branch master updated: Updated YAML parser to run unmarshal with parsing errors (#446)
Date Wed, 06 Sep 2017 03:12:53 GMT
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 49f6f37  Updated YAML parser to run unmarshal with parsing errors (#446)
49f6f37 is described below

commit 49f6f374638699bc383e5efb6d4b8d28f49deb90
Author: Priti Desai <pdesai@us.ibm.com>
AuthorDate: Tue Sep 5 20:12:51 2017 -0700

    Updated YAML parser to run unmarshal with parsing errors (#446)
---
 parsers/deploy_parser.go                            |  2 +-
 parsers/manifest_parser.go                          |  2 +-
 parsers/manifest_parser_test.go                     | 11 +----------
 parsers/yamlparser.go                               |  2 +-
 tests/src/integration/dependency/manifest.yaml      |  2 --
 tests/src/integration/helloworld/helloworld_test.go |  2 +-
 6 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/parsers/deploy_parser.go b/parsers/deploy_parser.go
index b6ad73c..6ad318b 100644
--- a/parsers/deploy_parser.go
+++ b/parsers/deploy_parser.go
@@ -24,7 +24,7 @@ import (
 )
 
 func (dm *YAMLParser) UnmarshalDeployment(input []byte, deploy *DeploymentYAML) error {
-	err := yaml.Unmarshal(input, deploy)
+	err := yaml.UnmarshalStrict(input, deploy)
 	if err != nil {
 		fmt.Printf("error happened during unmarshal :%v", err)
 		return err
diff --git a/parsers/manifest_parser.go b/parsers/manifest_parser.go
index a0a3b3c..8c9cc1e 100644
--- a/parsers/manifest_parser.go
+++ b/parsers/manifest_parser.go
@@ -59,7 +59,7 @@ func Write(manifest *ManifestYAML, filename string) {
 }
 
 func (dm *YAMLParser) Unmarshal(input []byte, manifest *ManifestYAML) error {
-	err := yaml.Unmarshal(input, manifest)
+	err := yaml.UnmarshalStrict(input, manifest)
 	if err != nil {
 		fmt.Printf("error happened during unmarshal :%v", err)
 		return err
diff --git a/parsers/manifest_parser_test.go b/parsers/manifest_parser_test.go
index b8cb664..374d21a 100644
--- a/parsers/manifest_parser_test.go
+++ b/parsers/manifest_parser_test.go
@@ -216,16 +216,7 @@ func TestUnmarshalForMissingPackage(t *testing.T) {
 	// Unmarshal reads/parses manifest data and sets the values of ManifestYAML
 	// And returns an error if parsing a manifest data fails
 	err := NewYAMLParser().Unmarshal([]byte(data), &m)
-	fmt.Println("Error: ", err)
-	fmt.Println("Filepath: \"", m.Filepath, "\"")
-	fmt.Println("Package: ", m.Package)
-	fmt.Println("PackageName: \"", m.Package.Packagename, "\"")
-	fmt.Println("Number of Actions: ", len(m.Package.Actions))
-	fmt.Println("Actions: ", m.Package.Actions)
-	// (TODO) Unmarshal does not report any error even if manifest file is missing required
section.
-	// (TODO) In this test case, "Package" section is missing which is not reported,
-	// (TODO) instead ManifestYAML is set to its zero values
-	// assert.NotNil(t, err, "Expected some error from Unmarshal but got no error")
+	assert.NotNil(t, err, "Expected some error from Unmarshal but got no error")
 }
 
 /*
diff --git a/parsers/yamlparser.go b/parsers/yamlparser.go
index 9190bbe..133c4c6 100644
--- a/parsers/yamlparser.go
+++ b/parsers/yamlparser.go
@@ -53,7 +53,7 @@ type Action struct {
 	Version  string `yaml:"version"`  //used in manifest.yaml
 	Location string `yaml:"location"` //deprecated, used in manifest.yaml
 	Function string `yaml:"function"` //used in manifest.yaml
-	Runtime  string `yaml:"runtime"`  //used in manifest.yaml
+	Runtime  string `yaml:"runtime,omitempty"`  //used in manifest.yaml
 	//mapping to wsk.Action.Namespace
 	Namespace  string                 `yaml:"namespace"`  //used in deployment.yaml
 	Credential string                 `yaml:"credential"` //used in deployment.yaml
diff --git a/tests/src/integration/dependency/manifest.yaml b/tests/src/integration/dependency/manifest.yaml
index f76390d..8c05414 100644
--- a/tests/src/integration/dependency/manifest.yaml
+++ b/tests/src/integration/dependency/manifest.yaml
@@ -10,8 +10,6 @@ package:
     rule1:
       trigger: trigger1
       action: openwhisk-app/hello
-      runtime: nodejs:6
     rule2:
       trigger: trigger2
       action: openwhisk-app/helloworld
-      runtime: nodejs:6
diff --git a/tests/src/integration/helloworld/helloworld_test.go b/tests/src/integration/helloworld/helloworld_test.go
index d453e66..d5d38e4 100644
--- a/tests/src/integration/helloworld/helloworld_test.go
+++ b/tests/src/integration/helloworld/helloworld_test.go
@@ -26,7 +26,7 @@ import (
 	"testing"
 )
 
-func IntegrationTestHelloWorld(t *testing.T) {
+func TestHelloWorld(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.")

-- 
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <commits@openwhisk.apache.org>'].

Mime
View raw message