You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ho...@apache.org on 2018/01/25 03:14:06 UTC
[incubator-openwhisk-wskdeploy] branch master updated: Move all
hardcoded strings from Cobra commands and remaining .go files into i18n
files. (#688)
This is an automated email from the ASF dual-hosted git repository.
houshengbo 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 de315bc Move all hardcoded strings from Cobra commands and remaining .go files into i18n files. (#688)
de315bc is described below
commit de315bcaa8d6e4b7404415ba3460d3c9a8f672fd
Author: Matt Rutkowski <mr...@us.ibm.com>
AuthorDate: Wed Jan 24 21:14:03 2018 -0600
Move all hardcoded strings from Cobra commands and remaining .go files into i18n files. (#688)
* Move all hardcoded strings from Cobra commands into i18n files.
* Continue adding missing strings and use i18n constants.
* Continue adding missing strings and use i18n constants.
* Continue adding missing strings and use i18n constants.
* Continue moving hardcoded strings to i18n files.
* ignore IDEA project file *.iml
* Update hardcoded strings from deploymentreader.go to i18n.
* Update hardcoded strings from deploymentreader.go to i18n.
* Update hardcoded strings from deploymentreader.go to i18n.
* Update hardcoded strings from manifest_parser.go to i18n.
* Update hardcoded strings from whiskclient.go to i18n.
* Update hardcoded strings from root.go, whiskclient.go to i18n.
* Update hardcoded strings from report.go, publish.go to i18n.
* Update hardcoded debug messages in whiskclient.go to i18n.
* Make (wskdeploy) Flags a Type and not just an anon. struct.
* More i18n for add, version, publish.go plus Flag trace output.
* More i18n for add, version, publish.go plus Flag trace output.
* Move descriptive strings from yamlparser.go to wski18n_ids.go.
* Update color library to v1.5
* Rewrite add.go to use i18n.
* Rewrite report.go to use i18n.
* Rewrite filesystemreader.go to use i18n.
* Rewrite servicedeployer.go to use i18n.
---
.gitignore | 3 +-
Godeps/Godeps.json | 4 +-
cmd/add.go | 58 ++++---
cmd/publish.go | 82 ++++++----
cmd/report.go | 132 +++++++++-------
cmd/root.go | 105 ++++++------
cmd/version.go | 17 +-
deployers/deploymentreader.go | 59 +++++--
deployers/filesystemreader.go | 57 ++++---
deployers/manifestreader_test.go | 2 +-
deployers/servicedeployer.go | 149 +++++++++---------
deployers/verifier.go | 3 +
deployers/whiskclient.go | 138 +++++++++-------
deployers/whiskclient_test.go | 102 ++++++------
parsers/manifest_parser.go | 102 +++++++-----
parsers/yamlparser.go | 28 ++--
utils/flags.go | 43 +++--
utils/runtimes.go | 2 +-
utils/validation.go | 2 +
wski18n/i18n_ids.go | 333 +++++++++++++++++++++++++--------------
wski18n/i18n_resources.go | 4 +-
wski18n/resources/en_US.all.json | 312 ++++++++++++++++++++++++++----------
wskprint/console.go | 58 ++++---
23 files changed, 1126 insertions(+), 669 deletions(-)
diff --git a/.gitignore b/.gitignore
index dcf046a..73345b7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,8 +32,9 @@ openwhisk-wskdeploy
incubator-openwhisk-wskdeploy
wskdeploy
-#GoGlanD IDE
+# Go IDE
.idea
+*.iml
# Gradle
.gradle
diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json
index 0608803..4576bf6 100644
--- a/Godeps/Godeps.json
+++ b/Godeps/Godeps.json
@@ -9,8 +9,8 @@
},
{
"ImportPath": "github.com/fatih/color",
- "Comment": "v1.1.0-4-gbf82308",
- "Rev": "bf82308e8c8546dc2b945157173eb8a959ae9505"
+ "Comment": "v1.5.0",
+ "Rev": "570b54cabe6b8eb0bc2dfce68d964677d63b5260"
},
{
"ImportPath": "github.com/fsnotify/fsnotify",
diff --git a/cmd/add.go b/cmd/add.go
index d18a86d..24eab52 100644
--- a/cmd/add.go
+++ b/cmd/add.go
@@ -19,25 +19,26 @@ package cmd
import (
"bufio"
- "fmt"
"os"
-
+ "github.com/spf13/cobra"
"github.com/apache/incubator-openwhisk-wskdeploy/parsers"
"github.com/apache/incubator-openwhisk-wskdeploy/utils"
- "github.com/spf13/cobra"
+ "github.com/apache/incubator-openwhisk-wskdeploy/wski18n"
+ "github.com/apache/incubator-openwhisk-wskdeploy/wskprint"
)
// addCmd represents the add command
var addCmd = &cobra.Command{
- Use: "add",
- SuggestFor: []string {"increase"},
- Short: "Add an action, feed, trigger or rule to the manifest",
+ Use: "add",
+ SuggestFor: []string {"insert"},
+ Short: wski18n.T(wski18n.ID_CMD_DESC_SHORT_ADD),
}
// action represents the `add action` command
var actionCmd = &cobra.Command{
Use: "action",
- Short: "add action to the manifest file and create default directory structure.",
+ Short: wski18n.T(wski18n.ID_CMD_DESC_SHORT_ADD_X_key_X,
+ map[string]interface{}{wski18n.KEY_KEY: parsers.YAML_KEY_ACTION}),
RunE: func(cmd *cobra.Command, args []string) error {
maniyaml, err := parsers.ReadOrCreateManifest()
if err != nil {
@@ -48,16 +49,23 @@ var actionCmd = &cobra.Command{
action := parsers.Action{}
for {
- action.Name = utils.Ask(reader, "Name", "")
+ action.Name = utils.Ask(reader, wski18n.NAME_ACTION, "")
// Check action name is unique
if _, ok := maniyaml.Package.Actions[action.Name]; !ok {
break
}
- fmt.Print(action.Name + " is already used. Pick another action name\n")
+
+ warnMsg := wski18n.T(wski18n.ID_WARN_ENTITY_NAME_EXISTS_X_key_X_name_X,
+ map[string]interface{}{
+ wski18n.KEY_KEY: parsers.YAML_KEY_ACTION,
+ wski18n.KEY_NAME: action.Name})
+ wskprint.PrintOpenWhiskWarning(warnMsg)
}
- action.Runtime = utils.Ask(reader, "Runtime", "nodejs:6")
+ // TODO() use dynamic/programmatic way to get default runtime (not hardcoded)
+ // TODO() And List all supported runtime names (values) (via API)
+ action.Runtime = utils.Ask(reader, wski18n.NAME_RUNTIME, "nodejs:6")
maniyaml.Package.Actions[action.Name] = action
// Create directory structure before update manifest, as a way
@@ -75,7 +83,8 @@ var actionCmd = &cobra.Command{
// trigger represents the `add trigger` command
var triggerCmd = &cobra.Command{
Use: "trigger",
- Short: "add trigger to the manifest file.",
+ Short: wski18n.T(wski18n.ID_CMD_DESC_SHORT_ADD_X_key_X,
+ map[string]interface{}{wski18n.KEY_KEY: parsers.YAML_KEY_TRIGGER}),
RunE: func(cmd *cobra.Command, args []string) error {
maniyaml, err := parsers.ReadOrCreateManifest()
if err != nil {
@@ -86,16 +95,21 @@ var triggerCmd = &cobra.Command{
trigger := parsers.Trigger{}
for {
- trigger.Name = utils.Ask(reader, "Name", "")
+ trigger.Name = utils.Ask(reader, wski18n.NAME_TRIGGER, "")
// Check trigger name is unique
if _, ok := maniyaml.Package.Triggers[trigger.Name]; !ok {
break
}
- fmt.Print(trigger.Name + " is already used. Pick another trigger name\n")
+
+ warnMsg := wski18n.T(wski18n.ID_WARN_ENTITY_NAME_EXISTS_X_key_X_name_X,
+ map[string]interface{}{
+ wski18n.KEY_KEY: parsers.YAML_KEY_TRIGGER,
+ wski18n.KEY_NAME: trigger.Name})
+ wskprint.PrintOpenWhiskWarning(warnMsg)
}
- trigger.Feed = utils.Ask(reader, "Feed", "")
+ trigger.Feed = utils.Ask(reader, wski18n.NAME_FEED, "")
maniyaml.Package.Triggers[trigger.Name] = trigger
return parsers.Write(maniyaml, utils.ManifestFileNameYaml)
@@ -105,7 +119,8 @@ var triggerCmd = &cobra.Command{
// rule represents the `add rule` command
var ruleCmd = &cobra.Command{
Use: "rule",
- Short: "add rule to the manifest file.",
+ Short: wski18n.T(wski18n.ID_CMD_DESC_SHORT_ADD_X_key_X,
+ map[string]interface{}{wski18n.KEY_KEY: parsers.YAML_KEY_RULE}),
RunE: func(cmd *cobra.Command, args []string) error {
maniyaml, err := parsers.ReadOrCreateManifest()
if err != nil {
@@ -116,17 +131,22 @@ var ruleCmd = &cobra.Command{
rule := parsers.Rule{}
for {
- rule.Rule = utils.Ask(reader, "Rule Name", "")
+ rule.Rule = utils.Ask(reader, wski18n.NAME_RULE, "")
// Check rule name is unique
if _, ok := maniyaml.Package.Triggers[rule.Rule]; !ok {
break
}
- fmt.Print(rule.Rule + " is already used. Pick another rule name\n")
+
+ warnMsg := wski18n.T(wski18n.ID_WARN_ENTITY_NAME_EXISTS_X_key_X_name_X,
+ map[string]interface{}{
+ wski18n.KEY_KEY: parsers.YAML_KEY_RULE,
+ wski18n.KEY_NAME: rule.Name})
+ wskprint.PrintOpenWhiskWarning(warnMsg)
}
- rule.Action = utils.Ask(reader, "Action", "")
- rule.Trigger = utils.Ask(reader, "Trigger", "")
+ rule.Action = utils.Ask(reader, wski18n.NAME_ACTION, "")
+ rule.Trigger = utils.Ask(reader, wski18n.NAME_TRIGGER, "")
maniyaml.Package.Rules[rule.Rule] = rule
return parsers.Write(maniyaml, utils.ManifestFileNameYaml)
diff --git a/cmd/publish.go b/cmd/publish.go
index ff0a4aa..22020ba 100644
--- a/cmd/publish.go
+++ b/cmd/publish.go
@@ -18,60 +18,72 @@
package cmd
import (
- "fmt"
-
"bufio"
- "github.com/apache/incubator-openwhisk-wskdeploy/parsers"
- "github.com/apache/incubator-openwhisk-wskdeploy/utils"
- "github.com/spf13/cobra"
"net/http"
"net/url"
"os"
"path"
"strings"
+ "github.com/spf13/cobra"
+ "github.com/apache/incubator-openwhisk-wskdeploy/parsers"
+ "github.com/apache/incubator-openwhisk-wskdeploy/utils"
+ "github.com/apache/incubator-openwhisk-wskdeploy/wski18n"
+ "github.com/apache/incubator-openwhisk-wskdeploy/wskprint"
)
// publishCmd represents the publish command
var publishCmd = &cobra.Command{
- Use: "publish",
- SuggestFor: []string {"publicize"},
- Short: "Publish a package to a registry",
- Long: `Publish a package to the registry set in ~/.wskprops`,
+ Use: "publish",
+ SuggestFor: []string{"publicize"},
+ Short: wski18n.T(wski18n.ID_CMD_DESC_SHORT_PUBLISH),
+ Long: wski18n.T(wski18n.ID_CMD_DESC_LONG_PUBLISH),
RunE: func(cmd *cobra.Command, args []string) error {
// Get registry location
-
userHome := utils.GetHomeDirectory()
propPath := path.Join(userHome, ".wskprops")
configs, err := utils.ReadProps(propPath)
if err != nil {
- return err
- }
+ return err
+ }
registry, ok := configs["REGISTRY"]
if !ok {
+ wskprint.PrintOpenWhiskError(
+ wski18n.T(wski18n.ID_ERR_URL_INVALID_X_urltype_X_url_X_filetype_X,
+ map[string]interface{}{
+ wski18n.KEY_URL_TYPE: wski18n.REGISTRY,
+ wski18n.KEY_URL: "",
+ wski18n.KEY_FILE_TYPE: wski18n.WHISK_PROPS}))
+
+ // TODO() should only read if interactive mode is on
reader := bufio.NewReader(os.Stdin)
- fmt.Print("Registry URL not found in ~./wskprops. Must be set before publishing.\n")
for {
- registry = utils.Ask(reader, "Registry URL", "")
+ registry = utils.Ask(reader, wski18n.REGISTRY_URL, "")
_, err := url.Parse(registry)
if err == nil {
- // TODO: send request to registry to check it exists.
+ // TODO() send request to registry to check if it exists.
break
}
- fmt.Print("Malformed repository URL. Try again")
+ // Tell user the URL they entered was invalid, try again...
+ wskprint.PrintOpenWhiskError(
+ wski18n.T(wski18n.ID_ERR_URL_MALFORMED_X_urltype_X_url_X,
+ map[string]interface{}{
+ wski18n.KEY_URL_TYPE: wski18n.REGISTRY,
+ wski18n.KEY_URL: registry}))
}
+
configs["REGISTRY"] = registry
utils.WriteProps(propPath, configs)
}
// Get repo URL
maniyaml, err := parsers.ReadOrCreateManifest()
- if err != nil {
- return err
- }
+ if err != nil {
+ return err
+ }
if len(maniyaml.Package.Repositories) > 0 {
repoURL := maniyaml.Package.Repositories[0].Url
@@ -79,28 +91,38 @@ var publishCmd = &cobra.Command{
paths := strings.Split(repoURL, "/")
l := len(paths)
if l < 2 {
- fmt.Print("Fatal error: malformed repository URL in manifest file :" + repoURL)
+ wskprint.PrintOpenWhiskError(
+ wski18n.T(wski18n.ID_ERR_URL_INVALID_X_urltype_X_url_X_filetype_X,
+ map[string]interface{}{
+ wski18n.KEY_URL_TYPE: wski18n.REPOSITORY,
+ wski18n.KEY_URL: repoURL,
+ wski18n.KEY_FILE_TYPE: wski18n.MANIFEST}))
return nil
}
- repo := paths[l-1]
- owner := paths[l-2]
+ repo := paths[l - 1]
+ owner := paths[l - 2]
// Send HTTP request
client := &http.Client{}
- request, err := http.NewRequest("PUT", registry+"?owner="+owner+"&repo="+repo, nil)
+ request, err := http.NewRequest("PUT", registry + "?owner=" + owner + "&repo=" + repo, nil)
if err != nil {
- return err
- }
+ return err
+ }
_, err = client.Do(request)
- if err != nil {
- return err
- }
+ if err != nil {
+ return err
+ }
} else {
- fmt.Print("Fatal error: missing repository URL in manifest file.")
+ wskprint.PrintOpenWhiskError(
+ wski18n.T(wski18n.ID_ERR_URL_INVALID_X_urltype_X_url_X_filetype_X,
+ map[string]interface{}{
+ wski18n.KEY_URL_TYPE: wski18n.REPOSITORY,
+ wski18n.KEY_URL: "",
+ wski18n.KEY_FILE_TYPE: wski18n.MANIFEST}))
}
- return nil
+ return nil
},
}
diff --git a/cmd/report.go b/cmd/report.go
index 0bc5645..37a361d 100644
--- a/cmd/report.go
+++ b/cmd/report.go
@@ -19,16 +19,15 @@ package cmd
import (
"fmt"
+ "path"
+ "sync"
+ "os"
+ "github.com/spf13/cobra"
+ "github.com/apache/incubator-openwhisk-wskdeploy/wskprint"
"github.com/apache/incubator-openwhisk-client-go/whisk"
"github.com/apache/incubator-openwhisk-wskdeploy/deployers"
"github.com/apache/incubator-openwhisk-wskdeploy/utils"
"github.com/apache/incubator-openwhisk-wskdeploy/wski18n"
- "github.com/fatih/color"
- "github.com/spf13/cobra"
- "path"
- "sync"
- "os"
- "github.com/apache/incubator-openwhisk-wskdeploy/wskprint"
)
var wskpropsPath string
@@ -38,31 +37,34 @@ var wg sync.WaitGroup
// reportCmd represents the report command
var reportCmd = &cobra.Command{
- Use: "report",
- SuggestFor: []string {"list"},
- Short: "Returns summary of what's been deployed on OpenWhisk in specific namespace",
- Long: `Command helps user get an overall report about what's been deployed
-on OpenWhisk with specific OpenWhisk namespace. By default it will read the wsk property file
-located under current user home.`,
+ Use: "report",
+ SuggestFor: []string{"list"},
+ Short: wski18n.T(wski18n.ID_CMD_DESC_SHORT_REPORT),
RunE: func(cmd *cobra.Command, args []string) error {
if wskpropsPath != "" {
config, _ := deployers.NewWhiskConfig(wskpropsPath, utils.Flags.DeploymentPath, utils.Flags.ManifestPath, false)
- client, _ := deployers.CreateNewClient(config)
- return printDeploymentInfo(client)
+ client, _ := deployers.CreateNewClient(config)
+ return printDeploymentInfo(client)
} else {
- //default to ~/.wskprops
- userHome := utils.GetHomeDirectory()
- propPath := path.Join(userHome, ".wskprops")
- config, _ := deployers.NewWhiskConfig(propPath, utils.Flags.DeploymentPath, utils.Flags.ManifestPath, false)
- client, _ := deployers.CreateNewClient(config)
- return printDeploymentInfo(client)
- }
+ //default to ~/.wskprops
+ userHome := utils.GetHomeDirectory()
+ // TODO() we should not only use const. for config files like .wskprops, but have a dedicated
+ // set of functions in its own package to interact with it as a resource
+ propPath := path.Join(userHome, ".wskprops")
+ config, _ := deployers.NewWhiskConfig(propPath, utils.Flags.DeploymentPath, utils.Flags.ManifestPath, false)
+ client, _ := deployers.CreateNewClient(config)
+ return printDeploymentInfo(client)
+ }
},
}
func init() {
RootCmd.AddCommand(reportCmd)
- reportCmd.Flags().StringVarP(&wskpropsPath, "wskproppath", "w", path.Join(os.Getenv("HOME"), ".wskprops"), "path to wsk property file, default is to ~/.wskprops")
+
+ // TODO() REMOVE this flag... the flag -config exists already
+ reportCmd.Flags().StringVarP(&wskpropsPath, "wskproppath", "w",
+ path.Join(os.Getenv("HOME"), ".wskprops"),
+ wski18n.T(wski18n.ID_CMD_FLAG_CONFIG))
// Here you will define your flags and configuration settings.
@@ -73,23 +75,19 @@ func init() {
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// reportCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
-
}
-var boldString = color.New(color.Bold).SprintFunc()
-
func printDeploymentInfo(client *whisk.Client) error {
//We currently list packages, actions, triggers, rules.
wg.Add(4)
- // TODO() i18n
- wskprint.PrintlnOpenWhiskStatus("----==== OpenWhisk Deployment Status ====----")
+ wskprint.PrintlnOpenWhiskInfo(wski18n.T(wski18n.ID_MSG_DEPLOYMENT_REPORT))
// we set the default package list options
pkgoptions := &whisk.PackageListOptions{false, 0, 0, 0, false}
packages, _, err := client.Packages.List(pkgoptions)
- if err != nil {
- return err
- }
+ if err != nil {
+ return err
+ }
// list all packages under current namespace.
go func() {
@@ -103,24 +101,24 @@ func printDeploymentInfo(client *whisk.Client) error {
acnoptions := &whisk.ActionListOptions{0, 0, false}
for _, pkg := range packages {
actions, _, err := client.Actions.List(pkg.Name, acnoptions)
- if err != nil {
- return err
- }
+ if err != nil {
+ return err
+ }
printActionList(actions)
}
- return nil
+ return nil
}()
// list all the triggers under current namespace.
go func() error {
defer wg.Done()
troptions := &whisk.TriggerListOptions{0, 0, false}
- _, _, err := client.Triggers.List(troptions)
- if err != nil {
- return err
- }
+ _, _, err := client.Triggers.List(troptions)
+ if err != nil {
+ return err
+ }
//printTriggerList(triggers)
- return nil
+ return nil
}()
// list all the rules under current namespace.
@@ -128,11 +126,11 @@ func printDeploymentInfo(client *whisk.Client) error {
defer wg.Done()
roptions := &whisk.RuleListOptions{0, 0, false}
rules, _, err := client.Rules.List(roptions)
- if err != nil {
- return err
- }
+ if err != nil {
+ return err
+ }
printRuleList(rules)
- return nil
+ return nil
}()
wg.Wait()
@@ -146,6 +144,7 @@ func printList(collection interface{}) {
switch collection := collection.(type) {
case []whisk.Action:
printActionList(collection)
+ // TODO()
//case []whisk.Trigger
// printTriggerList(collection)
case []whisk.Package:
@@ -159,43 +158,58 @@ func printList(collection interface{}) {
}
}
+// TODO() i18n private / shared never translated
func printRuleList(rules []whisk.Rule) {
- fmt.Fprintf(color.Output, "%s\n", boldString("rules"))
+ wskprint.PrintlnOpenWhiskInfoTitle(wski18n.RULES)
+
for _, rule := range rules {
publishState := wski18n.T("private")
if *rule.Publish {
publishState = wski18n.T("shared")
}
- fmt.Printf("%-70s %s\n", fmt.Sprintf("/%s/%s", rule.Namespace, rule.Name), publishState)
+ output := fmt.Sprintf("%-70s %s\n",
+ fmt.Sprintf("/%s/%s", rule.Namespace, rule.Name),
+ publishState)
+ wskprint.PrintlnOpenWhiskInfo(output)
}
}
+// TODO() i18n private / shared never translated
func printPackageList(packages []whisk.Package) {
- fmt.Fprintf(color.Output, "%s\n", boldString("packages"))
+ wskprint.PrintlnOpenWhiskInfoTitle(wski18n.PACKAGES)
for _, xPackage := range packages {
publishState := wski18n.T("private")
if *xPackage.Publish {
publishState = wski18n.T("shared")
}
- fmt.Printf("%-70s %s\n", fmt.Sprintf("/%s/%s", xPackage.Namespace, xPackage.Name), publishState)
+ output := fmt.Sprintf("%-70s %s\n",
+ fmt.Sprintf("/%s/%s", xPackage.Namespace, xPackage.Name),
+ publishState)
+ wskprint.PrintlnOpenWhiskInfo(output)
}
}
+// TODO() i18n private / shared never translated
func printActionList(actions []whisk.Action) {
- fmt.Fprintf(color.Output, "%s\n", boldString("actions"))
+ wskprint.PrintlnOpenWhiskInfoTitle(wski18n.ACTIONS)
for _, action := range actions {
publishState := wski18n.T("private")
if *action.Publish {
publishState = wski18n.T("shared")
}
kind := getValueString(action.Annotations, "exec")
- fmt.Printf("%-70s %s %s\n", fmt.Sprintf("/%s/%s", action.Namespace, action.Name), publishState, kind)
+ output := fmt.Sprintf("%-70s %s %s\n",
+ fmt.Sprintf("/%s/%s", action.Namespace, action.Name),
+ publishState,
+ kind)
+ wskprint.PrintlnOpenWhiskInfo(output)
}
}
/*
func printTriggerList(triggers whisk.Trigger) {
- fmt.Fprintf(color.Output, "%s\n", boldString("triggers"))
+ //fmt.Fprintf(color.Output, "%s\n", boldString("triggers"))
+ wskprint.PrintlnOpenWhiskInfoTitle(wski18n.TRIGGERS)
for _, trigger := range triggers {
publishState := wski18n.T("private")
if trigger.Publish {
@@ -216,7 +230,9 @@ func getValueString(keyValueArr whisk.KeyValueArr, key string) string {
res = castedValue
}
- whisk.Debug(whisk.DbgInfo, "Got string value '%v' for key '%s'\n", res, key)
+ // TODO() This may be too much for end-user debug/trace
+ //dbgMsg := fmt.Sprintf("keyValueArr[%v]: key=[%s] value=[%v]\n", keyValueArr, key, res)
+ //wskprint.PrintlnOpenWhiskVerbose(utils.Flags.Verbose, dbgMsg )
return res
}
@@ -231,21 +247,25 @@ func getValue(keyValueArr whisk.KeyValueArr, key string) interface{} {
}
}
- whisk.Debug(whisk.DbgInfo, "Got value '%v' from '%v' for key '%s'\n", res, keyValueArr, key)
+ // TODO() This may be too much for end-user debug/trace
+ //dbgMsg := fmt.Sprintf("keyValueArr[%v]: key=[%s] value=[%v]\n", keyValueArr, key, res)
+ //wskprint.PrintlnOpenWhiskVerbose(utils.Flags.Verbose, dbgMsg )
return res
}
func printNamespaceList(namespaces []whisk.Namespace) {
- fmt.Fprintf(color.Output, "%s\n", boldString("namespaces"))
+ wskprint.PrintlnOpenWhiskInfo(wski18n.NAMESPACES)
for _, namespace := range namespaces {
- fmt.Printf("%s\n", namespace.Name)
+ output := fmt.Sprintf("%s\n", namespace.Name)
+ wskprint.PrintlnOpenWhiskInfo(output)
}
}
func printActivationList(activations []whisk.Activation) {
- fmt.Fprintf(color.Output, "%s\n", boldString("activations"))
+ wskprint.PrintlnOpenWhiskInfo(wski18n.ACTIVATIONS)
for _, activation := range activations {
- fmt.Printf("%s %20s\n", activation.ActivationID, activation.Name)
+ output := fmt.Sprintf("%s %20s\n", activation.ActivationID, activation.Name)
+ wskprint.PrintlnOpenWhiskInfo(output)
}
}
diff --git a/cmd/root.go b/cmd/root.go
index 25ccc30..1600802 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -21,18 +21,18 @@ import (
"encoding/json"
"errors"
"fmt"
- "github.com/apache/incubator-openwhisk-client-go/whisk"
- "github.com/apache/incubator-openwhisk-wskdeploy/deployers"
- "github.com/apache/incubator-openwhisk-wskdeploy/utils"
- "github.com/apache/incubator-openwhisk-wskdeploy/wski18n"
- "github.com/spf13/cobra"
"os"
"path"
"path/filepath"
"regexp"
"strings"
+ "github.com/spf13/cobra"
"github.com/apache/incubator-openwhisk-wskdeploy/wskderrors"
"github.com/apache/incubator-openwhisk-wskdeploy/wskprint"
+ "github.com/apache/incubator-openwhisk-client-go/whisk"
+ "github.com/apache/incubator-openwhisk-wskdeploy/deployers"
+ "github.com/apache/incubator-openwhisk-wskdeploy/utils"
+ "github.com/apache/incubator-openwhisk-wskdeploy/wski18n"
)
var stderr = ""
@@ -40,15 +40,11 @@ var stdout = ""
// TODO(#683) short and long desc. should be translated for i18n
var RootCmd = &cobra.Command{
- Use: "wskdeploy",
- SilenceErrors: true,
- SilenceUsage: true,
- Short: "A tool set to help deploy your openwhisk packages in batch.",
- Long: `A tool to deploy openwhisk packages with a manifest and/or deployment yaml file.
-
-wskdeploy without any commands or flags deploys openwhisk package in the current directory if manifest.yaml exists.
-
- `,
+ Use: "wskdeploy",
+ SilenceErrors: true,
+ SilenceUsage: true,
+ Short: wski18n.T(wski18n.ID_CMD_DESC_SHORT_ROOT),
+ Long: wski18n.T(wski18n.ID_CMD_DESC_LONG_ROOT),
// Uncomment the following line if your bare application
// has an action associated with it:
RunE: RootCmdImp,
@@ -74,8 +70,9 @@ func Execute() {
os.Exit(-1)
} else {
if utils.Flags.WithinOpenWhisk {
- // TODO() i18n
- fmt.Print(`{"deploy":"success"}`) // maybe return report of what has been deployed.
+ // TODO() Why are we printing success here?
+ // TODO() maybe return report of what has been deployed.
+ wskprint.PrintlnOpenWhiskSuccess(wski18n.T(wski18n.ID_MSG_DEPLOYMENT_SUCCEEDED))
}
}
}
@@ -84,11 +81,11 @@ func Execute() {
// (i.e., command and arguments) is JSON data (map).
func substCmdArgs() error {
// Extract arguments from input JSON string
-
// { "cmd": ".." } // space-separated arguments
arg := os.Args[1]
+ // TODO() Move to proper status output/debug/trace
fmt.Println("arg is " + arg)
// unmarshal the string to a JSON object
var obj map[string]interface{}
@@ -98,12 +95,13 @@ func substCmdArgs() error {
regex, _ := regexp.Compile("[ ]+")
os.Args = regex.Split("wskdeploy "+strings.TrimSpace(v), -1)
} else {
- return errors.New(wski18n.T(wski18n.ID_JSON_MISSING_KEY_CMD))
+ return errors.New(wski18n.T(wski18n.ID_ERR_JSON_MISSING_KEY_CMD))
}
return nil
}
func init() {
+ // TODO() move Env var. to some global const
utils.Flags.WithinOpenWhisk = len(os.Getenv("__OW_API_HOST")) > 0
cobra.OnInitialize(initConfig)
@@ -113,24 +111,27 @@ func init() {
// will be global for your application.
// TODO(#682) add in-line descriptions to i18n resource file
- RootCmd.PersistentFlags().StringVar(&utils.Flags.CfgFile, "config", "", "config file (default is $HOME/.wskprops)")
+ RootCmd.PersistentFlags().StringVar(&utils.Flags.CfgFile, "config", "", wski18n.T(wski18n.ID_CMD_FLAG_CONFIG))
// Cobra also supports local flags, which will only run
// when this action is called directly.
- RootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
- RootCmd.Flags().StringVarP(&utils.Flags.ProjectPath, "project", "p", ".", "path to serverless project")
- RootCmd.Flags().StringVarP(&utils.Flags.ManifestPath, "manifest", "m", "", "path to manifest file")
- RootCmd.Flags().StringVarP(&utils.Flags.DeploymentPath, "deployment", "d", "", "path to deployment file")
- RootCmd.PersistentFlags().BoolVarP(&utils.Flags.Strict, "strict", "s", false, "allow user defined runtime version")
- RootCmd.PersistentFlags().BoolVarP(&utils.Flags.UseInteractive, "allow-interactive", "i", false, "allow interactive prompts")
- RootCmd.PersistentFlags().BoolVarP(&utils.Flags.UseDefaults, "allow-defaults", "a", false, "allow defaults")
- RootCmd.PersistentFlags().BoolVarP(&utils.Flags.Verbose, "verbose", "v", false, "verbose output")
+ // TODO() Publish command, not completed
+ // TODO() Report command, not completed
+ // TODO() What does toggle do? adding this flag seems to produce an error
+ RootCmd.Flags().BoolP("toggle", "t", false, wski18n.T(wski18n.ID_CMD_FLAG_TOGGLE_HELP))
+ RootCmd.Flags().StringVarP(&utils.Flags.ProjectPath, "project", "p", ".", wski18n.T(wski18n.ID_CMD_FLAG_PROJECT))
+ RootCmd.Flags().StringVarP(&utils.Flags.ManifestPath, "manifest", "m", "", wski18n.T(wski18n.ID_CMD_FLAG_MANIFEST))
+ RootCmd.Flags().StringVarP(&utils.Flags.DeploymentPath, "deployment", "d", "", wski18n.T(wski18n.ID_CMD_FLAG_DEPLOYMENT))
+ RootCmd.PersistentFlags().BoolVarP(&utils.Flags.Strict, "strict", "s", false, wski18n.T(wski18n.ID_CMD_FLAG_STRICT))
+ RootCmd.PersistentFlags().BoolVarP(&utils.Flags.UseInteractive, "allow-interactive", "i", false, wski18n.T(wski18n.ID_CMD_FLAG_INTERACTIVE))
+ RootCmd.PersistentFlags().BoolVarP(&utils.Flags.UseDefaults, "allow-defaults", "a", false, wski18n.T(wski18n.ID_CMD_FLAG_DEFAULTS))
+ RootCmd.PersistentFlags().BoolVarP(&utils.Flags.Verbose, "verbose", "v", false, wski18n.T(wski18n.ID_CMD_FLAG_VERBOSE))
RootCmd.PersistentFlags().StringVarP(&utils.Flags.ApiHost, "apihost", "", "", wski18n.T(wski18n.ID_CMD_FLAG_API_HOST))
RootCmd.PersistentFlags().StringVarP(&utils.Flags.Namespace, "namespace", "n", "", wski18n.T(wski18n.ID_CMD_FLAG_NAMESPACE))
RootCmd.PersistentFlags().StringVarP(&utils.Flags.Auth, "auth", "u", "", wski18n.T(wski18n.ID_CMD_FLAG_AUTH_KEY))
RootCmd.PersistentFlags().StringVar(&utils.Flags.ApiVersion, "apiversion", "", wski18n.T(wski18n.ID_CMD_FLAG_API_VERSION))
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, "mark project entities as managed")
+ RootCmd.PersistentFlags().BoolVarP(&utils.Flags.Managed, "managed", "", false, wski18n.T(wski18n.ID_CMD_FLAG_MANAGED))
}
// initConfig reads in config file and ENV variables if set.
@@ -143,8 +144,10 @@ func initConfig() {
_, err := whisk.ReadProps(utils.Flags.CfgFile)
if err != nil {
utils.Flags.CfgFile = defaultPath
- // TODO() i18n
- wskprint.PrintOpenWhiskWarning("Invalid config file detected, so by default it is set to " + utils.Flags.CfgFile + "\n")
+ warn := wski18n.T(wski18n.ID_WARN_CONFIG_INVALID_X_path_X,
+ map[string]interface{}{
+ wski18n.KEY_PATH: utils.Flags.CfgFile})
+ wskprint.PrintOpenWhiskWarning(warn)
}
} else {
@@ -174,18 +177,19 @@ func Deploy() error {
}
projectPath, _ := filepath.Abs(project_Path)
+ // TODO() identical code block below; please create function both can share
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{}{"path": utils.Flags.ManifestPath})
+ 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{}{"path": utils.Flags.ManifestPath})
+ map[string]interface{}{wski18n.KEY_PATH: utils.Flags.ManifestPath})
} else {
- stderr = wski18n.T(wski18n.ID_MSG_MANIFEST_FILE_NOT_FOUND_X_path_X,
- map[string]interface{}{"path": projectPath})
+ 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)
}
whisk.Debug(whisk.DbgInfo, stdout)
@@ -243,8 +247,8 @@ func Deploy() error {
}
} else {
- errString := wski18n.T(wski18n.ID_MSG_MANIFEST_FILE_NOT_FOUND_X_path_X,
- map[string]interface{}{"path": utils.Flags.ManifestPath})
+ errString := wski18n.T(wski18n.ID_ERR_MANIFEST_FILE_NOT_FOUND_X_path_X,
+ map[string]interface{}{wski18n.KEY_PATH: utils.Flags.ManifestPath})
whisk.Debug(whisk.DbgError, errString)
return wskderrors.NewErrorManifestFileNotFound(utils.Flags.ManifestPath, errString)
}
@@ -268,26 +272,37 @@ func Undeploy() error {
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{}{"path": utils.Flags.ManifestPath})
+ 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{}{"path": utils.Flags.ManifestPath})
+ map[string]interface{}{wski18n.KEY_PATH: utils.Flags.ManifestPath})
} else {
- stderr = wski18n.T(wski18n.ID_MSG_MANIFEST_FILE_NOT_FOUND_X_path_X,
- map[string]interface{}{"path": projectPath})
+ 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)
}
- whisk.Debug(whisk.DbgInfo, stdout)
+ 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)
- fmt.Printf("Using %s for undeployment \n", utils.Flags.DeploymentPath)
+ // 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)
- fmt.Printf("Using %s for undeployment \n", utils.Flags.DeploymentPath)
+ // 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)
}
}
@@ -330,8 +345,8 @@ func Undeploy() error {
}
} else {
- errString := wski18n.T(wski18n.ID_MSG_MANIFEST_FILE_NOT_FOUND_X_path_X,
- map[string]interface{}{"path": utils.Flags.ManifestPath})
+ errString := wski18n.T(wski18n.ID_ERR_MANIFEST_FILE_NOT_FOUND_X_path_X,
+ map[string]interface{}{wski18n.KEY_PATH: utils.Flags.ManifestPath})
return wskderrors.NewErrorManifestFileNotFound(utils.Flags.ManifestPath, errString)
}
}
diff --git a/cmd/version.go b/cmd/version.go
index 0f732d7..ef63f79 100644
--- a/cmd/version.go
+++ b/cmd/version.go
@@ -19,8 +19,10 @@ package cmd
import (
"fmt"
- "github.com/apache/incubator-openwhisk-wskdeploy/utils"
"github.com/spf13/cobra"
+ "github.com/apache/incubator-openwhisk-wskdeploy/utils"
+ "github.com/apache/incubator-openwhisk-wskdeploy/wski18n"
+ "github.com/apache/incubator-openwhisk-wskdeploy/wskprint"
)
func init() {
@@ -28,11 +30,14 @@ func init() {
}
var versionCmd = &cobra.Command{
- Use: "version",
- SuggestFor: []string {"edition", "release"},
- Short: "Print the version number of openwhisk-wskdeploy",
- Long: `Print the version number of openwhisk-wskdeploy`,
+ Use: "version",
+ SuggestFor: []string{"edition", "release"},
+ Short: wski18n.T(wski18n.ID_CMD_DESC_SHORT_VERSION),
Run: func(cmd *cobra.Command, args []string) {
- fmt.Printf("openwhisk-wskdeploy version is %s--%s\n", utils.Flags.CliBuild, utils.Flags.CliVersion)
+ wskprint.PrintlnOpenWhiskOutput(
+ // Note: no need to translate the following string
+ fmt.Sprintf("wskdeploy build-version: %s--%s",
+ utils.Flags.CliBuild,
+ utils.Flags.CliVersion))
},
}
diff --git a/deployers/deploymentreader.go b/deployers/deploymentreader.go
index 8370f8e..d490865 100644
--- a/deployers/deploymentreader.go
+++ b/deployers/deploymentreader.go
@@ -18,13 +18,13 @@
package deployers
import (
- "errors"
"github.com/apache/incubator-openwhisk-client-go/whisk"
"github.com/apache/incubator-openwhisk-wskdeploy/parsers"
"github.com/apache/incubator-openwhisk-wskdeploy/wski18n"
"github.com/apache/incubator-openwhisk-wskdeploy/wskderrors"
"github.com/apache/incubator-openwhisk-wskdeploy/wskprint"
"github.com/apache/incubator-openwhisk-wskdeploy/wskenv"
+ "github.com/apache/incubator-openwhisk-wskdeploy/utils"
)
type DeploymentReader struct {
@@ -76,8 +76,13 @@ func (reader *DeploymentReader) bindPackageInputsAndAnnotations() error {
// a single package is specified in deployment YAML file with "package" key
if len(reader.DeploymentDescriptor.GetProject().Package.Packagename) != 0 {
packMap[reader.DeploymentDescriptor.GetProject().Package.Packagename] = reader.DeploymentDescriptor.GetProject().Package
- // TODO() i18n
- wskprint.PrintlnOpenWhiskWarning("The package YAML key in deployment file will soon be deprecated. Please use packages instead as described in specifications.")
+ warningString := wski18n.T(
+ wski18n.ID_WARN_KEY_DEPRECATED_X_oldkey_X_filetype_X_newkey_X,
+ map[string]interface{}{
+ wski18n.KEY_OLD: parsers.YAML_KEY_PACKAGE,
+ wski18n.KEY_NEW: parsers.YAML_KEY_PACKAGES,
+ wski18n.KEY_FILE_TYPE: wski18n.DEPLOYMENT})
+ wskprint.PrintlnOpenWhiskWarning(warningString)
} else {
if reader.DeploymentDescriptor.Packages != nil {
for packName, depPacks := range reader.DeploymentDescriptor.Packages {
@@ -100,8 +105,12 @@ func (reader *DeploymentReader) bindPackageInputsAndAnnotations() error {
serviceDeployPack := reader.serviceDeployer.Deployment.Packages[packName]
if serviceDeployPack == nil {
- // TODO() i18n
- wskprint.PrintlnOpenWhiskWarning("Package name in deployment file " + packName + " does not match with manifest file.")
+ warningString := wski18n.T(
+ wski18n.ID_ERR_DEPLOYMENT_NAME_NOT_FOUND_X_key_X_name_X,
+ map[string]interface{}{
+ wski18n.KEY_KEY: wski18n.PACKAGE_NAME,
+ wski18n.KEY_NAME: packName })
+ wskprint.PrintlnOpenWhiskWarning(warningString)
break
}
@@ -149,10 +158,13 @@ func (reader *DeploymentReader) bindPackageInputsAndAnnotations() error {
}
}
if !keyExistsInManifest {
- // TODO() i18n, need to use an ID
- // TODO() fix grammar error; need command before "but"
- err := errors.New(wski18n.T("Annotation key \"" + name + "\" does not exist in manifest file but specified in deployment file."))
- return wskderrors.NewYAMLFileFormatError(reader.DeploymentDescriptor.Filepath, err)
+ warningString := wski18n.T(
+ wski18n.ID_ERR_DEPLOYMENT_NAME_NOT_FOUND_X_key_X_name_X,
+ map[string]interface{}{
+ wski18n.KEY_KEY: parsers.YAML_KEY_ANNOTATION,
+ wski18n.KEY_NAME: name })
+ wskprint.PrintlnOpenWhiskWarning(warningString)
+ return wskderrors.NewYAMLFileFormatError(reader.DeploymentDescriptor.Filepath, warningString)
}
}
}
@@ -240,9 +252,12 @@ func (reader *DeploymentReader) bindActionInputsAndAnnotations() error {
}
}
if !keyExistsInManifest {
- // TODO() i18n, need to use an ID
- err := errors.New(wski18n.T("Annotation key \"" + name + "\" does not exist in manifest file but specified in deployment file."))
- return wskderrors.NewYAMLFileFormatError(reader.DeploymentDescriptor.Filepath, err)
+ errMsg := wski18n.T(
+ wski18n.ID_ERR_DEPLOYMENT_NAME_NOT_FOUND_X_key_X_name_X,
+ map[string]interface{}{
+ wski18n.KEY_KEY: parsers.YAML_KEY_ANNOTATION,
+ wski18n.KEY_NAME: name })
+ return wskderrors.NewYAMLFileFormatError(reader.DeploymentDescriptor.Filepath, errMsg)
}
}
}
@@ -300,9 +315,16 @@ func (reader *DeploymentReader) bindTriggerInputsAndAnnotations() error {
depParams[kv.Key] = kv
}
+ var traceMsg string
for _, keyVal := range wskTrigger.Parameters {
- // TODO() i18n
- wskprint.PrintlnOpenWhiskOutput("Checking key " + keyVal.Key)
+ traceMsg = wski18n.T(
+ wski18n.ID_DEBUG_KEY_VERIFY_X_name_X_key_X,
+ map[string]interface{}{
+ wski18n.KEY_NAME: parsers.YAML_KEY_ANNOTATION,
+ wski18n.KEY_KEY: keyVal.Key})
+ wskprint.PrintOpenWhiskVerbose(utils.Flags.Verbose, traceMsg)
+
+ // TODO() verify logic and add Verbose/trace say "found" or "not found"
if _, exists := depParams[keyVal.Key]; !exists {
keyValArr = append(keyValArr, keyVal)
}
@@ -328,9 +350,12 @@ func (reader *DeploymentReader) bindTriggerInputsAndAnnotations() error {
}
}
if !keyExistsInManifest {
- // TODO() i18n, need to use an ID
- err := errors.New(wski18n.T("Annotation key \"" + name + "\" does not exist in manifest file but specified in deployment file."))
- return wskderrors.NewYAMLFileFormatError(reader.DeploymentDescriptor.Filepath, err)
+ errMsg := wski18n.T(
+ wski18n.ID_ERR_DEPLOYMENT_NAME_NOT_FOUND_X_key_X_name_X,
+ map[string]interface{}{
+ wski18n.KEY_KEY: parsers.YAML_KEY_ANNOTATION,
+ wski18n.KEY_NAME: name })
+ return wskderrors.NewYAMLFileFormatError(reader.DeploymentDescriptor.Filepath, errMsg)
}
}
}
diff --git a/deployers/filesystemreader.go b/deployers/filesystemreader.go
index 702da76..05d6137 100644
--- a/deployers/filesystemreader.go
+++ b/deployers/filesystemreader.go
@@ -28,6 +28,7 @@ import (
"github.com/apache/incubator-openwhisk-wskdeploy/utils"
"github.com/apache/incubator-openwhisk-wskdeploy/wskderrors"
"github.com/apache/incubator-openwhisk-wskdeploy/wskprint"
+ "github.com/apache/incubator-openwhisk-wskdeploy/wski18n"
)
// name of directory that can contain source code
@@ -46,26 +47,33 @@ func NewFileSystemReader(serviceDeployer *ServiceDeployer) *FileSystemReader {
func (reader *FileSystemReader) ReadProjectDirectory(manifest *parsers.YAML) ([]utils.ActionRecord, error) {
- // TODO() i18n
- wskprint.PrintlnOpenWhiskOutput("Inspecting project directory for actions....")
+ // Inform user of what reader is doing
+ dbgMsg := wski18n.T(wski18n.ID_DEBUG_PROJECT_SEARCH_X_path_X_key_X,
+ map[string]interface{}{
+ wski18n.KEY_PATH: reader.serviceDeployer.ProjectPath,
+ wski18n.KEY_KEY: wski18n.ACTIONS})
+ wskprint.PrintlnOpenWhiskVerbose(utils.Flags.Verbose, dbgMsg)
projectPathCount, err := reader.getFilePathCount(reader.serviceDeployer.ProjectPath)
actions := make([]utils.ActionRecord, 0)
- if err != nil {
- return actions, err
- }
+
+ if err != nil {
+ return actions, err
+ }
err = filepath.Walk(reader.serviceDeployer.ProjectPath, func(fpath string, f os.FileInfo, err error) error {
if fpath != reader.serviceDeployer.ProjectPath {
pathCount, err := reader.getFilePathCount(fpath)
- if err != nil {
- return wskderrors.NewFileReadError(fpath, err.Error())
- }
+ if err != nil {
+ return wskderrors.NewFileReadError(fpath, err.Error())
+ }
if !f.IsDir() {
- if pathCount-projectPathCount == 1 || strings.HasPrefix(fpath, reader.serviceDeployer.ProjectPath+"/"+FileSystemSourceDirectoryName) {
+ if pathCount - projectPathCount == 1 || strings.HasPrefix(fpath, reader.serviceDeployer.ProjectPath + "/" + FileSystemSourceDirectoryName) {
ext := filepath.Ext(fpath)
+ // TODO(#692) do not hardcoded known extensions here, create a util that associates
+ // known extensions to runtime types
foundFile := false
switch ext {
case ".swift":
@@ -78,9 +86,9 @@ func (reader *FileSystemReader) ReadProjectDirectory(manifest *parsers.YAML) ([]
if foundFile == true {
_, action, err := reader.CreateActionFromFile(reader.serviceDeployer.ManifestPath, fpath)
- if err != nil {
- return wskderrors.NewFileReadError(fpath, err.Error())
- }
+ if err != nil {
+ return wskderrors.NewFileReadError(fpath, err.Error())
+ }
var record utils.ActionRecord
record.Action = action
@@ -90,9 +98,17 @@ func (reader *FileSystemReader) ReadProjectDirectory(manifest *parsers.YAML) ([]
actions = append(actions, record)
}
}
- } else if strings.HasPrefix(fpath, reader.serviceDeployer.ProjectPath+"/"+FileSystemSourceDirectoryName) {
- // TODO() i18n
- wskprint.PrintlnOpenWhiskOutput("Searching directory " + filepath.Base(fpath) + " for action source code.")
+ } else if strings.HasPrefix(fpath, reader.serviceDeployer.ProjectPath + "/" + FileSystemSourceDirectoryName) {
+ // Inform user of what reader is doing
+ dbgMsg := wski18n.T(wski18n.ID_DEBUG_PROJECT_SEARCH_X_path_X_key_X,
+ map[string]interface{}{
+ wski18n.KEY_PATH: filepath.Base(fpath),
+ wski18n.KEY_KEY: wski18n.ACTION_CODE})
+ wskprint.PrintlnOpenWhiskVerbose(utils.Flags.Verbose, dbgMsg)
+
+ // TODO(#694) It appears there is no code to do what the debug message suggests
+ // TODO(#694) continued: i.e., searching for Action code...
+
} else {
return filepath.SkipDir
}
@@ -115,6 +131,7 @@ func (reader *FileSystemReader) CreateActionFromFile(manipath, filePath string)
name := strings.TrimSuffix(baseName, filepath.Ext(baseName))
action := new(whisk.Action)
+ // TODO(#692) same TODO as above, that is create util for matching exts. to runtimes in common util pkg.
// process source code files
if ext == ".swift" || ext == ".js" || ext == ".py" {
@@ -130,9 +147,9 @@ func (reader *FileSystemReader) CreateActionFromFile(manipath, filePath string)
}
dat, err := new(utils.ContentReader).LocalReader.ReadLocal(filePath)
- if err != nil {
- return name, action, wskderrors.NewFileReadError(filePath, err.Error())
- }
+ if err != nil {
+ return name, action, wskderrors.NewFileReadError(filePath, err.Error())
+ }
action.Exec = new(whisk.Exec)
code := string(dat)
@@ -143,6 +160,8 @@ func (reader *FileSystemReader) CreateActionFromFile(manipath, filePath string)
action.Publish = &pub
return name, action, nil
}
+
+ // TODO(#691) create new named error
// If the action is not supported, we better to return an error.
return "", nil, errors.New("Unsupported action type.")
}
@@ -173,6 +192,7 @@ func (reader *FileSystemReader) SetFileActions(actions []utils.ActionRecord) err
existAction.Action.Exec.Code = fileAction.Action.Exec.Code
existAction.Filepath = fileAction.Filepath
} else {
+ // TODO(#691) create new named error
// Action exists, but references two different sources
return errors.New("Conflict detected for action named " + existAction.Action.Name + ". Found two locations for source file: " + existAction.Filepath + " and " + fileAction.Filepath)
}
@@ -183,5 +203,4 @@ func (reader *FileSystemReader) SetFileActions(actions []utils.ActionRecord) err
}
return nil
-
}
diff --git a/deployers/manifestreader_test.go b/deployers/manifestreader_test.go
index 646c228..5e5851a 100644
--- a/deployers/manifestreader_test.go
+++ b/deployers/manifestreader_test.go
@@ -57,5 +57,5 @@ func TestManifestReader_param(t *testing.T) {
err := mr.InitRootPackage(ps, ms, whisk.KeyValue{})
assert.Equal(t, err, nil, "Init Root Package failed")
- // TODO.
+ // TODO(#695) Is there more to do here? Original author left a TODO here in comments
}
diff --git a/deployers/servicedeployer.go b/deployers/servicedeployer.go
index b382af5..72f3540 100644
--- a/deployers/servicedeployer.go
+++ b/deployers/servicedeployer.go
@@ -37,8 +37,8 @@ import (
)
const (
- CONFLICT_CODE = 153
CONFLICT_MESSAGE = "Concurrent modification to resource detected"
+ CONFLICT_CODE = 153
DEFAULT_ATTEMPTS = 3
DEFAULT_INTERVAL = 1 * time.Second
)
@@ -142,8 +142,8 @@ func (deployer *ServiceDeployer) ConstructDeploymentPlan() error {
// OpenWhisk entities are annotated with Project Name and therefore
// Project Name in manifest/deployment file is mandatory for managed deployments
if deployer.ProjectName == "" {
- errmsg := wski18n.T(wski18n.ID_ERR_MISSING_MANDATORY_KEY_X_key_X,
- map[string]interface{}{"key": parsers.PROJECT_NAME})
+ errmsg := wski18n.T(wski18n.ID_ERR_KEY_MISSING_X_key_X,
+ map[string]interface{}{wski18n.KEY_KEY: wski18n.PROJECT_NAME})
return wskderrors.NewYAMLFileFormatError(manifest.Filepath, errmsg)
}
@@ -177,13 +177,13 @@ func (deployer *ServiceDeployer) ConstructDeploymentPlan() error {
projectName = manifest.GetProject().Name
}
- // (TODO) delete this warning after deprecating application in manifest file
+ // TODO(#696) delete this warning after deprecating application in manifest file
if manifest.Application.Name != "" {
- wskprint.PrintOpenWhiskWarning(wski18n.T(wski18n.ID_WARN_DEPRECATED_KEY_REPLACED_X_oldkey_X_filetype_X_newkey_X,
+ wskprint.PrintOpenWhiskWarning(wski18n.T(wski18n.ID_WARN_KEY_DEPRECATED_X_oldkey_X_filetype_X_newkey_X,
map[string]interface{}{
- "oldkey": parsers.YAML_KEY_APPLICATION,
- "newkey": parsers.YAML_KEY_PROJECT,
- "filetype": "manifest"}))
+ wski18n.KEY_OLD: parsers.YAML_KEY_APPLICATION,
+ wski18n.KEY_NEW: parsers.YAML_KEY_PROJECT,
+ wski18n.KEY_FILE_TYPE: wski18n.MANIFEST}))
}
// process deployment file
@@ -195,26 +195,26 @@ func (deployer *ServiceDeployer) ConstructDeploymentPlan() error {
return err
}
- // (TODO) delete this warning after deprecating application in deployment file
+ // TODO(#696) delete this warning after deprecating application in deployment file
if deploymentReader.DeploymentDescriptor.Application.Name != "" {
- wskprint.PrintOpenWhiskWarning(wski18n.T(wski18n.ID_WARN_DEPRECATED_KEY_REPLACED_X_oldkey_X_filetype_X_newkey_X,
+ wskprint.PrintOpenWhiskWarning(wski18n.T(wski18n.ID_WARN_KEY_DEPRECATED_X_oldkey_X_filetype_X_newkey_X,
map[string]interface{}{
- "oldkey": parsers.YAML_KEY_APPLICATION,
- "newkey": parsers.YAML_KEY_PROJECT,
- "filetype": "deployment"}))
+ wski18n.KEY_OLD: parsers.YAML_KEY_APPLICATION,
+ wski18n.KEY_NEW: parsers.YAML_KEY_PROJECT,
+ wski18n.KEY_FILE_TYPE: wski18n.DEPLOYMENT}))
}
// compare the name of the project
if len(deploymentReader.DeploymentDescriptor.GetProject().Packages) != 0 && len(projectName) != 0 {
projectNameDeploy := deploymentReader.DeploymentDescriptor.GetProject().Name
if projectNameDeploy != projectName {
- errorString := wski18n.T(wski18n.ID_ERR_MISMATCH_NAME_X_key_X_dname_X_dpath_X_mname_X_moath_X,
+ errorString := wski18n.T(wski18n.ID_ERR_NAME_MISMATCH_X_key_X_dname_X_dpath_X_mname_X_moath_X,
map[string]interface{}{
- "key": parsers.YAML_KEY_PROJECT,
- "dname": projectNameDeploy,
- "dpath": deployer.DeploymentPath,
- "mname": projectName,
- "mpath": deployer.ManifestPath})
+ wski18n.KEY_KEY: parsers.YAML_KEY_PROJECT,
+ wski18n.KEY_DEPLOYMENT_NAME: projectNameDeploy,
+ wski18n.KEY_DEPLOYMENT_PATH: deployer.DeploymentPath,
+ wski18n.KEY_MANIFEST_NAME: projectName,
+ wski18n.KEY_MANIFEST_PATH: deployer.ManifestPath})
return wskderrors.NewYAMLFileFormatError(manifest.Filepath, errorString)
}
}
@@ -265,13 +265,13 @@ func (deployer *ServiceDeployer) ConstructUnDeploymentPlan() (*DeploymentProject
projectName = manifest.GetProject().Name
}
- // (TODO) delete this warning after deprecating application in manifest file
+ // TODO(#696) delete this warning after deprecating application in manifest file
if manifest.Application.Name != "" {
- wskprint.PrintOpenWhiskWarning(wski18n.T(wski18n.ID_WARN_DEPRECATED_KEY_REPLACED_X_oldkey_X_filetype_X_newkey_X,
+ wskprint.PrintOpenWhiskWarning(wski18n.T(wski18n.ID_WARN_KEY_DEPRECATED_X_oldkey_X_filetype_X_newkey_X,
map[string]interface{}{
- "oldkey": parsers.YAML_KEY_APPLICATION,
- "newkey": parsers.YAML_KEY_PROJECT,
- "filetype": "manifest"}))
+ wski18n.KEY_OLD: parsers.YAML_KEY_APPLICATION,
+ wski18n.KEY_NEW: parsers.YAML_KEY_PROJECT,
+ wski18n.KEY_FILE_TYPE: wski18n.MANIFEST}))
}
// process deployment file
@@ -282,26 +282,26 @@ func (deployer *ServiceDeployer) ConstructUnDeploymentPlan() (*DeploymentProject
return deployer.Deployment, err
}
- // (TODO) delete this warning after deprecating application in deployment file
+ // TODO(#696) delete this warning after deprecating application in deployment file
if deploymentReader.DeploymentDescriptor.Application.Name != "" {
- wskprint.PrintOpenWhiskWarning(wski18n.T(wski18n.ID_WARN_DEPRECATED_KEY_REPLACED_X_oldkey_X_filetype_X_newkey_X,
+ wskprint.PrintOpenWhiskWarning(wski18n.T(wski18n.ID_WARN_KEY_DEPRECATED_X_oldkey_X_filetype_X_newkey_X,
map[string]interface{}{
- "oldkey": parsers.YAML_KEY_APPLICATION,
- "newkey": parsers.YAML_KEY_PROJECT,
- "filetype": "deployment"}))
+ wski18n.KEY_OLD: parsers.YAML_KEY_APPLICATION,
+ wski18n.KEY_NEW: parsers.YAML_KEY_PROJECT,
+ wski18n.KEY_FILE_TYPE: wski18n.DEPLOYMENT}))
}
// compare the name of the application
if len(deploymentReader.DeploymentDescriptor.GetProject().Packages) != 0 && len(projectName) != 0 {
projectNameDeploy := deploymentReader.DeploymentDescriptor.GetProject().Name
if projectNameDeploy != projectName {
- errorString := wski18n.T(wski18n.ID_ERR_MISMATCH_NAME_X_key_X_dname_X_dpath_X_mname_X_moath_X,
+ errorString := wski18n.T(wski18n.ID_ERR_NAME_MISMATCH_X_key_X_dname_X_dpath_X_mname_X_moath_X,
map[string]interface{}{
- "key": parsers.YAML_KEY_PROJECT,
- "dname": projectNameDeploy,
- "dpath": deployer.DeploymentPath,
- "mname": projectName,
- "mpath": deployer.ManifestPath})
+ wski18n.KEY_KEY: parsers.YAML_KEY_PROJECT,
+ wski18n.KEY_DEPLOYMENT_NAME: projectNameDeploy,
+ wski18n.KEY_DEPLOYMENT_PATH: deployer.DeploymentPath,
+ wski18n.KEY_MANIFEST_NAME: projectName,
+ wski18n.KEY_MANIFEST_PATH: deployer.ManifestPath})
return deployer.Deployment, wskderrors.NewYAMLFileFormatError(manifest.Filepath, errorString)
}
}
@@ -414,7 +414,7 @@ func (deployer *ServiceDeployer) DeployDependencies() error {
for _, pack := range deployer.Deployment.Packages {
for depName, depRecord := range pack.Dependencies {
output := wski18n.T(wski18n.ID_MSG_DEPENDENCY_DEPLOYING_X_name_X,
- map[string]interface{}{"name": depName})
+ map[string]interface{}{wski18n.KEY_NAME: depName})
whisk.Debug(whisk.DbgInfo, output)
if depRecord.IsBinding {
@@ -438,7 +438,7 @@ func (deployer *ServiceDeployer) DeployDependencies() error {
return error
} else {
output := wski18n.T(wski18n.ID_MSG_DEPENDENCY_DEPLOYMENT_SUCCESS_X_name_X,
- map[string]interface{}{"name": depName})
+ map[string]interface{}{wski18n.KEY_NAME: depName})
whisk.Debug(whisk.DbgInfo, output)
}
@@ -455,7 +455,7 @@ func (deployer *ServiceDeployer) DeployDependencies() error {
if err := depServiceDeployer.deployAssets(); err != nil {
errString := wski18n.T(wski18n.ID_MSG_DEPENDENCY_DEPLOYMENT_FAILURE_X_name_X,
- map[string]interface{}{"name": depName})
+ map[string]interface{}{wski18n.KEY_NAME: depName})
wskprint.PrintOpenWhiskError(errString)
return err
}
@@ -484,7 +484,7 @@ func (deployer *ServiceDeployer) DeployDependencies() error {
return err
} else {
output := wski18n.T(wski18n.ID_MSG_DEPENDENCY_DEPLOYMENT_SUCCESS_X_name_X,
- map[string]interface{}{"name": depName})
+ map[string]interface{}{wski18n.KEY_NAME: depName})
whisk.Debug(whisk.DbgInfo, output)
}
}
@@ -583,9 +583,9 @@ func (deployer *ServiceDeployer) RefreshManagedTriggers(ma map[string]interface{
// we have found a trigger which was earlier part of the current project
output := wski18n.T(wski18n.ID_MSG_MANAGED_FOUND_DELETED_X_key_X_name_X_project_X,
map[string]interface{}{
- "key": parsers.YAML_KEY_TRIGGER,
- "name": trigger.Name,
- "project": ma[utils.OW_PROJECT_NAME]})
+ wski18n.KEY_KEY: parsers.YAML_KEY_TRIGGER,
+ wski18n.KEY_NAME: trigger.Name,
+ wski18n.KEY_PROJECT: ma[utils.OW_PROJECT_NAME]})
wskprint.PrintOpenWhiskWarning(output)
var err error
@@ -635,9 +635,9 @@ func (deployer *ServiceDeployer) RefreshManagedPackages(ma map[string]interface{
if pa[utils.OW_PROJECT_NAME] == ma[utils.OW_PROJECT_NAME] && pa[utils.OW_PROJECT_HASH] != ma[utils.OW_PROJECT_HASH] {
output := wski18n.T(wski18n.ID_MSG_MANAGED_FOUND_DELETED_X_key_X_name_X_project_X,
map[string]interface{}{
- "key": parsers.YAML_KEY_PACKAGE,
- "name": pkg.Name,
- "project": pa[utils.OW_PROJECT_NAME]})
+ wski18n.KEY_KEY: parsers.YAML_KEY_PACKAGE,
+ wski18n.KEY_NAME: pkg.Name,
+ wski18n.KEY_PROJECT: pa[utils.OW_PROJECT_NAME]})
wskprint.PrintOpenWhiskWarning(output)
var err error
@@ -738,7 +738,7 @@ func (deployer *ServiceDeployer) DeployApis() error {
func (deployer *ServiceDeployer) createBinding(packa *whisk.BindingPackage) error {
- displayPreprocessingInfo("package binding", packa.Name, true)
+ displayPreprocessingInfo(wski18n.PACKAGE_BINDING, packa.Name, true)
var err error
var response *http.Response
@@ -748,10 +748,10 @@ func (deployer *ServiceDeployer) createBinding(packa *whisk.BindingPackage) erro
})
if err != nil {
- return createWhiskClientError(err.(*whisk.WskError), response, "package binding", true)
+ return createWhiskClientError(err.(*whisk.WskError), response, wski18n.PACKAGE_BINDING, true)
}
- displayPostprocessingInfo(parsers.PACKAGE_BINDING, packa.Name, true)
+ displayPostprocessingInfo(wski18n.PACKAGE_BINDING, packa.Name, true)
return nil
}
@@ -793,7 +793,7 @@ func (deployer *ServiceDeployer) createTrigger(trigger *whisk.Trigger) error {
func (deployer *ServiceDeployer) createFeedAction(trigger *whisk.Trigger, feedName string) error {
- displayPreprocessingInfo(parsers.TRIGGER_FEED, trigger.Name, true)
+ displayPreprocessingInfo(wski18n.TRIGGER_FEED, trigger.Name, true)
// to hold and modify trigger parameters, not passed by ref?
params := make(map[string]interface{})
@@ -803,7 +803,7 @@ func (deployer *ServiceDeployer) createFeedAction(trigger *whisk.Trigger, feedNa
params[keyVal.Key] = keyVal.Value
}
- // TODO() defone keys and lifecylce operation names as const
+ // TODO() define keys and lifecycle operation names as const
params["authKey"] = deployer.ClientConfig.AuthToken
params["lifecycleEvent"] = "CREATE"
params["triggerName"] = "/" + deployer.Client.Namespace + "/" + trigger.Name
@@ -834,7 +834,7 @@ func (deployer *ServiceDeployer) createFeedAction(trigger *whisk.Trigger, feedNa
return err
})
if err != nil {
- return createWhiskClientError(err.(*whisk.WskError), response, parsers.TRIGGER_FEED, true)
+ return createWhiskClientError(err.(*whisk.WskError), response, wski18n.TRIGGER_FEED, true)
} else {
qName, err := utils.ParseQualifiedName(feedName, deployer.ClientConfig.Namespace)
@@ -859,11 +859,11 @@ func (deployer *ServiceDeployer) createFeedAction(trigger *whisk.Trigger, feedNa
return err
})
- return createWhiskClientError(err.(*whisk.WskError), response, parsers.TRIGGER_FEED, false)
+ return createWhiskClientError(err.(*whisk.WskError), response, wski18n.TRIGGER_FEED, false)
}
}
- displayPostprocessingInfo(parsers.TRIGGER_FEED, trigger.Name, true)
+ displayPostprocessingInfo(wski18n.TRIGGER_FEED, trigger.Name, true)
return nil
}
@@ -1022,7 +1022,7 @@ func (deployer *ServiceDeployer) UnDeployDependencies() error {
for _, pack := range deployer.Deployment.Packages {
for depName, depRecord := range pack.Dependencies {
output := wski18n.T(wski18n.ID_MSG_DEPENDENCY_UNDEPLOYING_X_name_X,
- map[string]interface{}{"name": depName})
+ map[string]interface{}{wski18n.KEY_NAME: depName})
whisk.Debug(whisk.DbgInfo, output)
if depRecord.IsBinding {
@@ -1056,20 +1056,20 @@ func (deployer *ServiceDeployer) UnDeployDependencies() error {
return err
})
if err != nil {
- return createWhiskClientError(err.(*whisk.WskError), response, parsers.PACKAGE_BINDING, false)
+ return createWhiskClientError(err.(*whisk.WskError), response, wski18n.PACKAGE_BINDING, false)
}
}
}
if err := depServiceDeployer.unDeployAssets(plan); err != nil {
errString := wski18n.T(wski18n.ID_MSG_DEPENDENCY_UNDEPLOYMENT_FAILURE_X_name_X,
- map[string]interface{}{"name": depName})
+ map[string]interface{}{wski18n.KEY_NAME: depName})
whisk.Debug(whisk.DbgError, errString)
return err
}
}
output = wski18n.T(wski18n.ID_MSG_DEPENDENCY_UNDEPLOYMENT_SUCCESS_X_name_X,
- map[string]interface{}{"name": depName})
+ map[string]interface{}{wski18n.KEY_NAME: depName})
whisk.Debug(whisk.DbgInfo, output)
}
}
@@ -1217,7 +1217,7 @@ func (deployer *ServiceDeployer) deleteFeedAction(trigger *whisk.Trigger, feedNa
if err != nil {
wskErr := err.(*whisk.WskError)
errString := wski18n.T(wski18n.ID_ERR_FEED_INVOKE_X_err_X_code_X,
- map[string]interface{}{"err": wskErr.Error(), "code": strconv.Itoa(wskErr.ExitCode)})
+ map[string]interface{}{wski18n.KEY_ERR: wskErr.Error(), wski18n.KEY_CODE: strconv.Itoa(wskErr.ExitCode)})
whisk.Debug(whisk.DbgError, errString)
return wskderrors.NewWhiskClientError(wskErr.Error(), wskErr.ExitCode, response)
@@ -1293,8 +1293,11 @@ func retry(attempts int, sleep time.Duration, callback func() error) error {
wskErr := err.(*whisk.WskError)
if wskErr.ExitCode == CONFLICT_CODE && strings.Contains(wskErr.Error(), CONFLICT_MESSAGE) {
time.Sleep(sleep)
- // TODO() i18n
- whisk.Debug(whisk.DbgError, "Retrying [%s] after error: %s\n", strconv.Itoa(i+1), err)
+ warningMsg := wski18n.T(wski18n.ID_WARN_COMMAND_RETRY,
+ map[string]interface{}{
+ wski18n.KEY_CMD: strconv.Itoa(i+1),
+ wski18n.KEY_ERR: err.Error()})
+ wskprint.PrintlnOpenWhiskWarning(warningMsg)
} else {
return err
}
@@ -1460,9 +1463,9 @@ func displayPreprocessingInfo(entity string, name string, onDeploy bool){
}
msg := wski18n.T(msgKey,
map[string]interface{}{
- "key": entity,
- "name": name})
- whisk.Debug(whisk.DbgInfo, msg)
+ wski18n.KEY_KEY: entity,
+ wski18n.KEY_NAME: name})
+ wskprint.PrintlnOpenWhiskInfo(msg)
}
func displayPostprocessingInfo(entity string, name string, onDeploy bool){
@@ -1473,27 +1476,27 @@ func displayPostprocessingInfo(entity string, name string, onDeploy bool){
} else {
msgKey = wski18n.ID_MSG_ENTITY_UNDEPLOYED_SUCCESS_X_key_X_name_X
}
- errString := wski18n.T(msgKey,
+ msg := wski18n.T(msgKey,
map[string]interface{}{
- "key": entity,
- "name": name})
- whisk.Debug(whisk.DbgInfo, errString)
+ wski18n.KEY_KEY: entity,
+ wski18n.KEY_NAME: name})
+ wskprint.PrintlnOpenWhiskInfo(msg)
}
func createWhiskClientError(err *whisk.WskError, response *http.Response, entity string, onCreate bool)(*wskderrors.WhiskClientError){
var msgKey string
if onCreate{
- msgKey = wski18n.ID_ERR_CREATE_ENTITY_X_key_X_err_X_code_X
+ msgKey = wski18n.ID_ERR_ENTITY_CREATE_X_key_X_err_X_code_X
} else {
- msgKey = wski18n.ID_ERR_DELETE_ENTITY_X_key_X_err_X_code_X
+ msgKey = wski18n.ID_ERR_ENTITY_DELETE_X_key_X_err_X_code_X
}
errString := wski18n.T(msgKey,
map[string]interface{}{
- "key": entity,
- "err": err.Error(),
- "code": strconv.Itoa(err.ExitCode)})
- whisk.Debug(whisk.DbgError, errString)
+ wski18n.KEY_KEY: entity,
+ wski18n.KEY_ERR: err.Error(),
+ wski18n.KEY_CODE: strconv.Itoa(err.ExitCode)})
+ wskprint.PrintOpenWhiskVerbose(utils.Flags.Verbose, errString)
// TODO() add errString as an AppendDetail() to WhiskClientError
return wskderrors.NewWhiskClientError(err.Error(), err.ExitCode, response)
diff --git a/deployers/verifier.go b/deployers/verifier.go
index a956ee9..4743815 100644
--- a/deployers/verifier.go
+++ b/deployers/verifier.go
@@ -49,6 +49,7 @@ func (vf *Verifier) Query(deployer *ServiceDeployer) (da *DeploymentProject, err
return da, nil
}
+// TODO() function supposedly returns an error, but never does
func (vf *Verifier) Filter(deployer *ServiceDeployer, target *DeploymentProject) (rs *DeploymentProject, err error) {
//substract
for _, pa := range target.Packages {
@@ -67,6 +68,8 @@ func (vf *Verifier) Filter(deployer *ServiceDeployer, target *DeploymentProject)
}
// Convert whisk.package to whisk.SentPackageNoPublish
+// TODO() function supposedly returns an error, but never does
+// TODO() return value named "sentpackage" is instead "sp"
func convert(pa *whisk.Package) (sentpackage *whisk.Package, err error) {
sp := &whisk.Package{}
sp.Name = pa.Name
diff --git a/deployers/whiskclient.go b/deployers/whiskclient.go
index 64dba3d..715750c 100644
--- a/deployers/whiskclient.go
+++ b/deployers/whiskclient.go
@@ -34,12 +34,12 @@ import (
"github.com/apache/incubator-openwhisk-wskdeploy/wskderrors"
)
+// Possible sources for config info (e.g., API Host, Auth Key, Namespace)
const (
- COMMANDLINE = "wskdeploy command line"
- DEFAULTVALUE = "default value"
- WSKPROPS = ".wskprops"
- WHISKPROPERTY = "whisk.properties"
- INTERINPUT = "interactve input"
+ SOURCE_WSKPROPS = ".wskprops"
+ SOURCE_WHISK_PROPERTIES = "whisk.properties"
+ SOURCE_INTERACTIVE_INPUT = "interactve input" // TODO() i18n?
+ SOURCE_DEFAULT_VALUE = "wskdeploy default" // TODO() i18n?
)
type PropertyValue struct {
@@ -90,38 +90,64 @@ func NewWhiskConfig(proppath string, deploymentPath string, manifestPath string,
// read credentials from command line
apihost, auth, ns, keyfile, certfile := GetCommandLineFlags()
- credential = GetPropertyValue(credential, auth, COMMANDLINE)
- namespace = GetPropertyValue(namespace, ns, COMMANDLINE)
- apiHost = GetPropertyValue(apiHost, apihost, COMMANDLINE)
- key = GetPropertyValue(key, keyfile, COMMANDLINE)
- cert = GetPropertyValue(cert, certfile, COMMANDLINE)
-
+ credential = GetPropertyValue(credential, auth, wski18n.COMMAND_LINE)
+ namespace = GetPropertyValue(namespace, ns, wski18n.COMMAND_LINE)
+ apiHost = GetPropertyValue(apiHost, apihost, wski18n.COMMAND_LINE)
+ key = GetPropertyValue(key, keyfile, wski18n.COMMAND_LINE)
+ cert = GetPropertyValue(cert, certfile, wski18n.COMMAND_LINE)
+
+ // TODO() i18n
+ // Print all flags / values if verbose
+ wskprint.PrintlnOpenWhiskVerbose(utils.Flags.Verbose, wski18n.CONFIGURATION + ":\n" + utils.Flags.Format())
+
+ // TODO() split this logic into its own function
+ // TODO() merge with the same logic used against manifest file (below)
// now, read them from deployment file if not found on command line
if len(credential.Value) == 0 || len(namespace.Value) == 0 || len(apiHost.Value) == 0 {
if utils.FileExists(deploymentPath) {
mm := parsers.NewYAMLParser()
deployment, _ := mm.ParseDeployment(deploymentPath)
- credential = GetPropertyValue(credential, deployment.GetProject().Credential, path.Base(deploymentPath))
- namespace = GetPropertyValue(namespace, deployment.GetProject().Namespace, path.Base(deploymentPath))
- apiHost = GetPropertyValue(apiHost, deployment.GetProject().ApiHost, path.Base(deploymentPath))
+ credential = GetPropertyValue(credential,
+ deployment.GetProject().Credential,
+ path.Base(deploymentPath))
+ namespace = GetPropertyValue(namespace,
+ deployment.GetProject().Namespace,
+ path.Base(deploymentPath))
+ apiHost = GetPropertyValue(apiHost,
+ deployment.GetProject().ApiHost,
+ path.Base(deploymentPath))
}
}
+ // TODO() split this logic into its own function
+ // TODO() merge with the same logic used against deployment file (above)
// read credentials from manifest file as didn't find them on command line and in deployment file
if len(credential.Value) == 0 || len(namespace.Value) == 0 || len(apiHost.Value) == 0 {
if utils.FileExists(manifestPath) {
mm := parsers.NewYAMLParser()
manifest, _ := mm.ParseManifest(manifestPath)
if manifest.Package.Packagename != "" {
- credential = GetPropertyValue(credential, manifest.Package.Credential, path.Base(manifestPath))
- namespace = GetPropertyValue(namespace, manifest.Package.Namespace, path.Base(manifestPath))
- apiHost = GetPropertyValue(apiHost, manifest.Package.ApiHost, path.Base(manifestPath))
+ credential = GetPropertyValue(credential,
+ manifest.Package.Credential,
+ path.Base(manifestPath))
+ namespace = GetPropertyValue(namespace,
+ manifest.Package.Namespace,
+ path.Base(manifestPath))
+ apiHost = GetPropertyValue(apiHost,
+ manifest.Package.ApiHost,
+ path.Base(manifestPath))
} else if manifest.Packages != nil {
if len(manifest.Packages) == 1 {
for _, pkg := range manifest.Packages {
- credential = GetPropertyValue(credential, pkg.Credential, path.Base(manifestPath))
- namespace = GetPropertyValue(namespace, pkg.Namespace, path.Base(manifestPath))
- apiHost = GetPropertyValue(apiHost, pkg.ApiHost, path.Base(manifestPath))
+ credential = GetPropertyValue(credential,
+ pkg.Credential,
+ path.Base(manifestPath))
+ namespace = GetPropertyValue(namespace,
+ pkg.Namespace,
+ path.Base(manifestPath))
+ apiHost = GetPropertyValue(apiHost,
+ pkg.ApiHost,
+ path.Base(manifestPath))
}
}
}
@@ -135,42 +161,42 @@ func NewWhiskConfig(proppath string, deploymentPath string, manifestPath string,
// The error raised here can be neglected, because we will handle it in the end of this function.
wskprops, _ := GetWskPropFromWskprops(pi, proppath)
- credential = GetPropertyValue(credential, wskprops.AuthKey, WSKPROPS)
- namespace = GetPropertyValue(namespace, wskprops.Namespace, WSKPROPS)
- apiHost = GetPropertyValue(apiHost, wskprops.APIHost, WSKPROPS)
- key = GetPropertyValue(key, wskprops.Key, WSKPROPS)
- cert = GetPropertyValue(cert, wskprops.Cert, WSKPROPS)
+ credential = GetPropertyValue(credential, wskprops.AuthKey, SOURCE_WSKPROPS)
+ namespace = GetPropertyValue(namespace, wskprops.Namespace, SOURCE_WSKPROPS)
+ apiHost = GetPropertyValue(apiHost, wskprops.APIHost, SOURCE_WSKPROPS)
+ key = GetPropertyValue(key, wskprops.Key, SOURCE_WSKPROPS)
+ cert = GetPropertyValue(cert, wskprops.Cert, SOURCE_WSKPROPS)
// TODO() see if we can split the following whisk prop logic into a separate function
// now, read credentials from whisk.properties but this is only acceptable within Travis
// whisk.properties will soon be deprecated and should not be used for any production deployment
whiskproperty, _ := GetWskPropFromWhiskProperty(pi)
- var warnmsg string
+ var warnMsg string
- credential = GetPropertyValue(credential, whiskproperty.AuthKey, WHISKPROPERTY)
- if credential.Source == WHISKPROPERTY {
- warnmsg = wski18n.T(wski18n.ID_WARN_WHISK_PROPS_DEPRECATED,
- map[string]interface{}{"key": "authenticaton key"})
- wskprint.PrintlnOpenWhiskWarning(warnmsg)
+ credential = GetPropertyValue(credential, whiskproperty.AuthKey, SOURCE_WHISK_PROPERTIES)
+ if credential.Source == SOURCE_WHISK_PROPERTIES {
+ warnMsg = wski18n.T(wski18n.ID_WARN_WHISK_PROPS_DEPRECATED,
+ map[string]interface{}{wski18n.KEY_KEY: wski18n.AUTH_KEY})
+ wskprint.PrintlnOpenWhiskWarning(warnMsg)
}
- namespace = GetPropertyValue(namespace, whiskproperty.Namespace, WHISKPROPERTY)
- if namespace.Source == WHISKPROPERTY {
- warnmsg = wski18n.T(wski18n.ID_WARN_WHISK_PROPS_DEPRECATED,
- map[string]interface{}{"key": "namespace"})
- wskprint.PrintlnOpenWhiskWarning(warnmsg)
+ namespace = GetPropertyValue(namespace, whiskproperty.Namespace, SOURCE_WHISK_PROPERTIES)
+ if namespace.Source == SOURCE_WHISK_PROPERTIES {
+ warnMsg = wski18n.T(wski18n.ID_WARN_WHISK_PROPS_DEPRECATED,
+ map[string]interface{}{wski18n.KEY_KEY: parsers.YAML_KEY_NAMESPACE})
+ wskprint.PrintlnOpenWhiskWarning(warnMsg)
}
- apiHost = GetPropertyValue(apiHost, whiskproperty.APIHost, WHISKPROPERTY)
- if apiHost.Source == WHISKPROPERTY {
- warnmsg = wski18n.T(wski18n.ID_WARN_WHISK_PROPS_DEPRECATED,
- map[string]interface{}{"key": "API host"})
- wskprint.PrintlnOpenWhiskWarning(warnmsg)
+ apiHost = GetPropertyValue(apiHost, whiskproperty.APIHost, SOURCE_WHISK_PROPERTIES)
+ if apiHost.Source == SOURCE_WHISK_PROPERTIES {
+ warnMsg = wski18n.T(wski18n.ID_WARN_WHISK_PROPS_DEPRECATED,
+ map[string]interface{}{wski18n.KEY_KEY: wski18n.API_HOST})
+ wskprint.PrintlnOpenWhiskWarning(warnMsg)
}
// set namespace to default namespace if not yet found
if len(apiHost.Value) != 0 && len(credential.Value) != 0 && len(namespace.Value) == 0 {
namespace.Value = whisk.DEFAULT_NAMESPACE
- namespace.Source = DEFAULTVALUE
+ namespace.Source = SOURCE_DEFAULT_VALUE
}
// TODO() See if we can split off the interactive logic into a separate function
@@ -185,22 +211,23 @@ func NewWhiskConfig(proppath string, deploymentPath string, manifestPath string,
host = "openwhisk.ng.bluemix.net"
}
apiHost.Value = host
- apiHost.Source = INTERINPUT
+ apiHost.Source = SOURCE_INTERACTIVE_INPUT
}
if len(credential.Value) == 0 && isInteractive == true {
cred := promptForValue(wski18n.T(wski18n.ID_MSG_PROMPT_AUTHKEY))
credential.Value = cred
- credential.Source = INTERINPUT
+ credential.Source = SOURCE_INTERACTIVE_INPUT
- // The namespace is always associated with the credential. Both of them should be picked up from the same source.
+ // The namespace is always associated with the credential.
+ // Both of them should be picked up from the same source.
if len(namespace.Value) == 0 || namespace.Value == whisk.DEFAULT_NAMESPACE {
tempNamespace := promptForValue(wski18n.T(wski18n.ID_MSG_PROMPT_NAMESPACE))
- source := INTERINPUT
+ source := SOURCE_INTERACTIVE_INPUT
if tempNamespace == "" {
tempNamespace = whisk.DEFAULT_NAMESPACE
- source = DEFAULTVALUE
+ source = SOURCE_DEFAULT_VALUE
}
namespace.Value = tempNamespace
@@ -217,7 +244,7 @@ func NewWhiskConfig(proppath string, deploymentPath string, manifestPath string,
AuthToken: credential.Value, //Authtoken
Namespace: namespace.Value, //Namespace
Host: apiHost.Value,
- Version: "v1",
+ Version: "v1", // TODO() should not be hardcoded, should prompt/warn user of default
Cert: cert.Value,
Key: key.Value,
Insecure: mode, // true if you want to ignore certificate signing
@@ -225,7 +252,6 @@ func NewWhiskConfig(proppath string, deploymentPath string, manifestPath string,
// validate we have credential, apihost and namespace
err := validateClientConfig(credential, apiHost, namespace)
-
return clientConfig, err
}
@@ -251,21 +277,21 @@ func validateClientConfig(credential PropertyValue, apiHost PropertyValue, names
// Show caller what final values we used for credential, apihost and namespace
stdout := wski18n.T(wski18n.ID_MSG_CONFIG_INFO_APIHOST_X_host_X_source_X,
- map[string]interface{}{"host": apiHost.Value, "source": apiHost.Source})
- wskprint.PrintOpenWhiskStatus(stdout)
+ map[string]interface{}{wski18n.KEY_HOST: apiHost.Value, wski18n.KEY_SOURCE: apiHost.Source})
+ wskprint.PrintOpenWhiskInfo(stdout)
stdout = wski18n.T(wski18n.ID_MSG_CONFIG_INFO_AUTHKEY_X_source_X,
- map[string]interface{}{"source": credential.Source})
- wskprint.PrintOpenWhiskStatus(stdout)
+ map[string]interface{}{wski18n.KEY_SOURCE: credential.Source})
+ wskprint.PrintOpenWhiskInfo(stdout)
stdout = wski18n.T(wski18n.ID_MSG_CONFIG_INFO_NAMESPACE_X_namespace_X_source_X,
- map[string]interface{}{"namespace": namespace.Value, "source": namespace.Source})
- wskprint.PrintOpenWhiskStatus(stdout)
+ map[string]interface{}{wski18n.KEY_NAMESPACE: namespace.Value, wski18n.KEY_SOURCE: namespace.Source})
+ wskprint.PrintOpenWhiskInfo(stdout)
return nil
}
-// TODO() move into its own package "wskread" and add support for passing in default value
+// TODO() perhaps move into its own package "wskread" and add support for passing in default value
var promptForValue = func(msg string) (string) {
reader := bufio.NewReader(os.Stdin)
fmt.Print(msg)
diff --git a/deployers/whiskclient_test.go b/deployers/whiskclient_test.go
index fca9429..5f81e03 100644
--- a/deployers/whiskclient_test.go
+++ b/deployers/whiskclient_test.go
@@ -43,16 +43,16 @@ const (
WSKPROPS_AUTH = "a4f8c502:123zO3xZCLrMN6v2BKK"
WSKPROPS_NAMESPACE = "guest"
- WSKPROPS_KEY = "test_key_file"
- WSKPROPS_CERT = "test_cert_file"
+ WSKPROPS_KEY = "test_key_file"
+ WSKPROPS_CERT = "test_cert_file"
)
func initializeFlags() {
- utils.Flags.Auth = ""
- utils.Flags.Namespace = ""
- utils.Flags.ApiHost = ""
- utils.Flags.Key = ""
- utils.Flags.Cert = ""
+ utils.Flags.Auth = ""
+ utils.Flags.Namespace = ""
+ utils.Flags.ApiHost = ""
+ utils.Flags.Key = ""
+ utils.Flags.Cert = ""
}
func TestNewWhiskConfig(t *testing.T) {
@@ -61,7 +61,7 @@ func TestNewWhiskConfig(t *testing.T) {
deploymentPath := ""
config, err := NewWhiskConfig(propPath, deploymentPath, manifestPath, false)
if err == nil {
- pi := whisk.PropertiesImp {
+ pi := whisk.PropertiesImp{
OsPackage: whisk.OSPackageImp{},
}
wskprops, err := whisk.GetDefaultWskProp(pi)
@@ -85,23 +85,23 @@ func TestNewWhiskConfigCommandLine(t *testing.T) {
config, err := NewWhiskConfig(propPath, deploymentPath, manifestPath, false)
assert.Nil(t, err, "Failed to read credentials from wskdeploy command line")
- assert.Equal(t, CLI_HOST, config.Host, "Failed to get host name from wskdeploy command line")
- assert.Equal(t, CLI_AUTH, config.AuthToken, "Failed to get auth token from wskdeploy command line")
- assert.Equal(t, CLI_NAMESPACE, config.Namespace, "Failed to get namespace from wskdeploy command line")
- assert.True(t, config.Insecure, "Config should set insecure to true")
-
- utils.Flags.Key = WSKPROPS_KEY
- utils.Flags.Cert = WSKPROPS_CERT
- config, err = NewWhiskConfig(propPath, deploymentPath, manifestPath, false)
- assert.Nil(t, err, "Failed to read credentials from wskdeploy command line")
- assert.Equal(t, CLI_HOST, config.Host, "Failed to get host name from wskdeploy command line")
- assert.Equal(t, CLI_AUTH, config.AuthToken, "Failed to get auth token from wskdeploy command line")
- assert.Equal(t, CLI_NAMESPACE, config.Namespace, "Failed to get namespace from wskdeploy command line")
- assert.Equal(t, WSKPROPS_KEY, config.Key, "Failed to get key file from wskdeploy command line")
- assert.Equal(t, WSKPROPS_CERT, config.Cert, "Failed to get cert file from wskdeploy command line")
- assert.False(t, config.Insecure, "Config should set insecure to false")
-
- initializeFlags()
+ assert.Equal(t, CLI_HOST, config.Host, "Failed to get host name from wskdeploy command line")
+ assert.Equal(t, CLI_AUTH, config.AuthToken, "Failed to get auth token from wskdeploy command line")
+ assert.Equal(t, CLI_NAMESPACE, config.Namespace, "Failed to get namespace from wskdeploy command line")
+ assert.True(t, config.Insecure, "Config should set insecure to true")
+
+ utils.Flags.Key = WSKPROPS_KEY
+ utils.Flags.Cert = WSKPROPS_CERT
+ config, err = NewWhiskConfig(propPath, deploymentPath, manifestPath, false)
+ assert.Nil(t, err, "Failed to read credentials from wskdeploy command line")
+ assert.Equal(t, CLI_HOST, config.Host, "Failed to get host name from wskdeploy command line")
+ assert.Equal(t, CLI_AUTH, config.AuthToken, "Failed to get auth token from wskdeploy command line")
+ assert.Equal(t, CLI_NAMESPACE, config.Namespace, "Failed to get namespace from wskdeploy command line")
+ assert.Equal(t, WSKPROPS_KEY, config.Key, "Failed to get key file from wskdeploy command line")
+ assert.Equal(t, WSKPROPS_CERT, config.Cert, "Failed to get cert file from wskdeploy command line")
+ assert.False(t, config.Insecure, "Config should set insecure to false")
+
+ initializeFlags()
}
func TestNewWhiskConfigDeploymentFile(t *testing.T) {
@@ -113,7 +113,7 @@ func TestNewWhiskConfigDeploymentFile(t *testing.T) {
assert.Equal(t, DEPLOYMENT_HOST, config.Host, "Failed to get host name from deployment file")
assert.Equal(t, DEPLOYMENT_AUTH, config.AuthToken, "Failed to get auth token from deployment file")
assert.Equal(t, DEPLOYMENT_NAMESPACE, config.Namespace, "Failed to get namespace from deployment file")
- assert.True(t, config.Insecure, "Config should set insecure to true")
+ assert.True(t, config.Insecure, "Config should set insecure to true")
}
func TestNewWhiskConfigManifestFile(t *testing.T) {
@@ -125,10 +125,9 @@ func TestNewWhiskConfigManifestFile(t *testing.T) {
assert.Equal(t, MANIFEST_HOST, config.Host, "Failed to get host name from manifest file")
assert.Equal(t, MANIFEST_AUTH, config.AuthToken, "Failed to get auth token from manifest file")
assert.Equal(t, MANIFEST_NAMESPACE, config.Namespace, "Failed to get namespace from manifest file")
- assert.True(t, config.Insecure, "Config should set insecure to true")
+ assert.True(t, config.Insecure, "Config should set insecure to true")
}
-
func TestNewWhiskConfigWithWskProps(t *testing.T) {
propPath := "../tests/dat/wskprops"
manifestPath := ""
@@ -138,22 +137,22 @@ func TestNewWhiskConfigWithWskProps(t *testing.T) {
assert.Equal(t, WSKPROPS_HOST, config.Host, "Failed to get host name from wskprops")
assert.Equal(t, WSKPROPS_AUTH, config.AuthToken, "Failed to get auth token from wskprops")
assert.Equal(t, WSKPROPS_NAMESPACE, config.Namespace, "Failed to get namespace from wskprops")
- assert.Equal(t, WSKPROPS_KEY, config.Key, "Failed to get key file from wskprops")
- assert.Equal(t, WSKPROPS_CERT, config.Cert, "Failed to get cert file from wskprops")
- assert.False(t, config.Insecure, "Config should set insecure to false")
-
- propPath = "../tests/dat/wskpropsnokeycert"
- config, err = NewWhiskConfig(propPath, deploymentPath, manifestPath, false)
- assert.Nil(t, err, "Failed to read credentials from wskprops")
- assert.Equal(t, WSKPROPS_HOST, config.Host, "Failed to get host name from wskprops")
- assert.Equal(t, WSKPROPS_AUTH, config.AuthToken, "Failed to get auth token from wskprops")
- assert.Equal(t, WSKPROPS_NAMESPACE, config.Namespace, "Failed to get namespace from wskprops")
- assert.Empty(t, config.Key, "Failed to get key file from wskprops")
- assert.Empty(t, config.Cert, "Failed to get cert file from wskprops")
- assert.True(t, config.Insecure, "Config should set insecure to true")
+ assert.Equal(t, WSKPROPS_KEY, config.Key, "Failed to get key file from wskprops")
+ assert.Equal(t, WSKPROPS_CERT, config.Cert, "Failed to get cert file from wskprops")
+ assert.False(t, config.Insecure, "Config should set insecure to false")
+
+ propPath = "../tests/dat/wskpropsnokeycert"
+ config, err = NewWhiskConfig(propPath, deploymentPath, manifestPath, false)
+ assert.Nil(t, err, "Failed to read credentials from wskprops")
+ assert.Equal(t, WSKPROPS_HOST, config.Host, "Failed to get host name from wskprops")
+ assert.Equal(t, WSKPROPS_AUTH, config.AuthToken, "Failed to get auth token from wskprops")
+ assert.Equal(t, WSKPROPS_NAMESPACE, config.Namespace, "Failed to get namespace from wskprops")
+ assert.Empty(t, config.Key, "Failed to get key file from wskprops")
+ assert.Empty(t, config.Cert, "Failed to get cert file from wskprops")
+ assert.True(t, config.Insecure, "Config should set insecure to true")
}
-// (TODO) add the following test
+// TODO(#693) add the following test
/*func TestNewWhiskConfigInteractiveMode(t *testing.T) {
propPath := ""
manifestPath := ""
@@ -176,12 +175,11 @@ func TestNewWhiskConfigWithCLIDeploymentAndManifestFile(t *testing.T) {
assert.Equal(t, config.Host, CLI_HOST, "Failed to get host name from wskdeploy CLI")
assert.Equal(t, config.AuthToken, CLI_AUTH, "Failed to get auth token from wskdeploy CLI")
assert.Equal(t, config.Namespace, CLI_NAMESPACE, "Failed to get namespace from wskdeploy CLI")
- assert.True(t, config.Insecure, "Config should set insecure to true")
+ assert.True(t, config.Insecure, "Config should set insecure to true")
- initializeFlags()
+ initializeFlags()
}
-
func TestNewWhiskConfigWithCLIAndDeployment(t *testing.T) {
propPath := ""
manifestPath := "../tests/dat/deployment_validate_credentials.yaml"
@@ -196,9 +194,9 @@ func TestNewWhiskConfigWithCLIAndDeployment(t *testing.T) {
assert.Equal(t, config.Host, CLI_HOST, "Failed to get host name from wskdeploy CLI")
assert.Equal(t, config.AuthToken, CLI_AUTH, "Failed to get auth token from wskdeploy CLI")
assert.Equal(t, config.Namespace, CLI_NAMESPACE, "Failed to get namespace from wskdeploy CLI")
- assert.True(t, config.Insecure, "Config should set insecure to true")
+ assert.True(t, config.Insecure, "Config should set insecure to true")
- initializeFlags()
+ initializeFlags()
}
func TestNewWhiskConfigWithCLIAndManifest(t *testing.T) {
@@ -215,9 +213,9 @@ func TestNewWhiskConfigWithCLIAndManifest(t *testing.T) {
assert.Equal(t, config.Host, CLI_HOST, "Failed to get host name from wskdeploy CLI")
assert.Equal(t, config.AuthToken, CLI_AUTH, "Failed to get auth token from wskdeploy CLI")
assert.Equal(t, config.Namespace, CLI_NAMESPACE, "Failed to get namespace from wskdeploy CLI")
- assert.True(t, config.Insecure, "Config should set insecure to true")
+ assert.True(t, config.Insecure, "Config should set insecure to true")
- initializeFlags()
+ initializeFlags()
}
func TestNewWhiskConfigWithCLIAndWskProps(t *testing.T) {
@@ -233,9 +231,9 @@ func TestNewWhiskConfigWithCLIAndWskProps(t *testing.T) {
assert.Equal(t, config.Host, CLI_HOST, "Failed to get host name from wskdeploy command line")
assert.Equal(t, config.AuthToken, CLI_AUTH, "Failed to get auth token from wskdeploy command line")
assert.Equal(t, config.Namespace, CLI_NAMESPACE, "Failed to get namespace from wskdeploy command line")
- assert.True(t, config.Insecure, "Config should set insecure to true")
+ assert.True(t, config.Insecure, "Config should set insecure to true")
- initializeFlags()
+ initializeFlags()
}
func TestNewWhiskConfigWithDeploymentAndManifestFile(t *testing.T) {
@@ -247,5 +245,5 @@ func TestNewWhiskConfigWithDeploymentAndManifestFile(t *testing.T) {
assert.Equal(t, config.Host, DEPLOYMENT_HOST, "Failed to get host name from deployment file")
assert.Equal(t, config.AuthToken, DEPLOYMENT_AUTH, "Failed to get auth token from deployment file")
assert.Equal(t, config.Namespace, DEPLOYMENT_NAMESPACE, "Failed to get namespace from deployment file")
- assert.True(t, config.Insecure, "Config should set insecure to true")
+ assert.True(t, config.Insecure, "Config should set insecure to true")
}
diff --git a/parsers/manifest_parser.go b/parsers/manifest_parser.go
index 82a4b52..37d318e 100644
--- a/parsers/manifest_parser.go
+++ b/parsers/manifest_parser.go
@@ -77,8 +77,6 @@ func (dm *YAMLParser) Unmarshal(input []byte, manifest *YAML) error {
func (dm *YAMLParser) marshal(manifest *YAML) (output []byte, err error) {
data, err := yaml.Marshal(manifest)
if err != nil {
- // TODO() i18n
- fmt.Printf("err happened during marshal :%v", err)
return nil, err
}
return data, nil
@@ -159,8 +157,8 @@ func (dm *YAMLParser) ComposeDependencies(pkg Package, projectPath string, fileP
isBinding = false
} else {
- // TODO() i18n
- return nil, errors.New("Dependency type is unknown. wskdeploy only supports /whisk.system bindings or github.com packages.")
+ // TODO() create new named error in wskerrors package
+ return nil, errors.New(wski18n.T(wski18n.ID_ERR_DEPENDENCY_UNKNOWN_TYPE))
}
keyValArrParams := make(whisk.KeyValueArr, 0)
@@ -245,15 +243,15 @@ func (dm *YAMLParser) ComposePackage(pkg Package, packageName string, filePath s
// TODO(#673) implement STRICT flag
if pkg.Version == "" {
warningString := wski18n.T(
- wski18n.ID_WARN_MISSING_MANDATORY_KEY_X_key_X_value_X,
+ wski18n.ID_WARN_KEY_MISSING_X_key_X_value_X,
map[string]interface{}{
- wski18n.KEY_KEY: PACKAGE_VERSION,
+ wski18n.KEY_KEY: wski18n.PACKAGE_VERSION,
wski18n.KEY_VALUE: DEFAULT_PACKAGE_VERSION})
wskprint.PrintOpenWhiskWarning(warningString)
warningString = wski18n.T(
wski18n.ID_WARN_KEYVALUE_NOT_SAVED_X_key_X,
- map[string]interface{}{wski18n.KEY_KEY: PACKAGE_VERSION})
+ map[string]interface{}{wski18n.KEY_KEY: wski18n.PACKAGE_VERSION})
wskprint.PrintOpenWhiskWarning(warningString)
pkg.Version = DEFAULT_PACKAGE_VERSION
@@ -265,15 +263,15 @@ func (dm *YAMLParser) ComposePackage(pkg Package, packageName string, filePath s
// TODO(#673) implement STRICT flag
if pkg.License == "" {
warningString := wski18n.T(
- wski18n.ID_WARN_MISSING_MANDATORY_KEY_X_key_X_value_X,
+ wski18n.ID_WARN_KEY_MISSING_X_key_X_value_X,
map[string]interface{}{
- wski18n.KEY_KEY: PACKAGE_LICENSE,
+ wski18n.KEY_KEY: wski18n.PACKAGE_LICENSE,
wski18n.KEY_VALUE: DEFAULT_PACKAGE_LICENSE})
wskprint.PrintOpenWhiskWarning(warningString)
warningString = wski18n.T(
wski18n.ID_WARN_KEYVALUE_NOT_SAVED_X_key_X,
- map[string]interface{}{wski18n.KEY_KEY: PACKAGE_VERSION})
+ map[string]interface{}{wski18n.KEY_KEY: wski18n.PACKAGE_VERSION})
wskprint.PrintOpenWhiskWarning(warningString)
@@ -423,8 +421,6 @@ func (dm *YAMLParser) ComposeActionsFromAllPackages(manifest *YAML, filePath str
func (dm *YAMLParser) ComposeActions(filePath string, actions map[string]Action, packageName string, ma whisk.KeyValue) ([]utils.ActionRecord, error) {
- // TODO() i18n
- const RUNTIME_ERR_MESSAGE = "Please specify any of the supported runtime for zip actions in manifest YAML."
var errorParser error
var ext string
var s1 []utils.ActionRecord = make([]utils.ActionRecord, 0)
@@ -482,9 +478,15 @@ func (dm *YAMLParser) ComposeActions(filePath string, actions map[string]Action,
// and its not explicitly specified in the manifest YAML file
// and action source is not a zip file
if len(kind) == 0 && len(action.Runtime) == 0 && ext != utils.ZIP_FILE_EXTENSION {
- // TODO() i18n
- errMessage := "ERROR: Failed to discover runtime from the action source files. " + RUNTIME_ERR_MESSAGE
- return nil, wskderrors.NewInvalidRuntimeError(errMessage, splitFilePath[len(splitFilePath)-1], action.Name, "Not Specified in Manifest YAML", utils.ListOfSupportedRuntimes(utils.SupportedRunTimes))
+ errMessage := wski18n.T(wski18n.ID_ERR_RUNTIME_MISMATCH_X_runtime_X_ext_X_action_X,
+ map[string]interface{}{
+ wski18n.KEY_RUNTIME: action.Runtime,
+ wski18n.KEY_EXTENTION: ext,
+ wski18n.KEY_ACTION: action.Name})
+ return nil, wskderrors.NewInvalidRuntimeError(errMessage,
+ splitFilePath[len(splitFilePath)-1], action.Name,
+ action.Runtime,
+ utils.ListOfSupportedRuntimes(utils.SupportedRunTimes))
}
wskaction.Exec.Kind = kind
@@ -499,9 +501,15 @@ func (dm *YAMLParser) ComposeActions(filePath string, actions map[string]Action,
code = base64.StdEncoding.EncodeToString([]byte(dat))
}
if ext == utils.ZIP_FILE_EXTENSION && len(action.Runtime) == 0 {
- // TODO() i18n
- errMessage := "ERROR: Runtime is missing for zip action. " + RUNTIME_ERR_MESSAGE
- return nil, wskderrors.NewInvalidRuntimeError(errMessage, splitFilePath[len(splitFilePath)-1], action.Name, "Not Specified in Manifest YAML", utils.ListOfSupportedRuntimes(utils.SupportedRunTimes))
+ errMessage := wski18n.T(wski18n.ID_ERR_RUNTIME_INVALID_X_runtime_X_action_X,
+ map[string]interface{}{
+ wski18n.KEY_RUNTIME: action.Runtime,
+ wski18n.KEY_ACTION: action.Name})
+ return nil, wskderrors.NewInvalidRuntimeError(errMessage,
+ splitFilePath[len(splitFilePath)-1],
+ action.Name,
+ action.Runtime,
+ utils.ListOfSupportedRuntimes(utils.SupportedRunTimes))
}
wskaction.Exec.Code = &code
}
@@ -525,33 +533,46 @@ func (dm *YAMLParser) ComposeActions(filePath string, actions map[string]Action,
if utils.CheckRuntimeConsistencyWithFileExtension(ext, action.Runtime) {
wskaction.Exec.Kind = action.Runtime
} else {
- errStr := wski18n.T(wski18n.ID_MSG_RUNTIME_MISMATCH_X_runtime_X_ext_X_action_X,
- map[string]interface{}{"runtime": action.Runtime, "ext": ext, "action": action.Name})
- wskprint.PrintOpenWhiskWarning(errStr)
+ warnStr := wski18n.T(wski18n.ID_ERR_RUNTIME_MISMATCH_X_runtime_X_ext_X_action_X,
+ map[string]interface{}{
+ wski18n.KEY_RUNTIME: action.Runtime,
+ wski18n.KEY_EXTENTION: ext,
+ wski18n.KEY_ACTION: action.Name})
+ wskprint.PrintOpenWhiskWarning(warnStr)
// even if runtime is not consistent with file extension, deploy action with specified runtime in strict mode
if utils.Flags.Strict {
wskaction.Exec.Kind = action.Runtime
} else {
- errStr := wski18n.T(wski18n.ID_MSG_RUNTIME_CHANGED_X_runtime_X_action_X,
- map[string]interface{}{"runtime": wskaction.Exec.Kind, "action": action.Name})
- wskprint.PrintOpenWhiskWarning(errStr)
+ warnStr := wski18n.T(wski18n.ID_WARN_RUNTIME_CHANGED_X_runtime_X_action_X,
+ map[string]interface{}{
+ wski18n.KEY_RUNTIME: wskaction.Exec.Kind,
+ wski18n.KEY_ACTION: action.Name})
+ wskprint.PrintOpenWhiskWarning(warnStr)
}
}
}
} else {
- errStr := wski18n.T(wski18n.ID_MSG_RUNTIME_UNSUPPORTED_X_runtime_X_action_X,
- map[string]interface{}{"runtime": action.Runtime, "action": action.Name})
- whisk.Debug(whisk.DbgWarn, errStr)
+ warnStr := wski18n.T(wski18n.ID_ERR_RUNTIME_INVALID_X_runtime_X_action_X,
+ map[string]interface{}{
+ wski18n.KEY_RUNTIME: action.Runtime,
+ wski18n.KEY_ACTION: action.Name})
+ wskprint.PrintOpenWhiskWarning(warnStr)
+
if ext == utils.ZIP_FILE_EXTENSION {
- // TODO() i18n
- // for zip action, error out if specified runtime is not supported by OpenWhisk server
- errMessage := "ERROR: Given runtime for a zip action is not supported by OpenWhisk server. " + RUNTIME_ERR_MESSAGE
- return nil, wskderrors.NewInvalidRuntimeError(errMessage, splitFilePath[len(splitFilePath)-1], action.Name, action.Runtime, utils.ListOfSupportedRuntimes(utils.SupportedRunTimes))
+ // for zip action, error out if specified runtime is not supported by
+ // OpenWhisk server
+ return nil, wskderrors.NewInvalidRuntimeError(warnStr,
+ splitFilePath[len(splitFilePath)-1],
+ action.Name,
+ action.Runtime,
+ utils.ListOfSupportedRuntimes(utils.SupportedRunTimes))
} else {
- errStr = wski18n.T(wski18n.ID_MSG_RUNTIME_CHANGED_X_runtime_X_action_X,
- map[string]interface{}{"runtime": wskaction.Exec.Kind, "action": action.Name})
- whisk.Debug(whisk.DbgWarn, errStr)
+ warnStr := wski18n.T(wski18n.ID_WARN_RUNTIME_CHANGED_X_runtime_X_action_X,
+ map[string]interface{}{
+ wski18n.KEY_RUNTIME: wskaction.Exec.Kind,
+ wski18n.KEY_ACTION: action.Name})
+ wskprint.PrintOpenWhiskWarning(warnStr)
}
}
@@ -650,21 +671,21 @@ func (dm *YAMLParser) ComposeActions(filePath string, actions map[string]Action,
if utils.LimitsTimeoutValidation(action.Limits.Timeout) {
wsklimits.Timeout = action.Limits.Timeout
} else {
- warningString := wski18n.T(wski18n.ID_MSG_ACTION_LIMIT_IGNORED_X_limit_X,
+ warningString := wski18n.T(wski18n.ID_WARN_LIMIT_IGNORED_X_limit_X,
map[string]interface{}{wski18n.KEY_LIMIT: LIMIT_VALUE_TIMEOUT})
wskprint.PrintOpenWhiskWarning(warningString)
}
if utils.LimitsMemoryValidation(action.Limits.Memory) {
wsklimits.Memory = action.Limits.Memory
} else {
- warningString := wski18n.T(wski18n.ID_MSG_ACTION_LIMIT_IGNORED_X_limit_X,
+ warningString := wski18n.T(wski18n.ID_WARN_LIMIT_IGNORED_X_limit_X,
map[string]interface{}{wski18n.KEY_LIMIT: LIMIT_VALUE_MEMORY_SIZE})
wskprint.PrintOpenWhiskWarning(warningString)
}
if utils.LimitsLogsizeValidation(action.Limits.Logsize) {
wsklimits.Logsize = action.Limits.Logsize
} else {
- warningString := wski18n.T(wski18n.ID_MSG_ACTION_LIMIT_IGNORED_X_limit_X,
+ warningString := wski18n.T(wski18n.ID_WARN_LIMIT_IGNORED_X_limit_X,
map[string]interface{}{wski18n.KEY_LIMIT: LIMIT_VALUE_LOG_SIZE})
wskprint.PrintOpenWhiskWarning(warningString)
}
@@ -729,13 +750,12 @@ func (dm *YAMLParser) ComposeTriggers(filePath string, pkg Package, ma whisk.Key
// print warning information when .Source key's value is not empty
if trigger.Source != "" {
- // TODO() i18n use const for keys and values on string
warningString := wski18n.T(
- wski18n.ID_WARN_DEPRECATED_KEY_REPLACED_X_oldkey_X_filetype_X_newkey_X,
+ wski18n.ID_WARN_KEY_DEPRECATED_X_oldkey_X_filetype_X_newkey_X,
map[string]interface{}{
- wski18n.KEY_OLD: "source",
+ wski18n.KEY_OLD: YAML_KEY_SOURCE,
wski18n.KEY_NEW: YAML_KEY_FEED,
- wski18n.KEY_FILE_TYPE: "manifest"})
+ wski18n.KEY_FILE_TYPE: wski18n.MANIFEST})
wskprint.PrintOpenWhiskWarning(warningString)
}
if trigger.Feed == "" {
diff --git a/parsers/yamlparser.go b/parsers/yamlparser.go
index fd7a24c..6bcee66 100644
--- a/parsers/yamlparser.go
+++ b/parsers/yamlparser.go
@@ -23,25 +23,21 @@ import (
)
// YAML schema key names
+// DO NOT translate
const(
- YAML_KEY_PROJECT = "project"
- YAML_KEY_APPLICATION = "application" // deprecated
- YAML_KEY_PACKAGE = "package"
YAML_KEY_ACTION = "action"
- YAML_KEY_TRIGGER = "trigger"
- YAML_KEY_RULE = "rule"
- YAML_KEY_FEED = "feed"
+ YAML_KEY_ANNOTATION = "annotoation"
YAML_KEY_API = "api"
+ YAML_KEY_FEED = "feed"
+ YAML_KEY_NAMESPACE = "namespace"
+ YAML_KEY_PACKAGES = "packages"
+ YAML_KEY_PROJECT = "project"
+ YAML_KEY_RULE = "rule"
YAML_KEY_SEQUENCE = "sequence"
-)
-
-// descriptive key names
-const (
- PROJECT_NAME = "project name"
- PACKAGE_BINDING = "package binding"
- PACKAGE_VERSION = "package version"
- PACKAGE_LICENSE = "package license"
- TRIGGER_FEED = "trigger feed"
+ YAML_KEY_TRIGGER = "trigger"
+ YAML_KEY_APPLICATION = "application" // deprecated
+ YAML_KEY_PACKAGE = "package" // deprecated
+ YAML_KEY_SOURCE = "source" // deprecated
)
// YAML schema key values
@@ -165,7 +161,7 @@ type Feed struct {
Inputs map[string]string `yaml:"inputs"` //used in deployment.yaml
Location string `yaml:"location"` //used in manifest.yaml
Action string `yaml:"action"` //used in manifest.yaml
- //TODO: need to define operation structure
+ // TODO(): need to define operation structure
Operations map[string]interface{} `yaml:"operations"` //used in manifest.yaml
Name string
}
diff --git a/utils/flags.go b/utils/flags.go
index 2a31256..6cbc0d9 100644
--- a/utils/flags.go
+++ b/utils/flags.go
@@ -17,7 +17,12 @@
package utils
-var Flags struct {
+import (
+ "fmt"
+ "reflect"
+)
+
+type WskDeployFlags struct {
WithinOpenWhisk bool // is this running within an OpenWhisk action?
ApiHost string // OpenWhisk API host
Auth string // OpenWhisk API key
@@ -36,20 +41,28 @@ var Flags struct {
Key string
Cert string
Managed bool // OpenWhisk Managed Deployments
+}
+
+func (flags *WskDeployFlags) Format() string {
+
+ flagNames := reflect.TypeOf(*flags)
+ flagValues := reflect.ValueOf(*flags)
- //action flag definition
- //from go cli
- action struct {
- docker bool
- copy bool
- pipe bool
- web string
- sequence bool
- timeout int
- memory int
- logsize int
- result bool
- kind string
- main string
+ var name string
+ var value interface{}
+ //var t interface{}
+ var result string
+
+ for i := 0; i < flagValues.NumField(); i++ {
+ name = flagNames.Field(i).Name
+ value = flagValues.Field(i)
+ // NOTE: if you need to see the Type, add this line to output
+ //t = flagValues.Field(i).Type()
+ line := fmt.Sprintf(" > %s: [%v]\n", name, value)
+ result += line
}
+
+ return result
}
+
+var Flags WskDeployFlags
diff --git a/utils/runtimes.go b/utils/runtimes.go
index bacc54d..ed22fa0 100644
--- a/utils/runtimes.go
+++ b/utils/runtimes.go
@@ -94,7 +94,7 @@ func ParseOpenWhisk(apiHost string) (op OpenWhiskInfo, err error) {
res, err := netClient.Do(req)
if err != nil {
// TODO() create an error
- errString := wski18n.T(wski18n.ID_ERR_GET_RUNTIMES_X_err_X,
+ errString := wski18n.T(wski18n.ID_ERR_RUNTIMES_GET_X_err_X,
map[string]interface{}{"err": err.Error()})
whisk.Debug(whisk.DbgWarn, errString)
}
diff --git a/utils/validation.go b/utils/validation.go
index 9e17088..2f926af 100644
--- a/utils/validation.go
+++ b/utils/validation.go
@@ -109,6 +109,7 @@ func LicenseRemoteValidation(license string) bool {
if len(license_json.Licenses) == 0 {
json_data, err := Read(RemoteLicenseURL)
if err != nil {
+ // TODO() i18n
errString := wski18n.T("Failed to get the remote license json.\n")
whisk.Debug(whisk.DbgError, errString)
return false
@@ -117,6 +118,7 @@ func LicenseRemoteValidation(license string) bool {
//parse json
err = json.Unmarshal(json_data, &license_json)
if err != nil || len(license_json.Licenses) == 0 {
+ // TODO() i18n
errString := wski18n.T("Failed to parse the remote license json.\n")
whisk.Debug(whisk.DbgError, errString)
return false
diff --git a/wski18n/i18n_ids.go b/wski18n/i18n_ids.go
index af599fa..8f8b544 100644
--- a/wski18n/i18n_ids.go
+++ b/wski18n/i18n_ids.go
@@ -17,29 +17,81 @@
package wski18n
+// descriptive key names
+// DO NOT TRANSLATE
+const (
+ ACTION_CODE = "Action source"
+ ACTIONS = "Actions"
+ ACTIVATIONS = "Activations"
+ API_HOST = "API host"
+ AUTH_KEY = "authentication key"
+ COMMAND_LINE = "wskdeploy command line"
+ DEPLOYMENT = "deployment"
+ CONFIGURATION = "Configuration"
+ MANIFEST = "manifest"
+ NAME_ACTION = "Action Name"
+ NAME_FEED = "Feed Name"
+ NAME_RULE = "Rule Name"
+ NAME_RUNTIME = "Runtime Name"
+ NAME_TRIGGER = "Trigger Name"
+ NAMESPACES = "Namespaces"
+ PACKAGE_BINDING = "package binding"
+ PACKAGE_LICENSE = "package license"
+ PACKAGE_NAME = "package name"
+ PACKAGE_VERSION = "package version"
+ PACKAGES = "Packages"
+ PROJECT_NAME = "project name"
+ REGISTRY = "registry"
+ REGISTRY_URL = "registry URL"
+ REPOSITORY = "repository"
+ RULES = "Rules"
+ TRIGGER_FEED = "trigger feed"
+ TRIGGERS = "Triggers"
+ WHISK_PROPS = "wskprops"
+)
+
+// i18n Identifiers
+// DO NOT TRANSLATE
const(
// Debug / trace message prefixes
ID_MSG_PREFIX_ERROR = "msg_prefix_error" // "Error"
+ ID_MSG_PREFIX_INFO = "msg_prefix_info" // "Info"
ID_MSG_PREFIX_SUCCESS = "msg_prefix_success" // "Success"
ID_MSG_PREFIX_WARNING = "msg_prefix_warning" // "Warning"
- ID_MSG_PREFIX_INFO = "msg_prefix_info" // "Info"
- // wskdeploy (as an Action) JSON messages
- ID_JSON_MISSING_KEY_CMD = "msg_json_missing_cmd_key" // "Missing 'cmd' input key"
+ // Cobra command descriptions
+ ID_CMD_DESC_LONG_PUBLISH = "msg_cmd_desc_long_publish"
+ ID_CMD_DESC_LONG_REPORT = "msg_cmd_desc_long_report"
+ ID_CMD_DESC_LONG_ROOT = "msg_cmd_desc_long_root"
+ ID_CMD_DESC_SHORT_ADD = "msg_cmd_desc_short_add"
+ ID_CMD_DESC_SHORT_ADD_X_key_X = "msg_cmd_desc_short_add_entity"
+ ID_CMD_DESC_SHORT_PUBLISH = "msg_cmd_desc_short_publish"
+ ID_CMD_DESC_SHORT_REPORT = "msg_cmd_desc_short_report"
+ ID_CMD_DESC_SHORT_ROOT = "msg_cmd_desc_short_root"
+ ID_CMD_DESC_SHORT_VERSION = "msg_cmd_desc_short_version"
- // wskdeploy Command messages
- ID_CMD_FLAG_AUTH_KEY = "msg_cmd_flag_auth_key" // "authorization `KEY`"
- ID_CMD_FLAG_NAMESPACE = "msg_cmd_flag_namespace" // "namespace"
- ID_CMD_FLAG_API_HOST = "msg_cmd_flag_api_host" // "whisk API `HOST`"
- ID_CMD_FLAG_API_VERSION = "msg_cmd_flag_api_version" // "whisk API `VERSION`"
- ID_CMD_FLAG_KEY_FILE = "msg_cmd_flag_key_file" // "path of the .key file"
- ID_CMD_FLAG_CERT_FILE = "msg_cmd_flag_cert_file" // "path of the .cert file"
+ // Cobra Flag messages
+ ID_CMD_FLAG_API_HOST = "msg_cmd_flag_api_host"
+ ID_CMD_FLAG_API_VERSION = "msg_cmd_flag_api_version"
+ ID_CMD_FLAG_AUTH_KEY = "msg_cmd_flag_auth_key"
+ ID_CMD_FLAG_CERT_FILE = "msg_cmd_flag_cert_file"
+ ID_CMD_FLAG_CONFIG = "msg_cmd_flag_config"
+ ID_CMD_FLAG_DEFAULTS = "msg_cmd_flag_allow_defaults"
+ ID_CMD_FLAG_DEPLOYMENT = "msg_cmd_flag_deployment"
+ 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_MANIFEST = "msg_cmd_flag_manifest"
+ 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_VERBOSE = "msg_cmd_flag_allow_verbose"
// Configuration messages
ID_MSG_CONFIG_MISSING_AUTHKEY = "msg_config_missing_authkey"
ID_MSG_CONFIG_MISSING_APIHOST = "msg_config_missing_apihost"
ID_MSG_CONFIG_MISSING_NAMESPACE = "msg_config_missing_namespace"
-
ID_MSG_CONFIG_INFO_APIHOST_X_host_X_source_X = "msg_config_apihost_info"
ID_MSG_CONFIG_INFO_AUTHKEY_X_source_X = "msg_config_authkey_info"
ID_MSG_CONFIG_INFO_NAMESPACE_X_namespace_X_source_X = "msg_config_namespace_info"
@@ -49,155 +101,208 @@ const(
ID_MSG_UNMARSHAL_NETWORK = "msg_unmarshall_network"
// Informational
- ID_MSG_MANIFEST_FILE_NOT_FOUND_X_path_X = "msg_manifest_not_found"
- ID_MSG_RUNTIME_MISMATCH_X_runtime_X_ext_X_action_X = "msg_runtime_mismatch"
- ID_MSG_RUNTIME_CHANGED_X_runtime_X_action_X = "msg_runtime_changed"
- ID_MSG_RUNTIME_UNSUPPORTED_X_runtime_X_action_X = "msg_runtime_unsupported"
+ ID_MSG_DEPLOYMENT_CANCELLED = "msg_deployment_cancelled"
+ ID_MSG_DEPLOYMENT_FAILED = "msg_deployment_failed"
+ ID_MSG_DEPLOYMENT_REPORT = "msg_deployment_report_status"
+ ID_MSG_DEPLOYMENT_SUCCEEDED = "msg_deployment_succeeded"
- ID_MSG_MANIFEST_DEPLOY_X_path_X = "msg_using_manifest_deploy" // "Using {{.path}} for deployment.\n"
- ID_MSG_MANIFEST_UNDEPLOY_X_path_X = "msg_using_manifest_undeploy" // "Using {{.path}} for undeployment.\n"
+ ID_MSG_UNDEPLOYMENT_CANCELLED = "msg_undeployment_cancelled"
+ ID_MSG_UNDEPLOYMENT_FAILED = "msg_undeployment_failed"
+ ID_MSG_UNDEPLOYMENT_SUCCEEDED = "msg_undeployment_succeeded"
- ID_MSG_DEPLOYMENT_SUCCEEDED = "msg_deployment_succeeded"
- ID_MSG_DEPLOYMENT_FAILED = "msg_deployment_failed"
- ID_MSG_DEPLOYMENT_CANCELLED = "msg_deployment_cancelled"
+ 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_DEPLOYING_X_key_X_name_X = "msg_entity_deploying"
- ID_MSG_ENTITY_UNDEPLOYING_X_key_X_name_X = "msg_entity_undeploying"
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"
+ ID_MSG_ENTITY_UNDEPLOYING_X_key_X_name_X = "msg_entity_undeploying"
- ID_MSG_UNDEPLOYMENT_SUCCEEDED = "msg_undeployment_succeeded"
- ID_MSG_UNDEPLOYMENT_FAILED = "msg_undeployment_failed"
- ID_MSG_UNDEPLOYMENT_CANCELLED = "msg_undeployment_cancelled"
-
- ID_MSG_DEPENDENCY_DEPLOYING_X_name_X = "msg_deploying_dependency"
- ID_MSG_DEPENDENCY_UNDEPLOYING_X_name_X = "msg_undeploying_dependency"
- ID_MSG_DEPENDENCY_DEPLOYMENT_SUCCESS_X_name_X = "msg_dependency_deployment_success"
+ ID_MSG_DEPENDENCY_DEPLOYING_X_name_X = "msg_dependency_deploying"
ID_MSG_DEPENDENCY_DEPLOYMENT_FAILURE_X_name_X = "msg_dependency_deployment_failure"
- ID_MSG_DEPENDENCY_UNDEPLOYMENT_SUCCESS_X_name_X = "msg_dependency_undeployment_success"
+ ID_MSG_DEPENDENCY_DEPLOYMENT_SUCCESS_X_name_X = "msg_dependency_deployment_success"
+ ID_MSG_DEPENDENCY_UNDEPLOYING_X_name_X = "msg_dependency_undeploying"
ID_MSG_DEPENDENCY_UNDEPLOYMENT_FAILURE_X_name_X = "msg_dependency_undeployment_failure"
+ ID_MSG_DEPENDENCY_UNDEPLOYMENT_SUCCESS_X_name_X = "msg_dependency_undeployment_success"
// Managed deployments
- ID_MSG_MANAGED_UNDEPLOYMENT_FAILED = "msg_undeployment_managed_failed"
+ ID_MSG_MANAGED_UNDEPLOYMENT_FAILED = "msg_managed_undeployment_failed"
ID_MSG_MANAGED_FOUND_DELETED_X_key_X_name_X_project_X = "msg_managed_found_deleted_entity"
// Interactive (prompts)
- ID_MSG_PROMPT_DEPLOY = "msg_prompt_deploy"
- ID_MSG_PROMPT_UNDEPLOY = "msg_prompt_undeploy"
- ID_MSG_PROMPT_AUTHKEY = "msg_prompt_authkey"
ID_MSG_PROMPT_APIHOST = "msg_prompt_apihost"
+ ID_MSG_PROMPT_AUTHKEY = "msg_prompt_authkey"
+ ID_MSG_PROMPT_DEPLOY = "msg_prompt_deploy"
ID_MSG_PROMPT_NAMESPACE = "msg_prompt_namespace"
+ ID_MSG_PROMPT_UNDEPLOY = "msg_prompt_undeploy"
- // Action Limits
- ID_MSG_ACTION_LIMIT_IGNORED_X_limit_X = "msg_action_limit_ignored" // timeout, memorySize, logSize
+ // Errors
+ ID_ERR_DEPENDENCY_UNKNOWN_TYPE = "msg_err_dependency_unknown_type"
+ ID_ERR_DEPLOYMENT_NAME_NOT_FOUND_X_key_X_name_X = "msg_err_deployment_name_not_found"
+ ID_ERR_ENTITY_CREATE_X_key_X_err_X_code_X = "msg_err_entity_create"
+ ID_ERR_ENTITY_DELETE_X_key_X_err_X_code_X = "msg_err_entity_delete"
+ ID_ERR_FEED_INVOKE_X_err_X_code_X = "msg_err_feed_invoke"
+ ID_ERR_KEY_MISSING_X_key_X = "msg_err_key_missing_mandatory"
+ ID_ERR_MANIFEST_FILE_NOT_FOUND_X_path_X = "msg_err_manifest_not_found"
+ ID_ERR_NAME_MISMATCH_X_key_X_dname_X_dpath_X_mname_X_moath_X = "msg_err_name_mismatch"
+ ID_ERR_RUNTIME_INVALID_X_runtime_X_action_X = "msg_err_runtime_invalid"
+ ID_ERR_RUNTIME_MISMATCH_X_runtime_X_ext_X_action_X = "msg_err_runtime_mismatch"
+ ID_ERR_RUNTIMES_GET_X_err_X = "msg_err_runtimes_get"
+ ID_ERR_URL_INVALID_X_urltype_X_url_X_filetype_X = "msg_err_url_invalid"
+ ID_ERR_URL_MALFORMED_X_urltype_X_url_X = "msg_err_url_malformed"
+
+ // Server-side Errors (wskdeploy as an Action)
+ ID_ERR_JSON_MISSING_KEY_CMD = "msg_err_json_missing_cmd_key"
// warnings
- ID_WARN_DEPRECATED_KEY_REPLACED_X_oldkey_X_filetype_X_newkey_X = "msg_warn_key_deprecated_replaced"
- ID_WARN_WHISK_PROPS_DEPRECATED = "msg_warn_whisk_properties"
- ID_WARN_MISSING_MANDATORY_KEY_X_key_X_value_X = "msg_warn_missing_mandatory_key"
+ ID_WARN_COMMAND_RETRY = "msg_warn_command_retry"
+ ID_WARN_CONFIG_INVALID_X_path_X = "msg_warn_config_invalid"
+ ID_WARN_KEY_DEPRECATED_X_oldkey_X_filetype_X_newkey_X = "msg_warn_key_deprecated_replaced"
+ ID_WARN_KEY_MISSING_X_key_X_value_X = "msg_warn_key_missing"
+ ID_WARN_KEYVALUE_INVALID = "msg_warn_key_value_invalid"
ID_WARN_KEYVALUE_NOT_SAVED_X_key_X = "msg_warn_key_value_not_saved"
- ID_WARN_KEYVALUE_INVALID = "msg_warn_invalid_key_value"
- ID_WARN_LIMITS_TIMEOUT = "msg_warn_limits_timeout"
- ID_WARN_LIMITS_MEMORY_SIZE = "msg_warn_limits_memory_size"
- ID_WARN_LIMITS_LOG_SIZE = "msg_warn_limits_memory_log_size"
+ ID_WARN_LIMIT_IGNORED_X_limit_X = "msg_warn_limit_ignored"
ID_WARN_LIMIT_UNCHANGEABLE_X_name_X = "msg_warn_limit_changeable"
+ ID_WARN_LIMITS_LOG_SIZE = "msg_warn_limits_log_size" // TODO() remove for value range
+ ID_WARN_LIMITS_MEMORY_SIZE = "msg_warn_limits_memory_size" // TODO() remove for value range
+ ID_WARN_LIMITS_TIMEOUT = "msg_warn_limits_timeout" // TODO() remove for value range
+ ID_WARN_RUNTIME_CHANGED_X_runtime_X_action_X = "msg_warn_runtime_changed"
+ ID_WARN_VALUE_RANGE_X_name_X_key_X_filetype_X_min_X_max_X = "msg_warn_value_range" // TODO() not used, but should be used for limit ranges
+ ID_WARN_WHISK_PROPS_DEPRECATED = "msg_warn_whisk_properties"
+ ID_WARN_ENTITY_NAME_EXISTS_X_key_X_name_X = "msg_warn_entity_name_exists"
- // Errors
- ID_ERR_GET_RUNTIMES_X_err_X = "msg_err_get_runtimes"
- ID_ERR_MISSING_MANDATORY_KEY_X_key_X = "msg_err_missing_mandatory_key"
- ID_ERR_MISMATCH_NAME_X_key_X_dname_X_dpath_X_mname_X_moath_X = "msg_err_mismatch_name_project"
- ID_ERR_CREATE_ENTITY_X_key_X_err_X_code_X = "msg_err_create_entity"
- ID_ERR_DELETE_ENTITY_X_key_X_err_X_code_X = "msg_err_delete_entity"
- ID_ERR_FEED_INVOKE_X_err_X_code_X = "msg_err_feed_invoke"
+ // Verbose (Debug/Trace) messages
+ ID_DEBUG_KEY_VERIFY_X_name_X_key_X = "msg_dbg_key_verify"
+ 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"
)
// Known keys used for text replacement in i18n translated strings
const(
- KEY_KEY = "key"
- KEY_VALUE = "value"
- KEY_NAME = "name"
- KEY_CODE = "code"
- KEY_ERR = "err"
- KEY_PROJECT = "project"
KEY_ACTION = "action"
- KEY_LIMIT = "limit"
- KEY_HOST = "host"
- KEY_SOURCE = "source"
- KEY_NAMESPACE = "namespace"
- KEY_PATH = "path"
- KEY_EXTENTION = "ext"
- KEY_RUNTIME = "runtime"
+ KEY_CMD = "cmd"
+ KEY_CODE = "code"
KEY_DEPLOYMENT_NAME = "dname"
KEY_DEPLOYMENT_PATH = "dpath"
+ KEY_ERR = "err"
+ KEY_EXTENTION = "ext"
+ KEY_FILE_TYPE = "filetype"
+ KEY_HOST = "host"
+ KEY_KEY = "key"
+ KEY_LIMIT = "limit"
KEY_MANIFEST_NAME = "mname"
KEY_MANIFEST_PATH = "mpath"
- KEY_OLD = "oldkey"
+ KEY_NAME = "name"
+ KEY_NAMESPACE = "namespace"
KEY_NEW = "newkey"
- KEY_FILE_TYPE = "filetype"
+ KEY_OLD = "oldkey"
+ KEY_PATH = "path"
+ KEY_PROJECT = "project"
+ KEY_RUNTIME = "runtime"
+ KEY_SOURCE = "source"
+ KEY_URL = "url"
+ KEY_URL_TYPE = "urltype"
+ 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
)
+// Used to unit test that translations exist with these IDs
var I18N_ID_SET = [](string){
- ID_MSG_PREFIX_ERROR,
- ID_MSG_PREFIX_SUCCESS,
- ID_MSG_PREFIX_WARNING,
- ID_MSG_PREFIX_INFO,
- ID_JSON_MISSING_KEY_CMD,
- ID_CMD_FLAG_AUTH_KEY,
- ID_CMD_FLAG_NAMESPACE,
+ ID_CMD_DESC_LONG_PUBLISH,
+ ID_CMD_DESC_LONG_REPORT,
+ ID_CMD_DESC_LONG_ROOT,
+ ID_CMD_DESC_SHORT_ADD,
+ ID_CMD_DESC_SHORT_ADD_X_key_X,
+ ID_CMD_DESC_SHORT_PUBLISH,
+ ID_CMD_DESC_SHORT_REPORT,
+ ID_CMD_DESC_SHORT_ROOT,
+ ID_CMD_DESC_SHORT_VERSION,
ID_CMD_FLAG_API_HOST,
ID_CMD_FLAG_API_VERSION,
- ID_CMD_FLAG_KEY_FILE,
+ ID_CMD_FLAG_AUTH_KEY,
ID_CMD_FLAG_CERT_FILE,
- ID_MSG_CONFIG_MISSING_AUTHKEY,
- ID_MSG_CONFIG_MISSING_APIHOST,
- ID_MSG_CONFIG_MISSING_NAMESPACE,
+ ID_CMD_FLAG_CONFIG,
+ ID_CMD_FLAG_DEFAULTS,
+ ID_CMD_FLAG_DEPLOYMENT,
+ ID_CMD_FLAG_INTERACTIVE,
+ ID_CMD_FLAG_KEY_FILE,
+ ID_CMD_FLAG_MANAGED,
+ ID_CMD_FLAG_MANIFEST,
+ ID_CMD_FLAG_NAMESPACE,
+ ID_CMD_FLAG_PROJECT,
+ ID_CMD_FLAG_STRICT,
+ ID_CMD_FLAG_TOGGLE_HELP,
+ ID_CMD_FLAG_VERBOSE,
+ ID_DEBUG_DEPLOYING_USING,
+ ID_DEBUG_KEY_VERIFY_X_name_X_key_X,
+ ID_DEBUG_PROJECT_SEARCH_X_path_X_key_X,
+ ID_DEBUG_UNDEPLOYING_USING,
+ ID_ERR_DEPENDENCY_UNKNOWN_TYPE,
+ ID_ERR_DEPLOYMENT_NAME_NOT_FOUND_X_key_X_name_X,
+ ID_ERR_ENTITY_CREATE_X_key_X_err_X_code_X,
+ ID_ERR_ENTITY_DELETE_X_key_X_err_X_code_X,
+ ID_ERR_JSON_MISSING_KEY_CMD,
+ ID_ERR_JSON_MISSING_KEY_CMD,
+ ID_ERR_KEY_MISSING_X_key_X,
+ ID_ERR_MANIFEST_FILE_NOT_FOUND_X_path_X,
+ ID_ERR_NAME_MISMATCH_X_key_X_dname_X_dpath_X_mname_X_moath_X,
+ ID_ERR_RUNTIME_INVALID_X_runtime_X_action_X,
+ ID_ERR_RUNTIME_MISMATCH_X_runtime_X_ext_X_action_X,
+ 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_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,
- ID_MSG_UNMARSHAL_LOCAL,
- ID_MSG_UNMARSHAL_NETWORK,
- ID_MSG_MANIFEST_FILE_NOT_FOUND_X_path_X,
- ID_MSG_RUNTIME_MISMATCH_X_runtime_X_ext_X_action_X,
- ID_MSG_RUNTIME_CHANGED_X_runtime_X_action_X,
- ID_MSG_RUNTIME_UNSUPPORTED_X_runtime_X_action_X,
- ID_MSG_MANIFEST_DEPLOY_X_path_X,
- ID_MSG_MANIFEST_UNDEPLOY_X_path_X,
- ID_MSG_DEPLOYMENT_SUCCEEDED,
- ID_MSG_DEPLOYMENT_FAILED,
- ID_MSG_DEPLOYMENT_CANCELLED,
- ID_MSG_ENTITY_DEPLOYING_X_key_X_name_X,
- ID_MSG_ENTITY_UNDEPLOYING_X_key_X_name_X,
- ID_MSG_ENTITY_DEPLOYED_SUCCESS_X_key_X_name_X,
- ID_MSG_ENTITY_UNDEPLOYED_SUCCESS_X_key_X_name_X,
- ID_MSG_UNDEPLOYMENT_SUCCEEDED,
- ID_MSG_UNDEPLOYMENT_FAILED,
- ID_MSG_UNDEPLOYMENT_CANCELLED,
+ ID_MSG_CONFIG_MISSING_APIHOST,
+ ID_MSG_CONFIG_MISSING_AUTHKEY,
+ ID_MSG_CONFIG_MISSING_NAMESPACE,
ID_MSG_DEPENDENCY_DEPLOYING_X_name_X,
- ID_MSG_DEPENDENCY_UNDEPLOYING_X_name_X,
- ID_MSG_DEPENDENCY_DEPLOYMENT_SUCCESS_X_name_X,
ID_MSG_DEPENDENCY_DEPLOYMENT_FAILURE_X_name_X,
- ID_MSG_DEPENDENCY_UNDEPLOYMENT_SUCCESS_X_name_X,
+ ID_MSG_DEPENDENCY_DEPLOYMENT_SUCCESS_X_name_X,
+ ID_MSG_DEPENDENCY_UNDEPLOYING_X_name_X,
ID_MSG_DEPENDENCY_UNDEPLOYMENT_FAILURE_X_name_X,
- ID_MSG_MANAGED_UNDEPLOYMENT_FAILED,
+ ID_MSG_DEPENDENCY_UNDEPLOYMENT_SUCCESS_X_name_X,
+ ID_MSG_DEPLOYMENT_CANCELLED,
+ ID_MSG_DEPLOYMENT_FAILED,
+ ID_MSG_DEPLOYMENT_REPORT,
+ ID_MSG_DEPLOYMENT_SUCCEEDED,
+ ID_MSG_ENTITY_DEPLOYED_SUCCESS_X_key_X_name_X,
+ ID_MSG_ENTITY_DEPLOYING_X_key_X_name_X,
+ ID_MSG_ENTITY_UNDEPLOYED_SUCCESS_X_key_X_name_X,
+ ID_MSG_ENTITY_UNDEPLOYING_X_key_X_name_X,
ID_MSG_MANAGED_FOUND_DELETED_X_key_X_name_X_project_X,
- ID_MSG_PROMPT_DEPLOY,
- ID_MSG_PROMPT_UNDEPLOY,
- ID_MSG_PROMPT_AUTHKEY,
+ 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,
+ ID_MSG_PREFIX_WARNING,
ID_MSG_PROMPT_APIHOST,
+ ID_MSG_PROMPT_AUTHKEY,
+ ID_MSG_PROMPT_DEPLOY,
ID_MSG_PROMPT_NAMESPACE,
- ID_MSG_ACTION_LIMIT_IGNORED_X_limit_X,
- ID_WARN_DEPRECATED_KEY_REPLACED_X_oldkey_X_filetype_X_newkey_X,
- ID_WARN_WHISK_PROPS_DEPRECATED,
- ID_WARN_MISSING_MANDATORY_KEY_X_key_X_value_X,
- ID_WARN_KEYVALUE_NOT_SAVED_X_key_X,
+ ID_MSG_PROMPT_UNDEPLOY,
+ ID_MSG_UNDEPLOYMENT_CANCELLED,
+ ID_MSG_UNDEPLOYMENT_FAILED,
+ ID_MSG_UNDEPLOYMENT_SUCCEEDED,
+ ID_MSG_UNMARSHAL_LOCAL,
+ ID_MSG_UNMARSHAL_NETWORK,
+ ID_WARN_COMMAND_RETRY,
+ ID_WARN_CONFIG_INVALID_X_path_X,
+ ID_WARN_ENTITY_NAME_EXISTS_X_key_X_name_X,
+ ID_WARN_KEY_DEPRECATED_X_oldkey_X_filetype_X_newkey_X,
+ ID_WARN_KEY_MISSING_X_key_X_value_X,
ID_WARN_KEYVALUE_INVALID,
- ID_WARN_LIMITS_TIMEOUT,
- ID_WARN_LIMITS_MEMORY_SIZE,
- ID_WARN_LIMITS_LOG_SIZE,
+ ID_WARN_KEYVALUE_NOT_SAVED_X_key_X,
+ ID_WARN_LIMIT_IGNORED_X_limit_X,
ID_WARN_LIMIT_UNCHANGEABLE_X_name_X,
- ID_ERR_GET_RUNTIMES_X_err_X,
- ID_ERR_MISSING_MANDATORY_KEY_X_key_X,
- ID_ERR_MISMATCH_NAME_X_key_X_dname_X_dpath_X_mname_X_moath_X,
- ID_ERR_CREATE_ENTITY_X_key_X_err_X_code_X,
- ID_ERR_DELETE_ENTITY_X_key_X_err_X_code_X,
+ ID_WARN_LIMITS_LOG_SIZE,
+ ID_WARN_LIMITS_MEMORY_SIZE,
+ ID_WARN_LIMITS_TIMEOUT,
+ ID_WARN_RUNTIME_CHANGED_X_runtime_X_action_X,
+ ID_WARN_WHISK_PROPS_DEPRECATED,
}
diff --git a/wski18n/i18n_resources.go b/wski18n/i18n_resources.go
index 1a04185..29d8528 100644
--- a/wski18n/i18n_resources.go
+++ b/wski18n/i18n_resources.go
@@ -97,7 +97,7 @@ func wski18nResourcesDe_deAllJson() (*asset, error) {
return a, nil
}
-var _wski18nResourcesEn_usAllJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xc4\x59\x51\x6f\xdb\x38\x12\x7e\xcf\xaf\x18\xe4\xa5\x77\x40\xe0\x6b\x7b\x38\xe0\xd0\x97\xc5\x62\xd3\xc5\x66\xbb\x6d\x8a\xa6\xdd\x62\xd1\x16\x0a\x23\x8e\x64\xd6\x14\x29\x90\x94\x5d\xd7\xf0\x7f\x5f\x0c\x29\x4a\x76\x12\x4a\xb2\x93\x62\xf3\xc4\x98\xc3\xf9\x66\x86\xc3\x99\x8f\xd4\xa7\x13\x80\xcd\x09\x00\xc0\xa9\xe0\xa7\x2f\xe0\xb4\xb2\x65\x56\x1b\x2c\xc4\xb7\x0c\x8d\xd1\xe6\xf4\x2c\xcc\x3a\xc3\x94\x95\xcc\x09 [...]
+var _wski18nResourcesEn_usAllJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xc4\x5a\x7b\x8f\x1b\xb7\x11\xff\xdf\x9f\x62\x60\x14\x70\x02\x9c\xd7\x4e\x8a\x02\x85\x81\x43\xe1\xd6\xd7\xe4\x9a\xd8\x67\xdc\x23\x41\xe0\x1c\xd6\xd4\x72\x24\x31\xe2\x92\x0b\x92\x2b\x59\x3e\xa8\x9f\xbd\x18\x72\x5f\xba\x3b\xee\x52\x72\x8c\xe6\x9f\xac\x8f\xc3\xf9\xcd\x83\x9c\x17\xf5\xe1\x09\xc0\xdd\x13\x00\x80\xa7\x82\x3f\x7d\x05\x4f\x4b\xbb\xc8\x2b\x83\x73\xf1\x29\x47\x63\xb4\x79\x7a\x12\x56\x9d\x61\xca\x4a [...]
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: 8030, mode: os.FileMode(420), modTime: time.Unix(1515789236, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/en_US.all.json", size: 12172, mode: os.FileMode(420), modTime: time.Unix(1516809631, 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 46e9f6a..99aede8 100644
--- a/wski18n/resources/en_US.all.json
+++ b/wski18n/resources/en_US.all.json
@@ -4,28 +4,52 @@
"translation": "Error"
},
{
- "id": "msg_prefix_warning",
- "translation": "Warning"
+ "id": "msg_prefix_info",
+ "translation": "Info"
},
{
"id": "msg_prefix_success",
"translation": "Success"
},
{
- "id": "msg_prefix_info",
- "translation": "Info"
+ "id": "msg_prefix_warning",
+ "translation": "Warning"
},
{
- "id": "msg_json_missing_cmd_key",
- "translation": "JSON input data Missing 'cmd' key"
+ "id": "msg_cmd_desc_long_publish",
+ "translation": "Publish a package to the registry set in ~/.wskprops."
},
{
- "id": "msg_cmd_flag_namespace",
- "translation": "namespace"
+ "id": "msg_cmd_desc_long_report",
+ "translation": "Reports on deployed entities (i.e., Packages, Actions, Triggers, Rules, etc.) as well as recent Activations in the specified namespace."
},
{
- "id": "msg_cmd_flag_auth_key",
- "translation": "authorization `KEY`"
+ "id": "msg_cmd_desc_long_root",
+ "translation": "A tool to deploy, undeploy and sync openwhisk packages using a manifest and optional deployment files using YAML."
+ },
+ {
+ "id": "msg_cmd_desc_short_publish",
+ "translation": "Publish a package to a registry."
+ },
+ {
+ "id": "msg_cmd_desc_short_report",
+ "translation": "Provides a summary report of what's been deployed in the specified namespace."
+ },
+ {
+ "id": "msg_cmd_desc_short_root",
+ "translation": "A tool set to help deploy your openwhisk packages using a manifest file."
+ },
+ {
+ "id": "msg_cmd_desc_short_add",
+ "translation": "Add an action, feed, trigger or rule to the manifest"
+ },
+ {
+ "id": "msg_cmd_desc_short_add_entity",
+ "translation": "Add a/an {{.key}} to the manifest file"
+ },
+ {
+ "id": "msg_cmd_desc_short_version",
+ "translation": "Print the version number of wskdeploy"
},
{
"id": "msg_cmd_flag_api_host",
@@ -36,60 +60,60 @@
"translation": "whisk API `VERSION`"
},
{
- "id": "msg_cmd_flag_key_file",
- "translation": "path of the .key file"
+ "id": "msg_cmd_flag_auth_key",
+ "translation": "authorization `KEY`"
},
{
"id": "msg_cmd_flag_cert_file",
"translation": "path of the .cert file"
},
{
- "id": "msg_prompt_deploy",
- "translation": "Do you really want to deploy this? (y/N): "
+ "id": "msg_cmd_flag_config",
+ "translation": "config file (default is $HOME/.wskprops)"
},
{
- "id": "msg_prompt_undeploy",
- "translation": "Do you really want to undeploy this? (y/N): "
+ "id": "msg_cmd_flag_allow_defaults",
+ "translation": "allow defaults"
},
{
- "id": "msg_prompt_authkey",
- "translation": "\nPlease provide an authentication token: "
+ "id": "msg_cmd_flag_deployment",
+ "translation": "path to deployment file"
},
{
- "id": "msg_prompt_apihost",
- "translation": "\nPlease provide the hostname for OpenWhisk: "
+ "id": "msg_cmd_flag_interactive",
+ "translation": "allow interactive prompts"
},
{
- "id": "msg_prompt_namespace",
- "translation": "\nPlease provide a namespace [default value is guest]: "
+ "id": "msg_cmd_flag_key_file",
+ "translation": "path of the .key file"
},
{
- "id": "msg_manifest_not_found",
- "translation": "Manifest file not found at path [{{.path}}].\n"
+ "id": "msg_cmd_flag_allow_managed",
+ "translation": "allow project entities to be marked managed"
},
{
- "id": "msg_using_manifest_deploy",
- "translation": "Using [{{.path}}] for deployment.\n"
+ "id": "msg_cmd_flag_manifest",
+ "translation": "path to manifest file"
},
{
- "id": "msg_using_manifest_undeploy",
- "translation": "Using [{{.path}}] for undeployment.\n"
+ "id": "msg_cmd_flag_namespace",
+ "translation": "namespace"
},
{
- "id": "msg_runtime_mismatch",
- "translation": "Runtime [{{.runtime}}] specified in manifest does not match with action source file extension [{{.ext}}] for action [{{.action}}].\n"
+ "id": "msg_cmd_flag_project",
+ "translation": "path to serverless project"
},
{
- "id": "msg_runtime_changed",
- "translation": "Runtime changed to [{{.runtime}}] based on the action source file extension for action [{{.action}}].\n"
+ "id": "msg_cmd_flag_strict",
+ "translation": "allow user defined runtime version"
},
{
- "id": "msg_runtime_unsupported",
- "translation": "Runtime [{{.runtime}}] specified in manifest is not supported for the action [{{.action}}].\n"
+ "id": "msg_cmd_flag_toggle_help",
+ "translation": "Toggle Help message"
},
{
- "id": "msg_action_limit_ignored",
- "translation": "Invalid action limit [{{.limit}}] in manifest is ignored.\n"
+ "id": "msg_cmd_flag_allow_verbose",
+ "translation": "verbose output"
},
{
"id": "msg_config_missing_authkey",
@@ -105,7 +129,7 @@
},
{
"id": "msg_config_apihost_info",
- "translation": "The API host is {{.host}}, from {{.source}}.\n"
+ "translation": "The API host is [{{.host}}], from {{.source}}.\n"
},
{
"id": "msg_config_authkey_info",
@@ -113,11 +137,7 @@
},
{
"id": "msg_config_namespace_info",
- "translation": "The namespace is {{.namespace}}, from {{.source}}.\n"
- },
- {
- "id": "msg_err_get_runtimes",
- "translation": "Failed to get the supported runtimes from OpenWhisk service: {{.err}}.\n"
+ "translation": "The namespace is [{{.namespace}}], from {{.source}}.\n"
},
{
"id": "msg_unmarshall_local",
@@ -128,58 +148,60 @@
"translation": "Unmarshal OpenWhisk info from internet.\n"
},
{
- "id": "msg_deployment_succeeded",
- "translation": "Deployment completed successfully.\n"
+ "id": "msg_deployment_cancelled",
+ "translation": "OK. Cancelling deployment.\n"
},
{
"id": "msg_deployment_failed",
"translation": "Deployment did not complete sucessfully. Run `wskdeploy undeploy` to remove partially deployed assets.\n"
},
{
- "id": "msg_deployment_cancelled",
- "translation": "OK. Cancelling deployment.\n"
+ "id": "msg_deployment_report_status",
+ "translation": "----==== OpenWhisk Deployment Status ====----"
},
{
- "id": "msg_undeployment_succeeded",
- "translation": "Undeployment completed successfully.\n"
+ "id": "msg_deployment_succeeded",
+ "translation": "Deployment completed successfully.\n"
+ },
+ {
+ "id": "msg_undeployment_cancelled",
+ "translation": "OK. Cancelling undeployment.\n"
},
{
"id": "msg_undeployment_failed",
"translation": "Undeployment did not complete sucessfully.\n"
},
{
- "id": "msg_undeployment_cancelled",
- "translation": "OK. Cancelling undeployment.\n"
+ "id": "msg_undeployment_succeeded",
+ "translation": "Undeployment completed successfully.\n"
},
{
- "id": "msg_undeployment_managed_failed",
- "translation": "Undeployment of deleted entities did not complete sucessfully during managed deployment. Run `wskdeploy undeploy` to remove partially deployed assets.\n"
+ "id": "msg_manifest_using_deployment",
+ "translation": "Using [{{.path}}] for deployment.\n"
},
{
- "id": "msg_warn_whisk_properties",
- "translation": "The [{{.key}}] key was retrieved from whisk.properties which will soon be deprecated please do not use it outside of Travis builds.\n"
+ "id": "msg_manifest_using_undeployment",
+ "translation": "Using [{{.path}}] for undeployment.\n"
},
{
- "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"
- },
- { "id": "msg_err_missing_mandatory_key",
- "translation": "The mandatory key [{{.key}}] is missing.\n"
+ "id": "msg_entity_deployed_success",
+ "translation": "{{.key}} [{{.name}}] has been successfully deployed.\n"
},
- { "id": "msg_warn_missing_mandatory_key",
- "translation": "The mandatory key [{{.key}}] should be set. Using default value [{{.value}}]...\n"
+ {
+ "id": "msg_entity_deploying",
+ "translation": "Deploying {{.key}} [{{.name}}] ..."
},
{
- "id": "msg_err_mismatch_name_project",
- "translation": "The {{.key}} named [{{.dname}}] in deployment file [{{.dpath}}] does not match the name [{{.mname}}] in manifest file [{{.mpath}}]."
+ "id": "msg_entity_undeployed_success",
+ "translation": "{{.key}} [{{.name}}] has been successfully undeployed.\n"
},
{
- "id": "msg_deploying_dependency",
- "translation": "Deploying dependency [{{.name}}]..."
+ "id": "msg_entity_undeploying",
+ "translation": "Undeploying {{.key}} [{{.name}}] ..."
},
{
- "id": "msg_undeploying_dependency",
- "translation": "Undeploying dependency [{{.name}}]..."
+ "id": "msg_dependency_deploying",
+ "translation": "Deploying dependency [{{.name}}]..."
},
{
"id": "msg_dependency_deployment_success",
@@ -190,6 +212,10 @@
"translation": "Deployment of dependency [{{.name}}] did not complete sucessfully. Run `wskdeploy undeploy` to remove partially deployed assets.\n"
},
{
+ "id": "msg_dependency_undeploying",
+ "translation": "Undeploying dependency [{{.name}}]..."
+ },
+ {
"id": "msg_dependency_undeployment_success",
"translation": "Dependency [{{.name}}] has been successfully undeployed.\n"
},
@@ -198,44 +224,132 @@
"translation": "Undeployment of dependency [{{.name}}] did not complete sucessfully.\n"
},
{
+ "id": "msg_managed_undeployment_failed",
+ "translation": "Undeployment of deleted entities did not complete sucessfully during managed deployment. Run `wskdeploy undeploy` to remove partially deployed assets.\n"
+ },
+ {
"id": "msg_managed_found_deleted_entity",
"translation": "Deleting {{.key}} [{{.name}}] which was removed from the current managed project [{{.project}}] as part of undeployment.\n"
},
{
- "id": "msg_err_create_entity",
- "translation": "Error creating {{.key}} with error message: {{.err}} and error code: {{.code}}.\n"
+ "id": "msg_prompt_apihost",
+ "translation": "\nPlease provide the hostname for OpenWhisk: "
},
{
- "id": "msg_err_delete_entity",
- "translation": "Error deleting {{.key}} with error message: {{.err}} and error code: {{.code}}.\n"
+ "id": "msg_prompt_authkey",
+ "translation": "\nPlease provide an authentication token: "
},
{
- "id": "msg_entity_deploying",
- "translation": "Deploying {{.key}} [{{.name}}] ..."
+ "id": "msg_prompt_deploy",
+ "translation": "Do you really want to deploy this? (y/N): "
},
{
- "id": "msg_entity_undeploying",
- "translation": "Undeploying {{.key}} [{{.name}}] ..."
+ "id": "msg_prompt_namespace",
+ "translation": "\nPlease provide a namespace [default value is guest]: "
},
{
- "id": "msg_entity_deployed_success",
- "translation": "{{.key}} [{{.name}}] has been successfully deployed.\n"
+ "id": "msg_prompt_undeploy",
+ "translation": "Do you really want to undeploy this? (y/N): "
},
{
- "id": "msg_entity_undeployed_success",
- "translation": "{{.key}} [{{.name}}] has been successfully undeployed.\n"
+ "id": "ERRORS",
+ "translation": "================= ERRORS ==================="
+ },
+ {
+ "id": "msg_err_dependency_unknown_type",
+ "translation": "Dependency type is unknown. wskdeploy only supports /whisk.system bindings or github.com packages.\n"
+ },
+ {
+ "id": "msg_err_deployment_name_not_found",
+ "translation": "The {{.key}} [{{.name}}] in deployment file not found in manifest file.\n"
+ },
+ {
+ "id": "msg_err_entity_create",
+ "translation": "Error creating {{.key}} with error message: {{.err}} and error code: {{.code}}.\n"
+ },
+ {
+ "id": "msg_err_entity_delete",
+ "translation": "Error deleting {{.key}} with error message: {{.err}} and error code: {{.code}}.\n"
},
{
"id": "msg_err_feed_invoke",
"translation": "Failed to invoke the feed when deleting trigger feed with error message: {{.err}} and error code: {{.code}}.\n"
},
{
+ "id": "msg_err_key_missing_mandatory",
+ "translation": "The mandatory key [{{.key}}] is missing.\n"
+ },
+ {
+ "id": "msg_err_manifest_not_found",
+ "translation": "Manifest file not found at path [{{.path}}].\n"
+ },
+ {
+ "id": "msg_err_name_mismatch",
+ "translation": "The {{.key}} named [{{.dname}}] in deployment file [{{.dpath}}] does not match the name [{{.mname}}] in manifest file [{{.mpath}}]."
+ },
+ {
+ "id": "msg_err_runtime_invalid",
+ "translation": "Invalid or missing runtime [{{.runtime}}] specified in manifest for the action [{{.action}}].\n"
+ },
+ {
+ "id": "msg_err_runtime_mismatch",
+ "translation": "Runtime [{{.runtime}}] specified in manifest does not match with action's source file extension [{{.ext}}] for action [{{.action}}].\n"
+ },
+ {
+ "id": "msg_err_runtimes_get",
+ "translation": "Failed to get the supported runtimes from OpenWhisk service: {{.err}}.\n"
+ },
+ {
+ "id": "msg_err_url_invalid",
+ "translation": "Invalid or missing {{.urltype}} URL [{{.url}}] in [{{.filetype}}] file.\n"
+ },
+ {
+ "id": "msg_err_url_malformed",
+ "translation": "Malformed {{.urltype}} URL [{{.url}}]. Try again...\n"
+ },
+ {
+ "id": "msg_err_json_missing_cmd_key",
+ "translation": "JSON input data Missing 'cmd' key"
+ },
+ {
+ "id": "WARNINGS",
+ "translation": "================= WARNINGS ==================="
+ },
+ {
+ "id": "msg_warn_command_retry",
+ "translation": "Retrying [{{.cmd}}] after error: [{{.err}}]\n"
+ },
+ {
+ "id": "msg_warn_config_invalid",
+ "translation": "Invalid or missing config file [{{.path}}] detected.\n"
+ },
+ {
+ "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"
+ },
+ {
+ "id": "msg_warn_key_missing",
+ "translation": "The mandatory key [{{.key}}] should be set. Using default value [{{.value}}]...\n"
+ },
+ {
+ "id": "msg_warn_key_value_invalid",
+ "translation": "The value for key [{{.key}}] is not valid.\n"
+ },
+ {
"id": "msg_warn_key_value_not_saved",
"translation": "The value for key [{{.key}}] is not saved in the current version of wskdeploy.\n"
},
{
- "id": "msg_warn_invalid_key_value",
- "translation": "The value for key [{{.key}}] is not valid.\n"
+ "id": "msg_warn_limit_ignored",
+ "translation": "Invalid action limit [{{.limit}}] in manifest is ignored.\n"
+ },
+ {
+ "id": "msg_warn_limit_changeable",
+ "translation": "Limit [{{.name}}] is currently not changeable. Ignoring...\n"
+ },
+ {
+ "id": "msg_warn_limits_log_size",
+ "translation": "logSize of limits in manifest should be an integer between 0 and 10.\n"
},
{
"id": "msg_warn_limits_memory_size",
@@ -246,11 +360,39 @@
"translation": "timeout of limits in manifest should be an integer between 100 and 300000.\n"
},
{
- "id": "msg_warn_limits_memory_log_size",
- "translation": "logSize of limits in manifest should be an integer between 0 and 10.\n"
+ "id": "msg_warn_whisk_properties",
+ "translation": "The [{{.key}}] key was retrieved from whisk.properties which will soon be deprecated please do not use it outside of Travis builds.\n"
},
{
- "id": "msg_warn_limit_changeable",
- "translation": "Limit [{{.name}}] is currently not changeable. Ignoring for now....\n"
+ "id": "msg_warn_value_range",
+ "translation": "The value for {{.name}} [{{.key}}] in {{.filetype}} should type {{.type}} between {{.min}} and {{.mac}}.\n"
+ },
+ {
+ "id": "msg_warn_runtime_changed",
+ "translation": "Runtime changed to [{{.runtime}}] based on the action's source file extension for action [{{.action}}].\n"
+ },
+ {
+ "id": "msg_warn_entity_name_exists",
+ "translation": "The {{.key}} name [{{.name}}] already exists. Please select another name.\n"
+ },
+ {
+ "id": "DEBUG",
+ "translation": "================= DEBUG ==================="
+ },
+ {
+ "id": "msg_dbg_key_verify",
+ "translation": "Verifying {{.name}} [{{.key}}] exists...\n"
+ },
+ {
+ "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 ccf6653..122eed7 100644
--- a/wskprint/console.go
+++ b/wskprint/console.go
@@ -19,7 +19,6 @@ package wskprint
import (
"fmt"
- "github.com/apache/incubator-openwhisk-client-go/whisk"
"github.com/apache/incubator-openwhisk-wskdeploy/wski18n"
"github.com/fatih/color"
"github.com/mattn/go-colorable"
@@ -29,14 +28,18 @@ const(
STR_PREFIXED_MESSAGE = "%s: %s"
)
+var(
+ clrInfo = color.New(color.FgCyan)
+ clrWarning = color.New(color.FgYellow)
+ clrError = color.New(color.FgRed)
+ clrSuccess = color.New(color.FgGreen)
+ clrTitleInfo = color.New(color.FgCyan).Add(color.Underline)
+)
+
func PrintOpenWhiskError(message string) {
outputStream := colorable.NewColorableStderr()
- fmsg := fmt.Sprintf( STR_PREFIXED_MESSAGE, wski18n.T(wski18n.ID_MSG_PREFIX_ERROR), message)
- fmt.Fprintf(outputStream, color.RedString(fmsg))
-}
-
-func PrintlnOpenWhiskError(message string) {
- PrintOpenWhiskError(message + "\n")
+ fmt.Fprintf(outputStream, clrError.Sprintf( STR_PREFIXED_MESSAGE,
+ wski18n.T(wski18n.ID_MSG_PREFIX_ERROR), message))
}
func PrintOpenWhiskFromError(err error) {
@@ -45,8 +48,8 @@ func PrintOpenWhiskFromError(err error) {
func PrintOpenWhiskWarning(message string) {
outputStream := colorable.NewColorableStdout()
- fmsg := fmt.Sprintf( STR_PREFIXED_MESSAGE, wski18n.T(wski18n.ID_MSG_PREFIX_WARNING), message)
- fmt.Fprintf(outputStream, color.YellowString(fmsg))
+ fmt.Fprintf(outputStream, clrWarning.Sprintf( STR_PREFIXED_MESSAGE,
+ wski18n.T(wski18n.ID_MSG_PREFIX_WARNING), message))
}
func PrintlnOpenWhiskWarning(message string) {
@@ -55,28 +58,47 @@ func PrintlnOpenWhiskWarning(message string) {
func PrintOpenWhiskSuccess(message string) {
outputStream := colorable.NewColorableStdout()
- fmsg := fmt.Sprintf( STR_PREFIXED_MESSAGE, wski18n.T(wski18n.ID_MSG_PREFIX_SUCCESS), message)
- fmt.Fprintf(outputStream, color.GreenString(fmsg))
+ fmt.Fprintf(outputStream, clrSuccess.Sprintf( STR_PREFIXED_MESSAGE,
+ wski18n.T(wski18n.ID_MSG_PREFIX_SUCCESS), message))
}
func PrintlnOpenWhiskSuccess(message string) {
PrintOpenWhiskSuccess(message + "\n")
}
-func PrintOpenWhiskStatus(message string) {
+func PrintOpenWhiskInfo(message string) {
outputStream := colorable.NewColorableStdout()
- fmsg := fmt.Sprintf( STR_PREFIXED_MESSAGE, wski18n.T(wski18n.ID_MSG_PREFIX_INFO), message)
- fmt.Fprintf(outputStream, color.CyanString(fmsg))
+ fmt.Fprintf(outputStream, clrInfo.Sprintf( STR_PREFIXED_MESSAGE,
+ wski18n.T(wski18n.ID_MSG_PREFIX_INFO), message))
+}
+
+
+func PrintlnOpenWhiskInfo(message string) {
+ PrintOpenWhiskInfo(message + "\n")
}
-func PrintlnOpenWhiskStatus(message string) {
- PrintOpenWhiskStatus(message + "\n")
+func PrintlnOpenWhiskInfoTitle(message string) {
+ outputStream := colorable.NewColorableStdout()
+ fmt.Fprintf(outputStream, clrTitleInfo.Sprintf( STR_PREFIXED_MESSAGE,
+ wski18n.T(wski18n.ID_MSG_PREFIX_INFO), message))
}
func PrintlnOpenWhiskOutput(message string) {
fmt.Println(message)
}
-func PrintOpenWhiskDebugInfo(message string) {
- whisk.Debug(whisk.DbgInfo, message)
+func PrintOpenWhiskVerboseTitle(verbose bool, message string) {
+ if verbose{
+ PrintlnOpenWhiskInfoTitle(message)
+ }
+}
+
+func PrintOpenWhiskVerbose(verbose bool, message string) {
+ if verbose{
+ PrintOpenWhiskInfo(message)
+ }
+}
+
+func PrintlnOpenWhiskVerbose(verbose bool, message string) {
+ PrintOpenWhiskVerbose(verbose, message + "\n")
}
--
To stop receiving notification emails like this one, please contact
houshengbo@apache.org.