openwhisk-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject [incubator-openwhisk-wskdeploy] branch master updated: Add trace support, include -trace flag and -v for go test. (#785)
Date Fri, 09 Mar 2018 01:08:07 GMT
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 c08d805  Add trace support, include -trace flag and -v for go test. (#785)
c08d805 is described below

commit c08d8053dec6fb478702e662f89d5bdb5cea8741
Author: Matt Rutkowski <mrutkows@us.ibm.com>
AuthorDate: Thu Mar 8 19:08:05 2018 -0600

    Add trace support, include -trace flag and -v for go test. (#785)
    
    adding detailed trace output while running unit tests (deploymentreader and manifestreader
for now) will add similar support to rest of the unit tests in future.
---
 README.md                          |  24 +++++++-
 cmd/root.go                        | 115 +++++++++++++++++++------------------
 deployers/deploymentreader.go      |   7 ++-
 deployers/deploymentreader_test.go |   5 +-
 deployers/manifestreader_test.go   |   5 ++
 parsers/manifest_parser.go         |   2 +-
 utils/flags.go                     |   3 +-
 wski18n/i18n_ids.go                |  95 +++++++++++++++---------------
 wski18n/i18n_resources.go          |  22 +++----
 wski18n/resources/en_US.all.json   |  24 ++------
 wskprint/console.go                |  28 ++++++---
 11 files changed, 182 insertions(+), 148 deletions(-)

diff --git a/README.md b/README.md
index cd519ba..f4c8102 100644
--- a/README.md
+++ b/README.md
@@ -141,6 +141,22 @@ $ git branch --set-upstream-to origin/master  # track master from origin
now
 
 You can now use `git push` to push changes to your repository and submit pull requests.
 
+### Developers should use "go deps" and "go build" not "go get"
+
+The Whisk deploy project is setup for development purposes and uses "go deps" for dependency
management. We do NOT recommend using "go get" as this will use the latest dependencies for
all imported GitHub repos. which is not supported.
+
+- See: [https://github.com/tools/godep](https://github.com/tools/godep)
+
+Specifically, for development please use:
+
+```
+$ git clone git@github.com:mrutkows/incubator-openwhisk-wskdeploy
+$ go build
+```
+
+for end-users, please use versioned releases of binaries.
+- [https://github.com/apache/incubator-openwhisk-wskdeploy/releases](https://github.com/apache/incubator-openwhisk-wskdeploy/releases)
+
 ### How to Cross Compile Binary with Gradle/Docker
 
 If you don't want to bother with go installation, build, git clone etc, and you can do it
with Gradle/Docker.
@@ -174,7 +190,7 @@ Then, you will find the binaries and their compressed packages generated
under t
 ### Building for Internationalization
 
 Please follow this process for building any changes to translatable strings:
-[How to generate the file i18n_resources.go for internationalization](https://github.com/apache/incubator-openwhisk-wskdeploy/blob/master/wski18n/README.md)
+- [How to generate the file i18n_resources.go for internationalization](https://github.com/apache/incubator-openwhisk-wskdeploy/blob/master/wski18n/README.md)
 
 <!-- ----------------------------------------------------------------------------- -->
 
@@ -204,7 +220,11 @@ while there, you can verify that your upstream repository is set correctly:
 
 #### Git clone RPC failed: HTTP 301
 
-This sometimes occurs using "go get" the wskdeploy code (which indirectly invokes "git clone").
You might get this error when downloading `incubator-openwhisk-wskdeploy`:
+This sometimes occurs using "go get" the wskdeploy code (which indirectly invokes "git clone").

+
+<b>Note: Using "go get" for development is unsupported; instead, please use "go deps"
for dependency management.</b>
+
+You might get this error when downloading `incubator-openwhisk-wskdeploy`:
 
      Cloning into ''$GOAPTH/src/gopkg.in/yaml.v2'...
      error: RPC failed; HTTP 301 curl 22 The requested URL returned error: 301
diff --git a/cmd/root.go b/cmd/root.go
index 082515e..c29eca1 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -111,6 +111,7 @@ func init() {
 	// with any other Whisk Deploy command e.g. undeploy, export, etc.
 	// TODO() Publish command, not completed
 	// TODO() Report command, not completed
+	// TODO() have a single function that conditionally (i.e., Trace=true) prints ALL Flags
 	RootCmd.PersistentFlags().StringVar(&utils.Flags.CfgFile, "config", "", wski18n.T(wski18n.ID_CMD_FLAG_CONFIG))
 	RootCmd.PersistentFlags().StringVarP(&utils.Flags.ProjectPath, "project", "p", ".",
wski18n.T(wski18n.ID_CMD_FLAG_PROJECT))
 	RootCmd.PersistentFlags().StringVarP(&utils.Flags.ManifestPath, "manifest", "m", "",
wski18n.T(wski18n.ID_CMD_FLAG_MANIFEST))
@@ -126,6 +127,8 @@ func init() {
 	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))
+	RootCmd.PersistentFlags().BoolVarP(&utils.Flags.Trace, "trace", "t", false, wski18n.T(wski18n.ID_CMD_FLAG_TRACE))
+	RootCmd.PersistentFlags().MarkHidden("trace")
 }
 
 // initConfig reads in config file and ENV variables if set.
@@ -149,6 +152,7 @@ func initConfig() {
 	}
 }
 
+// TODO() add Trace of runtimes found at apihost
 func setSupportedRuntimes(apiHost string) {
 	op, error := utils.ParseOpenWhisk(apiHost)
 	if error == nil {
@@ -159,12 +163,46 @@ func setSupportedRuntimes(apiHost string) {
 	}
 }
 
+func displayCommandUsingFilenameMessage(command string, filetype string, path string) {
+	msg := wski18n.T(wski18n.ID_MSG_COMMAND_USING_X_cmd_X_filetype_X_path_X,
+		map[string]interface{}{
+			wski18n.KEY_CMD:       command,
+			wski18n.KEY_FILE_TYPE: filetype,
+			wski18n.KEY_PATH:      path})
+	wskprint.PrintlnOpenWhiskVerbose(utils.Flags.Verbose, msg)
+}
+
+func loadDefaultManifestFileFromProjectPath(command string, projectPath string) error {
+
+	if _, err := os.Stat(path.Join(projectPath, utils.ManifestFileNameYaml)); err == nil {
+		utils.Flags.ManifestPath = path.Join(projectPath, utils.ManifestFileNameYaml)
+	} else if _, err := os.Stat(path.Join(projectPath, utils.ManifestFileNameYml)); err == nil
{
+		utils.Flags.ManifestPath = path.Join(projectPath, utils.ManifestFileNameYml)
+	} else {
+		stderr = wski18n.T(wski18n.ID_ERR_MANIFEST_FILE_NOT_FOUND_X_path_X,
+			map[string]interface{}{wski18n.KEY_PATH: projectPath})
+		return wskderrors.NewErrorManifestFileNotFound(projectPath, stderr)
+	}
+	displayCommandUsingFilenameMessage(command, wski18n.MANIFEST_FILE, utils.Flags.ManifestPath)
+	return nil
+}
+
+func loadDefaultDeploymentFileFromProjectPath(command string, projectPath string) error {
+
+	if _, err := os.Stat(path.Join(projectPath, utils.DeploymentFileNameYaml)); err == nil {
+		utils.Flags.DeploymentPath = path.Join(projectPath, utils.DeploymentFileNameYaml)
+	} else if _, err := os.Stat(path.Join(projectPath, utils.DeploymentFileNameYml)); err ==
nil {
+		utils.Flags.DeploymentPath = path.Join(projectPath, utils.DeploymentFileNameYml)
+	}
+	displayCommandUsingFilenameMessage(command, wski18n.DEPLOYMENT_FILE, utils.Flags.ManifestPath)
+	return nil
+}
+
 func Deploy() error {
 
+	// Convey flags for verbose and trace to Go client
 	whisk.SetVerbose(utils.Flags.Verbose)
-	// Verbose mode is the only mode for wskdeploy to turn on all the debug messages,
-	// so set Verbose mode (and also debug mode) to true.
-	whisk.SetDebug(utils.Flags.Verbose)
+	whisk.SetDebug(utils.Flags.Trace)
 
 	project_Path := strings.TrimSpace(utils.Flags.ProjectPath)
 	if len(project_Path) == 0 {
@@ -172,29 +210,17 @@ func Deploy() error {
 	}
 	projectPath, _ := filepath.Abs(project_Path)
 
-	// TODO() identical code block below; please create function both can share
+	// If manifest filename is not provided, attempt to load default manifests from project
path
 	if utils.Flags.ManifestPath == "" {
-		if _, err := os.Stat(path.Join(projectPath, utils.ManifestFileNameYaml)); err == nil {
-			utils.Flags.ManifestPath = path.Join(projectPath, utils.ManifestFileNameYaml)
-			stdout = wski18n.T(wski18n.ID_MSG_MANIFEST_DEPLOY_X_path_X,
-				map[string]interface{}{wski18n.KEY_PATH: utils.Flags.ManifestPath})
-		} else if _, err := os.Stat(path.Join(projectPath, utils.ManifestFileNameYml)); err ==
nil {
-			utils.Flags.ManifestPath = path.Join(projectPath, utils.ManifestFileNameYml)
-			stdout = wski18n.T(wski18n.ID_MSG_MANIFEST_DEPLOY_X_path_X,
-				map[string]interface{}{wski18n.KEY_PATH: utils.Flags.ManifestPath})
-		} else {
-			stderr = wski18n.T(wski18n.ID_ERR_MANIFEST_FILE_NOT_FOUND_X_path_X,
-				map[string]interface{}{wski18n.KEY_PATH: projectPath})
-			return wskderrors.NewErrorManifestFileNotFound(projectPath, stderr)
+		if err := loadDefaultManifestFileFromProjectPath(wski18n.CMD_DEPLOY, projectPath); err
!= nil {
+			return err
 		}
-		whisk.Debug(whisk.DbgInfo, stdout)
 	}
 
 	if utils.Flags.DeploymentPath == "" {
-		if _, err := os.Stat(path.Join(projectPath, utils.DeploymentFileNameYaml)); err == nil
{
-			utils.Flags.DeploymentPath = path.Join(projectPath, utils.DeploymentFileNameYaml)
-		} else if _, err := os.Stat(path.Join(projectPath, utils.DeploymentFileNameYml)); err ==
nil {
-			utils.Flags.DeploymentPath = path.Join(projectPath, utils.DeploymentFileNameYml)
+
+		if err := loadDefaultDeploymentFileFromProjectPath(wski18n.CMD_DEPLOY, projectPath); err
!= nil {
+			return err
 		}
 	}
 
@@ -209,7 +235,11 @@ func Deploy() error {
 		// master record of any dependency that has been downloaded
 		deployer.DependencyMaster = make(map[string]utils.DependencyRecord)
 
-		clientConfig, error := deployers.NewWhiskConfig(utils.Flags.CfgFile, utils.Flags.DeploymentPath,
utils.Flags.ManifestPath, deployer.IsInteractive)
+		clientConfig, error := deployers.NewWhiskConfig(
+			utils.Flags.CfgFile,
+			utils.Flags.DeploymentPath,
+			utils.Flags.ManifestPath,
+			deployer.IsInteractive)
 		if error != nil {
 			return error
 		}
@@ -250,10 +280,9 @@ func Deploy() error {
 
 func Undeploy() error {
 
+	// Convey flags for verbose and trace to Go client
 	whisk.SetVerbose(utils.Flags.Verbose)
-	// Verbose mode is the only mode for wskdeploy to turn on all the debug messages, so the
currenty Verbose mode
-	// also set debug mode to true.
-	whisk.SetDebug(utils.Flags.Verbose)
+	whisk.SetDebug(utils.Flags.Trace)
 
 	project_Path := strings.TrimSpace(utils.Flags.ProjectPath)
 	if len(project_Path) == 0 {
@@ -261,41 +290,17 @@ func Undeploy() error {
 	}
 	projectPath, _ := filepath.Abs(project_Path)
 
+	// If manifest filename is not provided, attempt to load default manifests from project
path
 	if utils.Flags.ManifestPath == "" {
-		if _, err := os.Stat(path.Join(projectPath, utils.ManifestFileNameYaml)); err == nil {
-			utils.Flags.ManifestPath = path.Join(projectPath, utils.ManifestFileNameYaml)
-			stdout = wski18n.T(wski18n.ID_MSG_MANIFEST_UNDEPLOY_X_path_X,
-				map[string]interface{}{wski18n.KEY_PATH: utils.Flags.ManifestPath})
-		} else if _, err := os.Stat(path.Join(projectPath, utils.ManifestFileNameYml)); err ==
nil {
-			utils.Flags.ManifestPath = path.Join(projectPath, utils.ManifestFileNameYml)
-			stdout = wski18n.T(wski18n.ID_MSG_MANIFEST_UNDEPLOY_X_path_X,
-				map[string]interface{}{wski18n.KEY_PATH: utils.Flags.ManifestPath})
-		} else {
-			stderr = wski18n.T(wski18n.ID_ERR_MANIFEST_FILE_NOT_FOUND_X_path_X,
-				map[string]interface{}{wski18n.KEY_PATH: projectPath})
-			return wskderrors.NewErrorManifestFileNotFound(projectPath, stderr)
+		if err := loadDefaultManifestFileFromProjectPath(wski18n.CMD_UNDEPLOY, projectPath); err
!= nil {
+			return err
 		}
-		wskprint.PrintlnOpenWhiskVerbose(utils.Flags.Verbose, stdout)
 	}
 
 	if utils.Flags.DeploymentPath == "" {
-		if _, err := os.Stat(path.Join(projectPath, utils.DeploymentFileNameYaml)); err == nil
{
-			utils.Flags.DeploymentPath = path.Join(projectPath, utils.DeploymentFileNameYaml)
-			// TODO() have a single function that conditionally (verbose) prints ALL Flags
-			dbgMsg := fmt.Sprintf("%s >> [%s]: [%s]",
-				wski18n.T(wski18n.ID_DEBUG_UNDEPLOYING_USING),
-				wski18n.DEPLOYMENT,
-				utils.Flags.DeploymentPath)
-			wskprint.PrintlnOpenWhiskVerbose(utils.Flags.Verbose, dbgMsg)
-
-		} else if _, err := os.Stat(path.Join(projectPath, utils.DeploymentFileNameYml)); err ==
nil {
-			utils.Flags.DeploymentPath = path.Join(projectPath, utils.DeploymentFileNameYml)
-			// TODO() have a single function that conditionally (verbose) prints ALL Flags
-			dbgMsg := fmt.Sprintf("%s >> [%s]: [%s]",
-				wski18n.T(wski18n.ID_DEBUG_UNDEPLOYING_USING),
-				wski18n.DEPLOYMENT,
-				utils.Flags.DeploymentPath)
-			wskprint.PrintlnOpenWhiskVerbose(utils.Flags.Verbose, dbgMsg)
+
+		if err := loadDefaultDeploymentFileFromProjectPath(wski18n.CMD_UNDEPLOY, projectPath);
err != nil {
+			return err
 		}
 	}
 
diff --git a/deployers/deploymentreader.go b/deployers/deploymentreader.go
index a31addd..ed31125 100644
--- a/deployers/deploymentreader.go
+++ b/deployers/deploymentreader.go
@@ -20,6 +20,7 @@ package deployers
 import (
 	"github.com/apache/incubator-openwhisk-client-go/whisk"
 	"github.com/apache/incubator-openwhisk-wskdeploy/parsers"
+	"github.com/apache/incubator-openwhisk-wskdeploy/utils"
 	"github.com/apache/incubator-openwhisk-wskdeploy/wskenv"
 	"github.com/apache/incubator-openwhisk-wskdeploy/wski18n"
 	"github.com/apache/incubator-openwhisk-wskdeploy/wskprint"
@@ -77,7 +78,7 @@ func (reader *DeploymentReader) getPackageMap() map[string]parsers.Package
{
 				wski18n.ID_DEBUG_PACKAGES_FOUND_UNDER_ROOT_X_path_X,
 				map[string]interface{}{
 					wski18n.KEY_PATH: reader.DeploymentDescriptor.Filepath})
-			wskprint.PrintlnOpenWhiskTrace(false, infoMsg)
+			wskprint.PrintlnOpenWhiskTrace(utils.Flags.Trace, infoMsg)
 			for packName, depPacks := range reader.DeploymentDescriptor.Packages {
 				depPacks.Packagename = packName
 				packMap[packName] = depPacks
@@ -90,7 +91,7 @@ func (reader *DeploymentReader) getPackageMap() map[string]parsers.Package
{
 			map[string]interface{}{
 				wski18n.KEY_PATH: reader.DeploymentDescriptor.Filepath,
 				wski18n.KEY_NAME: reader.DeploymentDescriptor.GetProject().Name})
-		wskprint.PrintlnOpenWhiskTrace(false, infoMsg)
+		wskprint.PrintlnOpenWhiskTrace(utils.Flags.Trace, infoMsg)
 
 		for packName, depPacks := range reader.DeploymentDescriptor.GetProject().Packages {
 			depPacks.Packagename = packName
@@ -349,5 +350,5 @@ func displayEntityFoundInDeploymentTrace(entityType string, entityName
string) {
 		map[string]interface{}{
 			wski18n.KEY_KEY:  entityType,
 			wski18n.KEY_NAME: entityName})
-	wskprint.PrintlnOpenWhiskTrace(true, infoMsg)
+	wskprint.PrintlnOpenWhiskTrace(utils.Flags.Trace, infoMsg)
 }
diff --git a/deployers/deploymentreader_test.go b/deployers/deploymentreader_test.go
index cc48f2c..1c6e52c 100644
--- a/deployers/deploymentreader_test.go
+++ b/deployers/deploymentreader_test.go
@@ -22,6 +22,8 @@ package deployers
 import (
 	"fmt"
 	"github.com/apache/incubator-openwhisk-client-go/whisk"
+	"github.com/apache/incubator-openwhisk-wskdeploy/utils"
+	"github.com/apache/incubator-openwhisk-wskdeploy/wskprint"
 	"github.com/stretchr/testify/assert"
 	"reflect"
 	"testing"
@@ -48,7 +50,8 @@ var deployment_file = "../tests/usecases/github/deployment.yaml"
 var manifest_file = "../tests/usecases/github/manifest.yaml"
 
 func init() {
-	// TODO(): setup "trace" flag here (and in all unit test files)
+	// Setup "trace" flag for unit tests based upon "go test" -v flag
+	utils.Flags.Trace = wskprint.DetectGoTestVerbose()
 }
 
 // Check DeploymentReader could handle deployment yaml successfully.
diff --git a/deployers/manifestreader_test.go b/deployers/manifestreader_test.go
index 39999d8..7d5acbc 100644
--- a/deployers/manifestreader_test.go
+++ b/deployers/manifestreader_test.go
@@ -22,6 +22,8 @@ package deployers
 import (
 	"github.com/apache/incubator-openwhisk-client-go/whisk"
 	"github.com/apache/incubator-openwhisk-wskdeploy/parsers"
+	"github.com/apache/incubator-openwhisk-wskdeploy/utils"
+	"github.com/apache/incubator-openwhisk-wskdeploy/wskprint"
 	"github.com/stretchr/testify/assert"
 	"testing"
 )
@@ -32,6 +34,9 @@ var ms *parsers.YAML
 
 func init() {
 
+	// Setup "trace" flag for unit tests based upon "go test" -v flag
+	utils.Flags.Trace = wskprint.DetectGoTestVerbose()
+
 	sd = NewServiceDeployer()
 	sd.ManifestPath = manifest_file
 	mr = NewManifestReader(sd)
diff --git a/parsers/manifest_parser.go b/parsers/manifest_parser.go
index f654cfa..63a55c1 100644
--- a/parsers/manifest_parser.go
+++ b/parsers/manifest_parser.go
@@ -809,7 +809,7 @@ func (dm *YAMLParser) ComposeTriggers(filePath string, pkg Package, ma
whisk.Key
 				map[string]interface{}{
 					wski18n.KEY_OLD:       YAML_KEY_SOURCE,
 					wski18n.KEY_NEW:       YAML_KEY_FEED,
-					wski18n.KEY_FILE_TYPE: wski18n.MANIFEST})
+					wski18n.KEY_FILE_TYPE: wski18n.MANIFEST_FILE})
 			wskprint.PrintOpenWhiskWarning(warningString)
 		}
 		if trigger.Feed == "" {
diff --git a/utils/flags.go b/utils/flags.go
index 89550b4..9232fc0 100644
--- a/utils/flags.go
+++ b/utils/flags.go
@@ -31,7 +31,6 @@ type WskDeployFlags struct {
 	CfgFile          string
 	CliVersion       string
 	CliBuild         string
-	Verbose          bool
 	ProjectPath      string
 	DeploymentPath   string
 	ManifestPath     string
@@ -42,6 +41,8 @@ type WskDeployFlags struct {
 	Managed          bool   // OpenWhisk Managed Deployments
 	ProjectName      string // Project name
 	ApigwAccessToken string
+	Verbose          bool
+	Trace            bool
 }
 
 func (flags *WskDeployFlags) Format() string {
diff --git a/wski18n/i18n_ids.go b/wski18n/i18n_ids.go
index bdde74b..ac08825 100644
--- a/wski18n/i18n_ids.go
+++ b/wski18n/i18n_ids.go
@@ -17,18 +17,18 @@
 
 package wski18n
 
-// descriptive key names
 // DO NOT TRANSLATE
+// descriptive key names
 const (
-	ACTION_CODE        = "Action source"
 	ACTIONS            = "Actions"
 	ACTIVATIONS        = "Activations"
 	API_HOST           = "API host"
+	APIGW_ACCESS_TOKEN = "API Gateway Access Token"
 	AUTH_KEY           = "authentication key"
 	COMMAND_LINE       = "wskdeploy command line"
-	DEPLOYMENT         = "deployment"
 	CONFIGURATION      = "Configuration"
-	MANIFEST           = "manifest"
+	DEPLOYMENT_FILE    = "deployment file"
+	MANIFEST_FILE      = "manifest file"
 	NAME_PROJECT       = "project name"
 	NAMESPACES         = "Namespaces"
 	PACKAGE_BINDING    = "package binding"
@@ -37,11 +37,44 @@ const (
 	PACKAGES           = "Packages"
 	RULES              = "Rules"
 	TRIGGER_FEED       = "trigger feed"
-	APIGW_ACCESS_TOKEN = "API Gateway Access Token"
+	CMD_DEPLOY         = "deploy"
+	CMD_UNDEPLOY       = "undeploy"
+	CMD_SYNC           = "sync"
+)
+
+// DO NOT TRANSLATE
+// Known keys used for text replacement in i18n translated strings
+const (
+	KEY_ACTION          = "action"
+	KEY_CMD             = "cmd"
+	KEY_CODE            = "code"
+	KEY_DEPLOYMENT_NAME = "dname"
+	KEY_DEPLOYMENT_PATH = "dpath"
+	KEY_ERR             = "err"
+	KEY_EXTENSION       = "ext"
+	KEY_FILE_TYPE       = "filetype"
+	KEY_HOST            = "host"
+	KEY_KEY             = "key"
+	KEY_LIMIT           = "limit"
+	KEY_MANIFEST_NAME   = "mname"
+	KEY_MANIFEST_PATH   = "mpath"
+	KEY_NAME            = "name"
+	KEY_NAMESPACE       = "namespace"
+	KEY_NEW             = "newkey"
+	KEY_OLD             = "oldkey"
+	KEY_PATH            = "path"
+	KEY_PROJECT         = "project"
+	KEY_RUNTIME         = "runtime"
+	KEY_SOURCE          = "source"
+	KEY_VALUE           = "value"
+	KEY_VALUE_MIN       = "min" // TODO() attempt to use this for Limit value range errors
+	KEY_VALUE_MAX       = "max" // TODO() attempt to use this for Limit value range errors
+	KEY_API             = "api"
+	KEY_URL             = "url"
 )
 
-// i18n Identifiers
 // DO NOT TRANSLATE
+// i18n Identifiers
 const (
 	// Debug / trace message prefixes
 	ID_MSG_PREFIX_ERROR   = "msg_prefix_error"   // "Error"
@@ -72,9 +105,12 @@ const (
 	ID_CMD_FLAG_NAMESPACE   = "msg_cmd_flag_namespace"
 	ID_CMD_FLAG_PROJECT     = "msg_cmd_flag_project"
 	ID_CMD_FLAG_STRICT      = "msg_cmd_flag_strict"
-	ID_CMD_FLAG_TOGGLE_HELP = "msg_cmd_flag_toggle_help"
+	ID_CMD_FLAG_TRACE       = "msg_cmd_flag_trace"
 	ID_CMD_FLAG_VERBOSE     = "msg_cmd_flag_allow_verbose"
 
+	// Root <command> using <manifest | deployment> file
+	ID_MSG_COMMAND_USING_X_cmd_X_filetype_X_path_X = "msg_command_using_filename_at_path"
+
 	// Configuration messages
 	ID_MSG_CONFIG_MISSING_AUTHKEY                       = "msg_config_missing_authkey"
 	ID_MSG_CONFIG_MISSING_APIHOST                       = "msg_config_missing_apihost"
@@ -99,9 +135,6 @@ const (
 	ID_MSG_UNDEPLOYMENT_FAILED    = "msg_undeployment_failed"
 	ID_MSG_UNDEPLOYMENT_SUCCEEDED = "msg_undeployment_succeeded"
 
-	ID_MSG_MANIFEST_DEPLOY_X_path_X   = "msg_manifest_using_deployment"
-	ID_MSG_MANIFEST_UNDEPLOY_X_path_X = "msg_manifest_using_undeployment"
-
 	ID_MSG_ENTITY_DEPLOYED_SUCCESS_X_key_X_name_X   = "msg_entity_deployed_success"
 	ID_MSG_ENTITY_DEPLOYING_X_key_X_name_X          = "msg_entity_deploying"
 	ID_MSG_ENTITY_UNDEPLOYED_SUCCESS_X_key_X_name_X = "msg_entity_undeployed_success"
@@ -171,44 +204,13 @@ const (
 	ID_WARN_PROJECT_NAME_OVERRIDDEN                           = "msg_warn_project_name_overridden"
 
 	// Verbose (Debug/Trace) messages
-	ID_DEBUG_DEPLOYING_USING                              = "msg_dbg_deploying_using"
-	ID_DEBUG_UNDEPLOYING_USING                            = "msg_dbg_undeploying_using"
 	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"
 )
 
-// Known keys used for text replacement in i18n translated strings
-const (
-	KEY_ACTION          = "action"
-	KEY_CMD             = "cmd"
-	KEY_CODE            = "code"
-	KEY_DEPLOYMENT_NAME = "dname"
-	KEY_DEPLOYMENT_PATH = "dpath"
-	KEY_ERR             = "err"
-	KEY_EXTENSION       = "ext"
-	KEY_FILE_TYPE       = "filetype"
-	KEY_HOST            = "host"
-	KEY_KEY             = "key"
-	KEY_LIMIT           = "limit"
-	KEY_MANIFEST_NAME   = "mname"
-	KEY_MANIFEST_PATH   = "mpath"
-	KEY_NAME            = "name"
-	KEY_NAMESPACE       = "namespace"
-	KEY_NEW             = "newkey"
-	KEY_OLD             = "oldkey"
-	KEY_PATH            = "path"
-	KEY_PROJECT         = "project"
-	KEY_RUNTIME         = "runtime"
-	KEY_SOURCE          = "source"
-	KEY_VALUE           = "value"
-	KEY_VALUE_MIN       = "min" // TODO() attempt to use this for Limit value range errors
-	KEY_VALUE_MAX       = "max" // TODO() attempt to use this for Limit value range errors
-	KEY_API             = "api"
-	KEY_URL             = "url"
-)
-
+// DO NOT TRANSLATE
 // Used to unit test that translations exist with these IDs
 var I18N_ID_SET = [](string){
 	ID_CMD_DESC_LONG_REPORT,
@@ -226,19 +228,17 @@ 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,
+	ID_CMD_FLAG_PROJECTNAME,
 	ID_CMD_FLAG_STRICT,
-	ID_CMD_FLAG_TOGGLE_HELP,
+	ID_CMD_FLAG_TRACE,
 	ID_CMD_FLAG_VERBOSE,
-	ID_DEBUG_DEPLOYING_USING,
 	ID_DEBUG_DEPLOYMENT_NAME_FOUND_X_key_X_name_X,
 	ID_DEBUG_PACKAGES_FOUND_UNDER_PROJECT_X_path_X_name_X,
 	ID_DEBUG_PACKAGES_FOUND_UNDER_ROOT_X_path_X,
 	ID_DEBUG_PROJECT_SEARCH_X_path_X_key_X,
-	ID_DEBUG_UNDEPLOYING_USING,
 	ID_ERR_DEPENDENCY_UNKNOWN_TYPE,
 	ID_ERR_ENTITY_CREATE_X_key_X_err_X_code_X,
 	ID_ERR_ENTITY_DELETE_X_key_X_err_X_code_X,
@@ -252,6 +252,7 @@ var I18N_ID_SET = [](string){
 	ID_ERR_RUNTIMES_GET_X_err_X,
 	ID_ERR_URL_INVALID_X_urltype_X_url_X_filetype_X,
 	ID_ERR_URL_MALFORMED_X_urltype_X_url_X,
+	ID_MSG_COMMAND_USING_X_cmd_X_filetype_X_path_X,
 	ID_MSG_CONFIG_INFO_APIHOST_X_host_X_source_X,
 	ID_MSG_CONFIG_INFO_AUTHKEY_X_source_X,
 	ID_MSG_CONFIG_INFO_NAMESPACE_X_namespace_X_source_X,
@@ -274,8 +275,6 @@ var I18N_ID_SET = [](string){
 	ID_MSG_ENTITY_UNDEPLOYING_X_key_X_name_X,
 	ID_MSG_MANAGED_FOUND_DELETED_X_key_X_name_X_project_X,
 	ID_MSG_MANAGED_UNDEPLOYMENT_FAILED,
-	ID_MSG_MANIFEST_DEPLOY_X_path_X,
-	ID_MSG_MANIFEST_UNDEPLOY_X_path_X,
 	ID_MSG_PREFIX_ERROR,
 	ID_MSG_PREFIX_INFO,
 	ID_MSG_PREFIX_SUCCESS,
diff --git a/wski18n/i18n_resources.go b/wski18n/i18n_resources.go
index e7f3242..f8a3835 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(1520374115, 0)}
+	info := bindataFileInfo{name: "wski18n/resources/de_DE.all.json", size: 0, mode: os.FileMode(420),
modTime: time.Unix(1515697090, 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\x5b\x6d\x6f\xdc\x36\xf2\x7f\x9f\x4f\x31\x08\xfe\x40\x5a\x60\xa3\xa4\xfd\xe3\x80\x43\x00\xe3\x90\xbb\xa4\xad\xaf\x4d\x1c\xd8\xc9\x05\x45\x6a\x28\x5c\x71\x76\x97\xb5\x44\x0a\x24\xe5\xcd\xd6\xf0\x77\x3f\x0c\x1f\x24\xed\xda\x94\xe8\x4d\x8b\xeb\x9b\x6e\xc2\xe1\xcc\x6f\x86\xe4\x3c\x2a\x9f\x1e\x01\xdc\x3c\x02\x00\x78\x2c\xf8\xe3\x17\xf0\xb8\x31\xeb\xb2\xd5\xb8\x12\x5f\x4a\xd4\x5a\xe9\xc7\x0b\xbf\x6a\x35\x93
[...]
+var _wski18nResourcesEn_usAllJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xc4\x5b\x6f\x8f\xdb\x36\xd2\x7f\x9f\x4f\x31\x08\x1e\x20\x2d\xe0\x28\x69\x1f\x1c\x70\x08\xb0\x38\xe4\x2e\x69\xbb\xd7\x26\x1b\xec\x26\x17\x14\xe9\x42\xa1\xc5\xb1\xcd\x5a\x22\x05\x92\xb2\xe3\x1a\xfe\xee\x87\xe1\x1f\x49\xf6\x2e\x25\xad\xd3\xe2\xf2\xa6\x6e\x38\x9c\xf9\xcd\x90\xfc\x71\x66\xa8\x7c\x7a\x04\xb0\x7f\x04\x00\xf0\x58\xf0\xc7\x2f\xe0\x71\x65\x96\x79\xad\x71\x21\xbe\xe4\xa8\xb5\xd2\x8f\x67\x7e\xd4\x6a
[...]
 
 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: 14026, mode: os.FileMode(420),
modTime: time.Unix(1520537404, 0)}
+	info := bindataFileInfo{name: "wski18n/resources/en_US.all.json", size: 13733, mode: os.FileMode(420),
modTime: time.Unix(1520546400, 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(1520374115, 0)}
+	info := bindataFileInfo{name: "wski18n/resources/es_ES.all.json", size: 0, mode: os.FileMode(420),
modTime: time.Unix(1515697090, 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(1520374115, 0)}
+	info := bindataFileInfo{name: "wski18n/resources/fr_FR.all.json", size: 101, mode: os.FileMode(420),
modTime: time.Unix(1515697090, 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(1520374115, 0)}
+	info := bindataFileInfo{name: "wski18n/resources/it_IT.all.json", size: 0, mode: os.FileMode(420),
modTime: time.Unix(1515697090, 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(1520374115, 0)}
+	info := bindataFileInfo{name: "wski18n/resources/ja_JA.all.json", size: 0, mode: os.FileMode(420),
modTime: time.Unix(1515697090, 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(1520374115, 0)}
+	info := bindataFileInfo{name: "wski18n/resources/ko_KR.all.json", size: 0, mode: os.FileMode(420),
modTime: time.Unix(1515697090, 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(1520374115, 0)}
+	info := bindataFileInfo{name: "wski18n/resources/pt_BR.all.json", size: 0, mode: os.FileMode(420),
modTime: time.Unix(1515697090, 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(1520374115, 0)}
+	info := bindataFileInfo{name: "wski18n/resources/zh_Hans.all.json", size: 0, mode: os.FileMode(420),
modTime: time.Unix(1515697090, 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(1520374115, 0)}
+	info := bindataFileInfo{name: "wski18n/resources/zh_Hant.all.json", size: 0, mode: os.FileMode(420),
modTime: time.Unix(1515697090, 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 94482f5..6370f94 100644
--- a/wski18n/resources/en_US.all.json
+++ b/wski18n/resources/en_US.all.json
@@ -96,8 +96,8 @@
     "translation": "allow user defined runtime version"
   },
   {
-    "id": "msg_cmd_flag_toggle_help",
-    "translation": "Toggle Help message"
+    "id": "msg_cmd_flag_trace",
+    "translation": "trace output"
   },
   {
     "id": "msg_cmd_flag_allow_verbose",
@@ -168,12 +168,8 @@
     "translation": "Undeployment completed successfully.\n"
   },
   {
-    "id": "msg_manifest_using_deployment",
-    "translation": "Using [{{.path}}] for deployment.\n"
-  },
-  {
-    "id": "msg_manifest_using_undeployment",
-    "translation": "Using [{{.path}}] for undeployment.\n"
+    "id": "msg_command_using_filename_at_path",
+    "translation": "{{.cmd}} using {{.filetype}} [{{.path}}]...\n"
   },
   {
     "id": "msg_entity_deployed_success",
@@ -189,7 +185,7 @@
   },
   {
     "id": "msg_entity_undeploying",
-    "translation": "Undeploying {{.key}} [{{.name}}] ..."
+    "translation": "Undeploying {{.key}} [{{.name}}]..."
   },
   {
     "id": "msg_dependency_deploying",
@@ -341,7 +337,7 @@
   },
   {
     "id": "msg_warn_key_deprecated_replaced",
-    "translation": "The [{{.oldkey}}] key in the {{.filetype}} file will soon be deprecated,
please use the [{{.newkey}}] key instead.\n"
+    "translation": "The [{{.oldkey}}] key in the {{.filetype}} will soon be deprecated, please
use the [{{.newkey}}] key instead.\n"
   },
   {
     "id": "msg_warn_key_missing",
@@ -408,14 +404,6 @@
     "translation": "================= DEBUG ==================="
   },
   {
-    "id": "msg_dbg_deploying_using",
-    "translation": "Deploying using:\n"
-  },
-  {
-    "id": "msg_dbg_undeploying_using",
-    "translation": "Undeploying using:\n"
-  },
-  {
     "id": "msg_dbg_searching_project_directory",
     "translation": "Searching project directory [{{.path}}] for [{{.key}}]...\n"
   },
diff --git a/wskprint/console.go b/wskprint/console.go
index 6e74565..62228bc 100644
--- a/wskprint/console.go
+++ b/wskprint/console.go
@@ -23,6 +23,8 @@ import (
 	"github.com/fatih/color"
 	"github.com/mattn/go-colorable"
 	"os"
+	"path/filepath"
+	"runtime"
 	"strings"
 )
 
@@ -104,16 +106,26 @@ func PrintlnOpenWhiskVerbose(verbose bool, message string) {
 	PrintOpenWhiskVerbose(verbose, message+"\n")
 }
 
+func PrintlnOpenWhiskTrace(trace bool, message string) {
+
+	if trace {
+		_, fname, lineNum, _ := runtime.Caller(2)
+		out := fmt.Sprintf("%s [%v]: %s\n", filepath.Base(fname), lineNum, message)
+		PrintOpenWhiskVerbose(trace, out)
+	}
+}
+
 // Display "trace" output if either param is true OR we are running Go test verbose (i.e.,
"go test -v")
-// arg[0] = [/var/folders/nj/2blqqtm500l5ch2d5k0hvqvm0000gn/T/go-build041478919/github.com/apache/incubator-openwhisk-wskdeploy/deployers/_test/deployers.test
+// Typical Args for "go test" looks as follows:
+// arg[0] = [/var/folders/nj/<uuid>/T/<build-id>/github.com/apache/incubator-openwhisk-wskdeploy/deployers/_test/deployers.test
 // arg[1] = -test.v=true
 // arg[2] = -test.run=TestDeploymentReader_PackagesBindTrigger]
-// TODO() introduce "trace" as an optional flag (perhaps hidden or picked up from environment)
-func PrintlnOpenWhiskTrace(trace bool, message string) {
-	GO_TEST_VERBOSE := false
-	if len(os.Args) >= 2 {
-		// TODO() move this to an init() routine
-		GO_TEST_VERBOSE = strings.Contains(os.Args[1], "-test.v=true")
+func DetectGoTestVerbose() bool {
+	arguments := os.Args
+	for i := range arguments {
+		if strings.HasPrefix(arguments[i], "-test.v=true") {
+			return true
+		}
 	}
-	PrintOpenWhiskVerbose(GO_TEST_VERBOSE || trace, message+"\n")
+	return false
 }

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

Mime
View raw message