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/03/08 19:28:19 UTC

[incubator-openwhisk-wskdeploy] branch master updated: add --projectname flag (#775)

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 9ca3c3d  add --projectname  flag (#775)
9ca3c3d is described below

commit 9ca3c3d805e39e285e39bbdce598274476fd86ea
Author: Lionel Villard <vi...@us.ibm.com>
AuthorDate: Thu Mar 8 14:28:17 2018 -0500

    add --projectname  flag (#775)
    
    Adding an option to specify project name on command line which will take higher precedence and overrides the one in manifest/deployment file.
---
 .gitignore                                         |  1 +
 cmd/root.go                                        |  1 +
 deployers/servicedeployer.go                       | 11 ++++++++++-
 tests/src/integration/common/wskdeploy.go          |  4 ++++
 .../managed-deployment/05-manifest-headless.yaml   | 22 ++++++++++++++++++++++
 .../managed-deployment/managed-deployment_test.go  | 10 ++++++++--
 utils/flags.go                                     |  3 ++-
 wski18n/i18n_ids.go                                |  3 +++
 wski18n/i18n_resources.go                          | 22 +++++++++++-----------
 wski18n/resources/en_US.all.json                   |  8 ++++++++
 10 files changed, 70 insertions(+), 15 deletions(-)

diff --git a/.gitignore b/.gitignore
index d986475..9fd9de2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -46,3 +46,4 @@ build/
 
 #emacs
 *~
+bin/content.json
diff --git a/cmd/root.go b/cmd/root.go
index 7225924..082515e 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -125,6 +125,7 @@ func init() {
 	RootCmd.PersistentFlags().StringVarP(&utils.Flags.Key, "key", "k", "", wski18n.T(wski18n.ID_CMD_FLAG_KEY_FILE))
 	RootCmd.PersistentFlags().StringVarP(&utils.Flags.Cert, "cert", "c", "", wski18n.T(wski18n.ID_CMD_FLAG_CERT_FILE))
 	RootCmd.PersistentFlags().BoolVarP(&utils.Flags.Managed, "managed", "", false, wski18n.T(wski18n.ID_CMD_FLAG_MANAGED))
+	RootCmd.PersistentFlags().StringVarP(&utils.Flags.ProjectName, "projectname", "", "", wski18n.T(wski18n.ID_CMD_FLAG_PROJECTNAME))
 }
 
 // initConfig reads in config file and ENV variables if set.
diff --git a/deployers/servicedeployer.go b/deployers/servicedeployer.go
index f542912..0ef55d8 100644
--- a/deployers/servicedeployer.go
+++ b/deployers/servicedeployer.go
@@ -128,7 +128,16 @@ func (deployer *ServiceDeployer) ConstructDeploymentPlan() error {
 		return err
 	}
 
-	deployer.ProjectName = manifest.GetProject().Name
+	deployer.ProjectName = utils.Flags.ProjectName
+	if deployer.ProjectName == "" {
+		deployer.ProjectName = manifest.GetProject().Name
+	} else {
+		warningString := wski18n.T(
+			wski18n.ID_WARN_PROJECT_NAME_OVERRIDDEN,
+			map[string]interface{}{
+				wski18n.KEY_PROJECT: deployer.ProjectName})
+		wskprint.PrintOpenWhiskWarning(warningString)
+	}
 
 	// Generate Managed Annotations if its marked as a Managed Deployment
 	// Managed deployments are the ones when OpenWhisk entities are deployed with command line flag --managed.
diff --git a/tests/src/integration/common/wskdeploy.go b/tests/src/integration/common/wskdeploy.go
index caddc99..82a3404 100644
--- a/tests/src/integration/common/wskdeploy.go
+++ b/tests/src/integration/common/wskdeploy.go
@@ -170,6 +170,10 @@ func (Wskdeploy *Wskdeploy) ManagedDeployment(manifestPath string, deploymentPat
 	return Wskdeploy.RunCommand("-m", manifestPath, "-d", deploymentPath, "--managed")
 }
 
+func (Wskdeploy *Wskdeploy) HeadlessManagedDeployment(manifestPath string, deploymentPath string, name string) (string, error) {
+	return Wskdeploy.RunCommand("-m", manifestPath, "-d", deploymentPath, "--managed", "--projectname", name)
+}
+
 func (Wskdeploy *Wskdeploy) ManagedUndeployment(manifestPath string, deploymentPath string) (string, error) {
 	return Wskdeploy.RunCommand("undeploy", "-m", manifestPath, "-d", deploymentPath, "--managed")
 }
diff --git a/tests/src/integration/managed-deployment/05-manifest-headless.yaml b/tests/src/integration/managed-deployment/05-manifest-headless.yaml
new file mode 100644
index 0000000..cf2b1c8
--- /dev/null
+++ b/tests/src/integration/managed-deployment/05-manifest-headless.yaml
@@ -0,0 +1,22 @@
+#
+# 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.
+#
+
+packages:
+  ManagedPackage-Headless:
+    actions:
+      HelloWorld-Headless:
+        function: actions/hello.js
+        runtime: nodejs:6
\ No newline at end of file
diff --git a/tests/src/integration/managed-deployment/managed-deployment_test.go b/tests/src/integration/managed-deployment/managed-deployment_test.go
index c3bf5d6..119296d 100644
--- a/tests/src/integration/managed-deployment/managed-deployment_test.go
+++ b/tests/src/integration/managed-deployment/managed-deployment_test.go
@@ -20,10 +20,11 @@
 package tests
 
 import (
-	"github.com/apache/incubator-openwhisk-wskdeploy/tests/src/integration/common"
-	"github.com/stretchr/testify/assert"
 	"os"
 	"testing"
+
+	"github.com/apache/incubator-openwhisk-wskdeploy/tests/src/integration/common"
+	"github.com/stretchr/testify/assert"
 )
 
 func TestManagedDeployment(t *testing.T) {
@@ -58,4 +59,9 @@ func TestManagedDeployment(t *testing.T) {
 	wskdeploy = common.NewWskdeploy()
 	_, err = wskdeploy.ManagedDeployment(manifestPath, deploymentPath)
 	assert.Equal(t, nil, err, "Failed to deploy based on the manifest and deployment files.")
+
+	manifestPath = os.Getenv("GOPATH") + path + "05-manifest-headless.yaml"
+	wskdeploy = common.NewWskdeploy()
+	_, err = wskdeploy.HeadlessManagedDeployment(manifestPath, deploymentPath, "Headless Managed")
+	assert.Equal(t, nil, err, "Failed to deploy based on the manifest and deployment files.")
 }
diff --git a/utils/flags.go b/utils/flags.go
index e55983e..89550b4 100644
--- a/utils/flags.go
+++ b/utils/flags.go
@@ -39,7 +39,8 @@ type WskDeployFlags struct {
 	Strict           bool // strict flag to support user defined runtime version.
 	Key              string
 	Cert             string
-	Managed          bool // OpenWhisk Managed Deployments
+	Managed          bool   // OpenWhisk Managed Deployments
+	ProjectName      string // Project name
 	ApigwAccessToken string
 }
 
diff --git a/wski18n/i18n_ids.go b/wski18n/i18n_ids.go
index b8c1bdc..3040e59 100644
--- a/wski18n/i18n_ids.go
+++ b/wski18n/i18n_ids.go
@@ -67,6 +67,7 @@ const (
 	ID_CMD_FLAG_INTERACTIVE = "msg_cmd_flag_interactive"
 	ID_CMD_FLAG_KEY_FILE    = "msg_cmd_flag_key_file"
 	ID_CMD_FLAG_MANAGED     = "msg_cmd_flag_allow_managed"
+	ID_CMD_FLAG_PROJECTNAME = "msg_cmd_flag_project_name"
 	ID_CMD_FLAG_MANIFEST    = "msg_cmd_flag_manifest"
 	ID_CMD_FLAG_NAMESPACE   = "msg_cmd_flag_namespace"
 	ID_CMD_FLAG_PROJECT     = "msg_cmd_flag_project"
@@ -163,6 +164,7 @@ const (
 	ID_WARN_ENTITY_NAME_EXISTS_X_key_X_name_X                 = "msg_warn_entity_name_exists"
 	ID_WARN_PACKAGES_NOT_FOUND_X_path_X                       = "msg_warn_packages_not_found"
 	ID_WARN_DEPLOYMENT_NAME_NOT_FOUND_X_key_X_name_X          = "msg_warn_deployment_name_not_found"
+	ID_WARN_PROJECT_NAME_OVERRIDDEN                           = "msg_warn_project_name_overridden"
 
 	// Verbose (Debug/Trace) messages
 	ID_DEBUG_DEPLOYING_USING                              = "msg_dbg_deploying_using"
@@ -219,6 +221,7 @@ var I18N_ID_SET = [](string){
 	ID_CMD_FLAG_INTERACTIVE,
 	ID_CMD_FLAG_KEY_FILE,
 	ID_CMD_FLAG_MANAGED,
+	ID_CMD_FLAG_PROJECTNAME,
 	ID_CMD_FLAG_MANIFEST,
 	ID_CMD_FLAG_NAMESPACE,
 	ID_CMD_FLAG_PROJECT,
diff --git a/wski18n/i18n_resources.go b/wski18n/i18n_resources.go
index 440b072..a43f2f8 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(1515697090, 0)}
+	info := bindataFileInfo{name: "wski18n/resources/de_DE.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1489187925, 0)}
 	a := &asset{bytes: bytes, info: info}
 	return a, nil
 }
 
-var _wski18nResourcesEn_usAllJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xc4\x5a\x6d\x6f\x1b\x37\xf2\x7f\x9f\x4f\x31\x08\xfe\x40\x5a\xc0\x51\xd2\xfe\x71\xc0\x21\x80\x71\xc8\x5d\xd2\x36\xd7\x26\x0e\xec\xf8\x8a\x22\x35\x36\xd4\x72\xb4\xcb\x6a\x97\x5c\x90\x5c\x2b\xaa\xa1\xef\x7e\x18\x92\xfb\x20\xd9\xdc\xa5\x94\x06\xd7\x37\x55\xcc\xe1\xcc\x6f\x86\xe4\x3c\xee\xc7\x47\x00\x77\x8f\x00\x00\x1e\x0b\xfe\xf8\x05\x3c\xae\x4d\x91\x35\x1a\x57\xe2\x73\x86\x5a\x2b\xfd\xf8\xcc\xaf\x5a\xcd\xa4 [...]
+var _wski18nResourcesEn_usAllJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xc4\x5a\x6d\x6f\x1b\x37\xf2\x7f\x9f\x4f\x31\x08\xfe\x40\x5a\xc0\x51\xd2\xfe\x71\xc0\x21\x80\x71\xc8\x5d\xd2\x36\xd7\x26\x0e\xec\xf8\x8a\x22\x35\x36\xd4\x72\x24\xb1\xda\x25\x17\x24\xd7\x8a\x6a\xe8\xbb\x1f\x86\x0f\xbb\x2b\xd9\xdc\xa5\x94\x06\xd7\x37\x55\xcc\xe1\xcc\x6f\x66\xc8\xe1\x3c\xec\xc7\x47\x00\x77\x8f\x00\x00\x1e\x0b\xfe\xf8\x05\x3c\xae\xcd\xb2\x68\x34\x2e\xc4\xe7\x02\xb5\x56\xfa\xf1\x99\x5f\xb5\x9a [...]
 
 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: 13032, mode: os.FileMode(420), modTime: time.Unix(1520362388, 0)}
+	info := bindataFileInfo{name: "wski18n/resources/en_US.all.json", size: 13249, mode: os.FileMode(420), modTime: time.Unix(1520531312, 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(1515697090, 0)}
+	info := bindataFileInfo{name: "wski18n/resources/es_ES.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1489187925, 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(1515697090, 0)}
+	info := bindataFileInfo{name: "wski18n/resources/fr_FR.all.json", size: 101, mode: os.FileMode(420), modTime: time.Unix(1489187925, 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(1515697090, 0)}
+	info := bindataFileInfo{name: "wski18n/resources/it_IT.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1489187925, 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(1515697090, 0)}
+	info := bindataFileInfo{name: "wski18n/resources/ja_JA.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1489187925, 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(1515697090, 0)}
+	info := bindataFileInfo{name: "wski18n/resources/ko_KR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1489187925, 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(1515697090, 0)}
+	info := bindataFileInfo{name: "wski18n/resources/pt_BR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1489187925, 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(1515697090, 0)}
+	info := bindataFileInfo{name: "wski18n/resources/zh_Hans.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1489187925, 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(1515697090, 0)}
+	info := bindataFileInfo{name: "wski18n/resources/zh_Hant.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1489187925, 0)}
 	a := &asset{bytes: bytes, info: info}
 	return a, nil
 }
diff --git a/wski18n/resources/en_US.all.json b/wski18n/resources/en_US.all.json
index 7d1a2d7..67c2850 100644
--- a/wski18n/resources/en_US.all.json
+++ b/wski18n/resources/en_US.all.json
@@ -76,6 +76,10 @@
     "translation": "allow project entities to be marked managed"
   },
   {
+    "id": "msg_cmd_flag_project_name",
+    "translation": "project name"
+  },
+  {
     "id": "msg_cmd_flag_manifest",
     "translation": "path to manifest file"
   },
@@ -380,6 +384,10 @@
     "translation": "The {{.key}} [{{.name}}] in the deployment file was not found in the manifest file.\n"
   },
   {
+    "id": "msg_warn_project_name_overridden",
+    "translation": "The project name has been overridden. Using {{.project}}\n"
+  },
+  {
     "id": "DEBUG",
     "translation": "================= DEBUG ==================="
   },

-- 
To stop receiving notification emails like this one, please contact
pdesai@apache.org.