You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by cs...@apache.org on 2017/08/09 20:27:44 UTC

[incubator-openwhisk-client-go] branch master updated (b3d194d -> b5eb418)

This is an automated email from the ASF dual-hosted git repository.

csantanapr pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-client-go.git.


    from b3d194d  Support client certificate on cli and nginx (#2427)
     new fdbb033  Limit length of HTTP body displayed when debugging. (#2491)
     new 0358422  Remove "experimental" gateway api (#2547)
     new b5eb418  Ensure Action Update Creates a Web Action (#2435)

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 whisk/action.go           |  12 +--
 whisk/activation.go       |  10 +-
 whisk/api.go              | 248 ++++++----------------------------------------
 whisk/client.go           |  88 ++++++++++++----
 whisk/info.go             |   4 +-
 whisk/namespace.go        |   4 +-
 whisk/package.go          |  12 +--
 whisk/rule.go             |  14 +--
 whisk/sdk.go              |   2 +-
 whisk/shared.go           |  28 +++++-
 whisk/trace.go            |   5 +-
 whisk/trigger.go          |  14 +--
 whisk/util.go             |   4 +-
 whisk/wskerror.go         |  11 +-
 wski18n/i18n_resources.go |  20 ++--
 15 files changed, 182 insertions(+), 294 deletions(-)

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

[incubator-openwhisk-client-go] 03/03: Ensure Action Update Creates a Web Action (#2435)

Posted by cs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-client-go.git

commit b5eb4181f14d888a812fdf604d86092c6ceb10eb
Author: James Dubee <jw...@us.ibm.com>
AuthorDate: Wed Aug 9 13:18:50 2017 -0400

    Ensure Action Update Creates a Web Action (#2435)
    
    * Ensure Action Update Creates a Web ActionEnsure Action Update Creates a Web ActionEnsure Action Update Creates a Web ActionEnsure Action Update Creates a Web ActionEnsure Action Update Creates a Web ActionEnsure Action Update Creates a Web ActionEnsure Action Update Creates a Web ActionEnsure Action Update Creates a Web ActionEnsure Action Update Creates a Web Action
    
    * Ensure Existing Annotations are Overwritten
    - Overwrite annotations that have matching keys with most recent values
---
 whisk/action.go           | 12 ++++++------
 whisk/activation.go       | 10 +++++-----
 whisk/api.go              | 28 ++++++++++++++--------------
 whisk/client.go           | 38 +++++++++++++++++++-------------------
 whisk/info.go             |  4 ++--
 whisk/namespace.go        |  4 ++--
 whisk/package.go          | 12 ++++++------
 whisk/rule.go             | 14 +++++++-------
 whisk/sdk.go              |  2 +-
 whisk/shared.go           | 28 +++++++++++++++++++++++++++-
 whisk/trigger.go          | 14 +++++++-------
 whisk/util.go             |  4 ++--
 whisk/wskerror.go         | 11 ++++++-----
 wski18n/i18n_resources.go | 20 ++++++++++----------
 14 files changed, 114 insertions(+), 87 deletions(-)

diff --git a/whisk/action.go b/whisk/action.go
index 394e59b..d5cd43f 100644
--- a/whisk/action.go
+++ b/whisk/action.go
@@ -127,7 +127,7 @@ func (s *ActionService) List(packageName string, options *ActionListOptions) ([]
         Debug(DbgError, "addRouteOptions(%s, %#v) error: '%s'\n", route, options, err)
         errMsg := wski18n.T("Unable to add route options '{{.options}}'",
             map[string]interface{}{"options": options})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG,
+        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG,
             NO_DISPLAY_USAGE)
         return nil, nil, whiskErr
     }
@@ -138,7 +138,7 @@ func (s *ActionService) List(packageName string, options *ActionListOptions) ([]
         Debug(DbgError, "http.NewRequestUrl(GET, %s, nil, IncludeNamespaceInUrl, AppendOpenWhiskPathPrefix, EncodeBodyAsJson, AuthRequired) error: '%s'\n", routeUrl, err)
         errMsg := wski18n.T("Unable to create HTTP request for GET '{{.route}}': {{.err}}",
             map[string]interface{}{"route": routeUrl, "err": err})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_NETWORK, DISPLAY_MSG,
+        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXIT_CODE_ERR_NETWORK, DISPLAY_MSG,
             NO_DISPLAY_USAGE)
         return nil, nil, whiskErr
     }
@@ -164,7 +164,7 @@ func (s *ActionService) Insert(action *Action, overwrite bool) (*Action, *http.R
         Debug(DbgError, "http.NewRequest(PUT, %s, %#v) error: '%s'\n", route, err, action)
         errMsg := wski18n.T("Unable to create HTTP request for PUT '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_NETWORK, DISPLAY_MSG,
+        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXIT_CODE_ERR_NETWORK, DISPLAY_MSG,
             NO_DISPLAY_USAGE)
         return nil, nil, whiskErr
     }
@@ -190,7 +190,7 @@ func (s *ActionService) Get(actionName string) (*Action, *http.Response, error)
         Debug(DbgError, "http.NewRequest(GET, %s, nil) error: '%s'\n", route, err)
         errMsg := wski18n.T("Unable to create HTTP request for GET '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_NETWORK, DISPLAY_MSG,
+        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXIT_CODE_ERR_NETWORK, DISPLAY_MSG,
             NO_DISPLAY_USAGE)
         return nil, nil, whiskErr
     }
@@ -217,7 +217,7 @@ func (s *ActionService) Delete(actionName string) (*http.Response, error) {
         Debug(DbgError, "http.NewRequest(DELETE, %s, nil) error: '%s'\n", route, err)
         errMsg := wski18n.T("Unable to create HTTP request for DELETE '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_NETWORK, DISPLAY_MSG,
+        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXIT_CODE_ERR_NETWORK, DISPLAY_MSG,
             NO_DISPLAY_USAGE)
         return nil, whiskErr
     }
@@ -246,7 +246,7 @@ func (s *ActionService) Invoke(actionName string, payload interface{}, blocking
         Debug(DbgError, "http.NewRequest(POST, %s, %#v) error: '%s'\n", route, payload, err)
         errMsg := wski18n.T("Unable to create HTTP request for POST '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_NETWORK, DISPLAY_MSG,
+        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXIT_CODE_ERR_NETWORK, DISPLAY_MSG,
             NO_DISPLAY_USAGE)
         return nil, nil, whiskErr
     }
diff --git a/whisk/activation.go b/whisk/activation.go
index 22e6f6a..654c405 100644
--- a/whisk/activation.go
+++ b/whisk/activation.go
@@ -79,7 +79,7 @@ func (s *ActivationService) List(options *ActivationListOptions) ([]Activation,
         Debug(DbgError, "addRouteOptions(%s, %#v) error: '%s'\n", route, options, err)
         errStr := wski18n.T("Unable to append options '{{.options}}' to URL route '{{.route}}': {{.err}}",
             map[string]interface{}{"options": fmt.Sprintf("%#v", options), "route": route, "err": err})
-        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, nil, werr
     }
 
@@ -88,7 +88,7 @@ func (s *ActivationService) List(options *ActivationListOptions) ([]Activation,
         Debug(DbgError, "http.NewRequestUrl(GET, %s, nil, IncludeNamespaceInUrl, AppendOpenWhiskPathPrefix, EncodeBodyAsJson, AuthRequired) error: '%s'\n", route, err)
         errStr := wski18n.T("Unable to create HTTP request for GET '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, nil, werr
     }
 
@@ -119,7 +119,7 @@ func (s *ActivationService) Get(activationID string) (*Activation, *http.Respons
         Debug(DbgError, "http.NewRequest(GET, %s) error: '%s'\n", route, err)
         errStr := wski18n.T("Unable to create HTTP request for GET '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, nil, werr
     }
 
@@ -148,7 +148,7 @@ func (s *ActivationService) Logs(activationID string) (*Activation, *http.Respon
         Debug(DbgError, "http.NewRequest(GET, %s) error: '%s'\n", route, err)
         errStr := wski18n.T("Unable to create HTTP request for GET '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, nil, werr
     }
 
@@ -177,7 +177,7 @@ func (s *ActivationService) Result(activationID string) (*Response, *http.Respon
         Debug(DbgError, "http.NewRequest(GET, %s) error: '%s'\n", route, err)
         errStr := wski18n.T("Unable to create HTTP request for GET '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, nil, werr
     }
 
diff --git a/whisk/api.go b/whisk/api.go
index 9667017..1fa8d7b 100644
--- a/whisk/api.go
+++ b/whisk/api.go
@@ -170,7 +170,7 @@ func (s *ApiService) List(apiListOptions *ApiListRequestOptions) (*ApiListRespon
         Debug(DbgError, "addRouteOptions(%s, %#v) error: '%s'\n", route, apiListOptions, err)
         errMsg := wski18n.T("Unable to add route options '{{.options}}'",
             map[string]interface{}{"options": apiListOptions})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG,
+        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG,
             NO_DISPLAY_USAGE)
         return nil, nil, whiskErr
     }
@@ -181,7 +181,7 @@ func (s *ApiService) List(apiListOptions *ApiListRequestOptions) (*ApiListRespon
         Debug(DbgError, "http.NewRequestUrl(GET, %s, nil, DoNotIncludeNamespaceInUrl, AppendOpenWhiskPathPrefix, EncodeBodyAsJson) error: '%s'\n", routeUrl, err)
         errMsg := wski18n.T("Unable to create HTTP request for GET '{{.route}}': {{.err}}",
             map[string]interface{}{"route": routeUrl, "err": err})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_NETWORK, DISPLAY_MSG,
+        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXIT_CODE_ERR_NETWORK, DISPLAY_MSG,
             NO_DISPLAY_USAGE)
         return nil, nil, whiskErr
     }
@@ -211,7 +211,7 @@ func (s *ApiService) Insert(api *ApiCreateRequest, options *ApiCreateRequestOpti
         Debug(DbgError, "addRouteOptions(%s, %#v) error: '%s'\n", route, options, err)
         errMsg := wski18n.T("Unable to add route options '{{.options}}'",
             map[string]interface{}{"options": options})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG,
+        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG,
             NO_DISPLAY_USAGE)
         return nil, nil, whiskErr
     }
@@ -222,7 +222,7 @@ func (s *ApiService) Insert(api *ApiCreateRequest, options *ApiCreateRequestOpti
         Debug(DbgError, "http.NewRequestUrl(POST, %s, nil, DoNotIncludeNamespaceInUrl, AppendOpenWhiskPathPrefix, EncodeBodyAsJson) error: '%s'\n", route, err)
         errMsg := wski18n.T("Unable to create HTTP request for POST '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_NETWORK, DISPLAY_MSG,
+        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXIT_CODE_ERR_NETWORK, DISPLAY_MSG,
             NO_DISPLAY_USAGE)
         return nil, nil, whiskErr
     }
@@ -252,7 +252,7 @@ func (s *ApiService) Get(api *ApiGetRequest, options *ApiGetRequestOptions) (*Ap
         Debug(DbgError, "addRouteOptions(%s, %#v) error: '%s'\n", route, options, err)
         errMsg := wski18n.T("Unable to add route options '{{.options}}'",
             map[string]interface{}{"options": options})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG,
+        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG,
             NO_DISPLAY_USAGE)
         return nil, nil, whiskErr
     }
@@ -263,7 +263,7 @@ func (s *ApiService) Get(api *ApiGetRequest, options *ApiGetRequestOptions) (*Ap
         Debug(DbgError, "http.NewRequestUrl(GET, %s, nil, DoNotIncludeNamespaceInUrl, AppendOpenWhiskPathPrefix, EncodeBodyAsJson) error: '%s'\n", route, err)
         errMsg := wski18n.T("Unable to create HTTP request for GET '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_NETWORK, DISPLAY_MSG,
+        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXIT_CODE_ERR_NETWORK, DISPLAY_MSG,
             NO_DISPLAY_USAGE)
         return nil, nil, whiskErr
     }
@@ -287,7 +287,7 @@ func (s *ApiService) Delete(api *ApiDeleteRequest, options *ApiDeleteRequestOpti
         Debug(DbgError, "addRouteOptions(%s, %#v) error: '%s'\n", route, options, err)
         errMsg := wski18n.T("Unable to add route options '{{.options}}'",
             map[string]interface{}{"options": options})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG,
+        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG,
             NO_DISPLAY_USAGE)
         return nil, whiskErr
     }
@@ -298,7 +298,7 @@ func (s *ApiService) Delete(api *ApiDeleteRequest, options *ApiDeleteRequestOpti
         Debug(DbgError, "http.NewRequestUrl(DELETE, %s, nil, DoNotIncludeNamespaceInUrl, AppendOpenWhiskPathPrefix, EncodeBodyAsJson) error: '%s'\n", route, err)
         errMsg := wski18n.T("Unable to create HTTP request for DELETE '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_NETWORK, DISPLAY_MSG,
+        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXIT_CODE_ERR_NETWORK, DISPLAY_MSG,
             NO_DISPLAY_USAGE)
         return nil, whiskErr
     }
@@ -319,7 +319,7 @@ func validateApiListResponse(apiList *ApiListResponse) error {
         if apiList.Apis[i].ApiValue == nil {
             Debug(DbgError, "validateApiResponse: No value stanza in api %v\n", apiList.Apis[i])
             errMsg := wski18n.T("Internal error. Missing value stanza in API configuration response")
-            whiskErr := MakeWskError(errors.New(errMsg), EXITCODE_ERR_NETWORK, DISPLAY_MSG, NO_DISPLAY_USAGE)
+            whiskErr := MakeWskError(errors.New(errMsg), EXIT_CODE_ERR_NETWORK, DISPLAY_MSG, NO_DISPLAY_USAGE)
             return whiskErr
         }
         err := validateApiSwaggerResponse(apiList.Apis[i].ApiValue.Swagger)
@@ -335,7 +335,7 @@ func validateApiSwaggerResponse(swagger *ApiSwagger) error {
     if swagger == nil {
         Debug(DbgError, "validateApiSwaggerResponse: No apidoc stanza in api\n")
         errMsg := wski18n.T("Internal error. Missing apidoc stanza in API configuration")
-        whiskErr := MakeWskError(errors.New(errMsg), EXITCODE_ERR_NETWORK, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        whiskErr := MakeWskError(errors.New(errMsg), EXIT_CODE_ERR_NETWORK, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return whiskErr
     }
     for path, _ := range swagger.Paths {
@@ -365,7 +365,7 @@ func validateApiOperation(opName string, op *ApiSwaggerOperation) error {
         Debug(DbgError, "validateApiOperation: No operationId field in operation %v\n", op)
         errMsg := wski18n.T("Missing operationId field in API configuration for operation {{.op}}",
             map[string]interface{}{"op": opName})
-        whiskErr := MakeWskError(errors.New(errMsg), EXITCODE_ERR_NETWORK, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        whiskErr := MakeWskError(errors.New(errMsg), EXIT_CODE_ERR_NETWORK, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return whiskErr
     }
 
@@ -373,7 +373,7 @@ func validateApiOperation(opName string, op *ApiSwaggerOperation) error {
         Debug(DbgError, "validateApiOperation: no x-openwhisk.namespace stanza in operation %v\n", op)
         errMsg := wski18n.T("Missing x-openwhisk.namespace field in API configuration for operation {{.op}}",
             map[string]interface{}{"op": opName})
-        whiskErr := MakeWskError(errors.New(errMsg), EXITCODE_ERR_NETWORK, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        whiskErr := MakeWskError(errors.New(errMsg), EXIT_CODE_ERR_NETWORK, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return whiskErr
     }
 
@@ -383,14 +383,14 @@ func validateApiOperation(opName string, op *ApiSwaggerOperation) error {
         Debug(DbgError, "validateApiOperation: no x-openwhisk.action stanza in operation %v\n", op)
         errMsg := wski18n.T("Missing x-openwhisk.action field in API configuration for operation {{.op}}",
             map[string]interface{}{"op": opName})
-        whiskErr := MakeWskError(errors.New(errMsg), EXITCODE_ERR_NETWORK, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        whiskErr := MakeWskError(errors.New(errMsg), EXIT_CODE_ERR_NETWORK, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return whiskErr
     }
     if (op.XOpenWhisk != nil && len(op.XOpenWhisk.ApiUrl) == 0) {
         Debug(DbgError, "validateApiOperation: no x-openwhisk.url stanza in operation %v\n", op)
         errMsg := wski18n.T("Missing x-openwhisk.url field in API configuration for operation {{.op}}",
             map[string]interface{}{"op": opName})
-        whiskErr := MakeWskError(errors.New(errMsg), EXITCODE_ERR_NETWORK, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        whiskErr := MakeWskError(errors.New(errMsg), EXIT_CODE_ERR_NETWORK, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return whiskErr
     }
     return nil
diff --git a/whisk/client.go b/whisk/client.go
index d3c3670..9ea5823 100644
--- a/whisk/client.go
+++ b/whisk/client.go
@@ -113,7 +113,7 @@ func NewClient(httpClient *http.Client, config *Config) (*Client, error) {
             Debug(DbgError, "url.Parse(%s) error: %s\n", defaultBaseURL, err)
             errStr := wski18n.T("Unable to create request URL '{{.url}}': {{.err}}",
                 map[string]interface{}{"url": defaultBaseURL, "err": err})
-            werr := MakeWskError(errors.New(errStr), EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+            werr := MakeWskError(errors.New(errStr), EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
             return nil, werr
         }
     }
@@ -165,7 +165,7 @@ func (c *Client) NewRequest(method, urlStr string, body interface{}, includeName
         Debug(DbgError, "url.Parse(%s) error: %s\n", urlStr, err)
         errStr := wski18n.T("Invalid request URL '{{.url}}': {{.err}}",
             map[string]interface{}{"url": urlStr, "err": err})
-        werr := MakeWskError(errors.New(errStr), EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskError(errors.New(errStr), EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, werr
     }
 
@@ -179,7 +179,7 @@ func (c *Client) NewRequest(method, urlStr string, body interface{}, includeName
         if err != nil {
             Debug(DbgError, "json.Encode(%#v) error: %s\n", body, err)
             errStr := wski18n.T("Error encoding request body: {{.err}}", map[string]interface{}{"err": err})
-            werr := MakeWskError(errors.New(errStr), EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+            werr := MakeWskError(errors.New(errStr), EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
             return nil, werr
         }
     }
@@ -188,7 +188,7 @@ func (c *Client) NewRequest(method, urlStr string, body interface{}, includeName
     if err != nil {
         Debug(DbgError, "http.NewRequest(%v, %s, buf) error: %s\n", method, u.String(), err)
         errStr := wski18n.T("Error initializing request: {{.err}}", map[string]interface{}{"err": err})
-        werr := MakeWskError(errors.New(errStr), EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskError(errors.New(errStr), EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, werr
     }
     if req.Body != nil {
@@ -200,7 +200,7 @@ func (c *Client) NewRequest(method, urlStr string, body interface{}, includeName
         Debug(DbgError, "addAuthHeader() error: %s\n", err)
         errStr := wski18n.T("Unable to add the HTTP authentication header: {{.err}}",
             map[string]interface{}{"err": err})
-        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, werr
     }
 
@@ -216,7 +216,7 @@ func (c *Client) addAuthHeader(req *http.Request, authRequired bool) error {
         if authRequired {
             Debug(DbgError, "The required authorization key is not configured - neither set as a property nor set via the --auth CLI argument\n")
             errStr := wski18n.T("Authorization key is not configured (--auth is required)")
-            werr := MakeWskError(errors.New(errStr), EXITCODE_ERR_USAGE, DISPLAY_MSG, DISPLAY_USAGE)
+            werr := MakeWskError(errors.New(errStr), EXIT_CODE_ERR_USAGE, DISPLAY_MSG, DISPLAY_USAGE)
             return werr
         }
     }
@@ -231,7 +231,7 @@ func bodyTruncator(body io.ReadCloser) (string, io.ReadCloser, error) {
     data, err := ioutil.ReadAll(body)
     if err != nil {
         Verbose("ioutil.ReadAll(req.Body) error: %s\n", err)
-        werr := MakeWskError(err, EXITCODE_ERR_NETWORK, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskError(err, EXIT_CODE_ERR_NETWORK, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return "", body, werr
     }
 
@@ -282,7 +282,7 @@ func (c *Client) Do(req *http.Request, v interface{}, ExitWithErrorOnTimeout boo
     resp, err := c.client.Do(req)
     if err != nil {
         Debug(DbgError, "HTTP Do() [req %s] error: %s\n", req.URL.String(), err)
-        werr := MakeWskError(err, EXITCODE_ERR_NETWORK, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskError(err, EXIT_CODE_ERR_NETWORK, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, werr
     }
 
@@ -300,7 +300,7 @@ func (c *Client) Do(req *http.Request, v interface{}, ExitWithErrorOnTimeout boo
     data, err := ioutil.ReadAll(resp.Body)
     if err != nil {
         Debug(DbgError, "ioutil.ReadAll(resp.Body) error: %s\n", err)
-        werr := MakeWskError(err, EXITCODE_ERR_NETWORK, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskError(err, EXIT_CODE_ERR_NETWORK, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return resp, werr
     }
 
@@ -370,9 +370,9 @@ func (c *Client) Do(req *http.Request, v interface{}, ExitWithErrorOnTimeout boo
 
         // If a timeout occurs, 202 HTTP status code is returned, and the caller wishes to handle such an event, return
         // an error corresponding with the timeout
-        if ExitWithErrorOnTimeout && resp.StatusCode == EXITCODE_TIMED_OUT {
+        if ExitWithErrorOnTimeout && resp.StatusCode == EXIT_CODE_TIMED_OUT {
             errMsg :=  wski18n.T("Request accepted, but processing not completed yet.")
-            err = MakeWskError(errors.New(errMsg), EXITCODE_TIMED_OUT, NO_DISPLAY_MSG, NO_DISPLAY_USAGE,
+            err = MakeWskError(errors.New(errMsg), EXIT_CODE_TIMED_OUT, NO_DISPLAY_MSG, NO_DISPLAY_USAGE,
                 NO_MSG_DISPLAYED, NO_DISPLAY_PREFIX, NO_APPLICATION_ERR, TIMED_OUT)
         }
 
@@ -380,7 +380,7 @@ func (c *Client) Do(req *http.Request, v interface{}, ExitWithErrorOnTimeout boo
     }
 
     // We should never get here, but just in case return failure to keep the compiler happy
-    werr := MakeWskError(errors.New(wski18n.T("Command failed due to an internal failure")), EXITCODE_ERR_GENERAL,
+    werr := MakeWskError(errors.New(wski18n.T("Command failed due to an internal failure")), EXIT_CODE_ERR_GENERAL,
         DISPLAY_MSG, NO_DISPLAY_USAGE)
     return resp, werr
 }
@@ -576,7 +576,7 @@ func (c *Client) NewRequestUrl(
             Debug(DbgError, "url.Parse(%s) error: %s\n", urlStr, err)
             errStr := wski18n.T("Invalid request URL '{{.url}}': {{.err}}",
                 map[string]interface{}{"url": urlStr, "err": err})
-            werr := MakeWskError(errors.New(errStr), EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+            werr := MakeWskError(errors.New(errStr), EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
             return nil, werr
         }
     } else {
@@ -587,7 +587,7 @@ func (c *Client) NewRequestUrl(
             Debug(DbgError, "url.Parse(%s) error: %s\n", urlStr, err)
             errStr := wski18n.T("Invalid request URL '{{.url}}': {{.err}}",
                 map[string]interface{}{"url": urlStr, "err": err})
-            werr := MakeWskError(errors.New(errStr), EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+            werr := MakeWskError(errors.New(errStr), EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
             return nil, werr
         }
     }
@@ -604,7 +604,7 @@ func (c *Client) NewRequestUrl(
                 Debug(DbgError, "json.Encode(%#v) error: %s\n", body, err)
                 errStr := wski18n.T("Error encoding request body: {{.err}}",
                     map[string]interface{}{"err": err})
-                werr := MakeWskError(errors.New(errStr), EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+                werr := MakeWskError(errors.New(errStr), EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
                 return nil, werr
             }
         } else if (encodeBodyAs == EncodeBodyAsFormData) {
@@ -613,14 +613,14 @@ func (c *Client) NewRequestUrl(
             } else {
                 Debug(DbgError, "Invalid form data body: %v\n", body)
                 errStr := wski18n.T("Internal error.  Form data encoding failure")
-                werr := MakeWskError(errors.New(errStr), EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+                werr := MakeWskError(errors.New(errStr), EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
                 return nil, werr
             }
         } else {
             Debug(DbgError, "Invalid body encode type: %s\n", encodeBodyAs)
             errStr := wski18n.T("Internal error.  Invalid encoding type '{{.encodetype}}'",
                 map[string]interface{}{"encodetype": encodeBodyAs})
-            werr := MakeWskError(errors.New(errStr), EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+            werr := MakeWskError(errors.New(errStr), EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
             return nil, werr
         }
     }
@@ -629,7 +629,7 @@ func (c *Client) NewRequestUrl(
     if err != nil {
         Debug(DbgError, "http.NewRequest(%v, %s, buf) error: %s\n", method, requestUrl.String(), err)
         errStr := wski18n.T("Error initializing request: {{.err}}", map[string]interface{}{"err": err})
-        werr := MakeWskError(errors.New(errStr), EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskError(errors.New(errStr), EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, werr
     }
     if (req.Body != nil && encodeBodyAs == EncodeBodyAsJson) {
@@ -645,7 +645,7 @@ func (c *Client) NewRequestUrl(
             Debug(DbgError, "addAuthHeader() error: %s\n", err)
             errStr := wski18n.T("Unable to add the HTTP authentication header: {{.err}}",
                 map[string]interface{}{"err": err})
-            werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+            werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
             return nil, werr
         }
     } else {
diff --git a/whisk/info.go b/whisk/info.go
index c8a79dd..ce8d269 100644
--- a/whisk/info.go
+++ b/whisk/info.go
@@ -44,7 +44,7 @@ func (s *InfoService) Get() (*Info, *http.Response, error) {
         Debug(DbgError, "url.Parse(%s) error: %s\n", urlStr, err)
         errStr := wski18n.T("Unable to URL parse '{{.version}}': {{.err}}",
             map[string]interface{}{"version": urlStr, "err": err})
-        werr := MakeWskError(errors.New(errStr), EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskError(errors.New(errStr), EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, nil, werr
     }
 
@@ -53,7 +53,7 @@ func (s *InfoService) Get() (*Info, *http.Response, error) {
         Debug(DbgError, "http.NewRequest(GET, %s) error: %s\n", u.String(), err)
         errStr := wski18n.T("Unable to create HTTP request for GET '{{.url}}': {{.err}}",
             map[string]interface{}{"url": u.String(), "err": err})
-        werr := MakeWskError(errors.New(errStr), EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskError(errors.New(errStr), EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, nil, werr
     }
 
diff --git a/whisk/namespace.go b/whisk/namespace.go
index 195cc06..0705608 100644
--- a/whisk/namespace.go
+++ b/whisk/namespace.go
@@ -51,7 +51,7 @@ func (s *NamespaceService) List() ([]Namespace, *http.Response, error) {
         Debug(DbgError, "s.client.NewRequest(GET) error: %s\n", err)
         errStr := wski18n.T("Unable to create HTTP request for GET: {{.err}}",
             map[string]interface{}{"err": err})
-        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, nil, werr
     }
 
@@ -89,7 +89,7 @@ func (s *NamespaceService) Get(namespace string) (*Namespace, *http.Response, er
     if err != nil {
         Debug(DbgError, "s.client.NewRequest(GET) error: %s\n", err)
         errStr := wski18n.T("Unable to create HTTP request for GET: {{.err}}", map[string]interface{}{"err": err})
-        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return resNamespace, nil, werr
     }
 
diff --git a/whisk/package.go b/whisk/package.go
index 2049d07..7b96180 100644
--- a/whisk/package.go
+++ b/whisk/package.go
@@ -90,7 +90,7 @@ func (s *PackageService) List(options *PackageListOptions) ([]Package, *http.Res
     if err != nil {
         Debug(DbgError, "addRouteOptions(%s, %#v) error: '%s'\n", route, options, err)
         errStr := wski18n.T("Unable to build request URL: {{.err}}", map[string]interface{}{"err": err})
-        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, nil, werr
     }
 
@@ -99,7 +99,7 @@ func (s *PackageService) List(options *PackageListOptions) ([]Package, *http.Res
         Debug(DbgError, "http.NewRequestUrl(GET, %s, nil, IncludeNamespaceInUrl, AppendOpenWhiskPathPrefix, EncodeBodyAsJson, AuthRequired); error: '%s'\n", route, err)
         errStr := wski18n.T("Unable to create GET HTTP request for '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, nil, werr
     }
 
@@ -125,7 +125,7 @@ func (s *PackageService) Get(packageName string) (*Package, *http.Response, erro
         Debug(DbgError, "http.NewRequest(GET, %s); error: '%s'\n", route, err)
         errStr := wski18n.T("Unable to create GET HTTP request for '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, nil, werr
     }
 
@@ -151,7 +151,7 @@ func (s *PackageService) Insert(x_package PackageInterface, overwrite bool) (*Pa
         Debug(DbgError, "http.NewRequest(PUT, %s); error: '%s'\n", route, err)
         errStr := wski18n.T("Unable to create PUT HTTP request for '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, nil, werr
     }
 
@@ -176,7 +176,7 @@ func (s *PackageService) Delete(packageName string) (*http.Response, error) {
         Debug(DbgError, "http.NewRequest(DELETE, %s); error: '%s'\n", route, err)
         errStr := wski18n.T("Unable to create DELETE HTTP request for '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, werr
     }
 
@@ -197,7 +197,7 @@ func (s *PackageService) Refresh() (*BindingUpdates, *http.Response, error) {
         Debug(DbgError, "http.NewRequest(POST, %s); error: '%s'\n", route, err)
         errStr := wski18n.T("Unable to create POST HTTP request for '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, nil, werr
     }
 
diff --git a/whisk/rule.go b/whisk/rule.go
index 8dcc680..ab268e2 100644
--- a/whisk/rule.go
+++ b/whisk/rule.go
@@ -54,7 +54,7 @@ func (s *RuleService) List(options *RuleListOptions) ([]Rule, *http.Response, er
         Debug(DbgError, "addRouteOptions(%s, %#v) error: '%s'\n", route, options, err)
         errStr := wski18n.T("Unable to append options '{{.options}}' to URL route '{{.route}}': {{.err}}",
             map[string]interface{}{"options": fmt.Sprintf("%#v", options), "route": route, "err": err})
-        werr := MakeWskError(errors.New(errStr), EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskError(errors.New(errStr), EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, nil, werr
     }
 
@@ -63,7 +63,7 @@ func (s *RuleService) List(options *RuleListOptions) ([]Rule, *http.Response, er
         Debug(DbgError, "http.NewRequestUrl(GET, %s, nil, IncludeNamespaceInUrl, AppendOpenWhiskPathPrefix, EncodeBodyAsJson, AuthRequired); error: '%s'\n", route, err)
         errStr := wski18n.T("Unable to create HTTP request for GET '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, nil, werr
     }
 
@@ -88,7 +88,7 @@ func (s *RuleService) Insert(rule *Rule, overwrite bool) (*Rule, *http.Response,
         Debug(DbgError, "http.NewRequest(PUT, %s); error: '%s'\n", route, err)
         errStr := wski18n.T("Unable to create HTTP request for PUT '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, nil, werr
     }
 
@@ -113,7 +113,7 @@ func (s *RuleService) Get(ruleName string) (*Rule, *http.Response, error) {
         Debug(DbgError, "http.NewRequest(GET, %s); error: '%s'\n", route, err)
         errStr := wski18n.T("Unable to create HTTP request for GET '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, nil, werr
     }
 
@@ -138,7 +138,7 @@ func (s *RuleService) Delete(ruleName string) (*http.Response, error) {
         Debug(DbgError, "http.NewRequest(DELETE, %s); error: '%s'\n", route, err)
         errStr := wski18n.T("Unable to create HTTP request for DELETE '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, werr
     }
 
@@ -156,7 +156,7 @@ func (s *RuleService) SetState(ruleName string, state string) (*Rule, *http.Resp
     if state != "active" && state != "inactive" {
         errStr := wski18n.T("Internal error. Invalid state option '{{.state}}'. Valid options are \"active\" and \"inactive\".",
             map[string]interface{}{"state": state})
-        werr := MakeWskError(errors.New(errStr), EXITCODE_ERR_GENERAL, DISPLAY_MSG, DISPLAY_USAGE)
+        werr := MakeWskError(errors.New(errStr), EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, DISPLAY_USAGE)
         return nil, nil, werr
     }
 
@@ -172,7 +172,7 @@ func (s *RuleService) SetState(ruleName string, state string) (*Rule, *http.Resp
         Debug(DbgError, "http.NewRequest(POST, %s); error: '%s'\n", route, err)
         errStr := wski18n.T("Unable to create HTTP request for POST '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, nil, werr
     }
 
diff --git a/whisk/sdk.go b/whisk/sdk.go
index 25809b4..9269a83 100644
--- a/whisk/sdk.go
+++ b/whisk/sdk.go
@@ -47,7 +47,7 @@ func (s *SdkService) Install(relFileUrl string) (*http.Response, error) {
         Debug(DbgError, "http.NewRequest(GET, %s, nil) error: %s\n", urlStr, err)
         errStr := wski18n.T("Unable to create HTTP request for GET '{{.url}}': {{.err}}",
             map[string]interface{}{"url": urlStr, "err": err})
-        werr := MakeWskError(errors.New(errStr), EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskError(errors.New(errStr), EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, werr
     }
 
diff --git a/whisk/shared.go b/whisk/shared.go
index f91787d..5b81f91 100644
--- a/whisk/shared.go
+++ b/whisk/shared.go
@@ -17,7 +17,10 @@
 
 package whisk
 
-import "encoding/json"
+import (
+    "encoding/json"
+    "strings"
+)
 
 type KeyValue struct {
     Key     string          `json:"key"`
@@ -43,6 +46,29 @@ func (keyValueArr KeyValueArr) GetValue(key string) (res interface{}) {
     return res
 }
 
+func (keyValueArr KeyValueArr) FindKeyValue(key string) (int) {
+    for i := 0; i < len(keyValueArr); i++ {
+        if strings.ToLower(keyValueArr[i].Key) == strings.ToLower(key) {
+            return i
+        }
+    }
+
+    return -1
+}
+
+/*
+Appends items from appKeyValueArr to keyValueArr if the appKeyValueArr item does not exist in keyValueArr.
+ */
+func (keyValueArr KeyValueArr) AppendKeyValueArr(appKeyValueArr KeyValueArr) (KeyValueArr) {
+    for i := 0; i < len(appKeyValueArr); i++ {
+        if KeyValueArr.FindKeyValue(keyValueArr, appKeyValueArr[i].Key) == -1 {
+            keyValueArr = append(keyValueArr, appKeyValueArr[i])
+        }
+    }
+
+    return keyValueArr
+}
+
 type Annotations []map[string]interface{}
 
 type Parameters *json.RawMessage
diff --git a/whisk/trigger.go b/whisk/trigger.go
index afe759f..0d0fb76 100644
--- a/whisk/trigger.go
+++ b/whisk/trigger.go
@@ -54,7 +54,7 @@ func (s *TriggerService) List(options *TriggerListOptions) ([]Trigger, *http.Res
         Debug(DbgError, "addRouteOptions(%s, %#v) error: '%s'\n", route, options, err)
         errStr := wski18n.T("Unable to append options '{{.options}}' to URL route '{{.route}}': {{.err}}",
             map[string]interface{}{"options": fmt.Sprintf("%#v", options), "route": route, "err": err})
-        werr := MakeWskError(errors.New(errStr), EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskError(errors.New(errStr), EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, nil, werr
     }
 
@@ -63,7 +63,7 @@ func (s *TriggerService) List(options *TriggerListOptions) ([]Trigger, *http.Res
         Debug(DbgError, "http.NewRequestUrl(GET, %s, nil, IncludeNamespaceInUrl, AppendOpenWhiskPathPrefix, EncodeBodyAsJson, AuthRequired); error: '%s'\n", route, err)
         errStr := wski18n.T("Unable to create HTTP request for GET '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, nil, werr
     }
 
@@ -88,7 +88,7 @@ func (s *TriggerService) Insert(trigger *Trigger, overwrite bool) (*Trigger, *ht
         Debug(DbgError, "url.Parse(%s) error: %s\n", route, err)
         errStr := wski18n.T("Invalid request URL '{{.url}}': {{.err}}",
             map[string]interface{}{"url": route, "err": err})
-        werr := MakeWskError(errors.New(errStr), EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskError(errors.New(errStr), EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, nil, werr
     }
 
@@ -97,7 +97,7 @@ func (s *TriggerService) Insert(trigger *Trigger, overwrite bool) (*Trigger, *ht
         Debug(DbgError, "http.NewRequestUrl(PUT, %s, %+v, IncludeNamespaceInUrl, AppendOpenWhiskPathPrefix, EncodeBodyAsJson, AuthRequired); error: '%s'\n", routeUrl, trigger, err)
         errStr := wski18n.T("Unable to create HTTP request for PUT '{{.route}}': {{.err}}",
             map[string]interface{}{"route": routeUrl, "err": err})
-        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, nil, werr
     }
 
@@ -123,7 +123,7 @@ func (s *TriggerService) Get(triggerName string) (*Trigger, *http.Response, erro
         Debug(DbgError, "http.NewRequest(GET, %s); error: '%s'\n", route, err)
         errStr := wski18n.T("Unable to create HTTP request for GET '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, nil, werr
     }
 
@@ -149,7 +149,7 @@ func (s *TriggerService) Delete(triggerName string) (*Trigger, *http.Response, e
         Debug(DbgError, "http.NewRequest(DELETE, %s); error: '%s'\n", route, err)
         errStr := wski18n.T("Unable to create HTTP request for DELETE '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, nil, werr
     }
 
@@ -174,7 +174,7 @@ func (s *TriggerService) Fire(triggerName string, payload interface{}) (*Trigger
         Debug(DbgError," http.NewRequest(POST, %s); error: '%s'\n", route, err)
         errStr := wski18n.T("Unable to create HTTP request for POST '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskErrorFromWskError(errors.New(errStr), err, EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, nil, werr
     }
 
diff --git a/whisk/util.go b/whisk/util.go
index f5b1d62..150647f 100644
--- a/whisk/util.go
+++ b/whisk/util.go
@@ -38,7 +38,7 @@ func addRouteOptions(route string, options interface{}) (*url.URL, error) {
         Debug(DbgError,"url.Parse(%s) error: %s\n", route, err)
         errStr := wski18n.T("Unable to parse URL '{{.route}}': {{.err}}",
             map[string]interface{}{"route": route, "err": err})
-        werr := MakeWskError(errors.New(errStr), EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskError(errors.New(errStr), EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, werr
     }
 
@@ -52,7 +52,7 @@ func addRouteOptions(route string, options interface{}) (*url.URL, error) {
         Debug(DbgError,"query.Values(%#v) error: %s\n", options, err)
         errStr := wski18n.T("Unable to process URL query options '{{.options}}': {{.err}}",
             map[string]interface{}{"options": fmt.Sprintf("%#v", options), "err": err})
-        werr := MakeWskError(errors.New(errStr), EXITCODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        werr := MakeWskError(errors.New(errStr), EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, werr
     }
 
diff --git a/whisk/wskerror.go b/whisk/wskerror.go
index c493316..a8adcde 100644
--- a/whisk/wskerror.go
+++ b/whisk/wskerror.go
@@ -17,12 +17,13 @@
 
 package whisk
 
-const EXITCODE_ERR_GENERAL      int = 1
-const EXITCODE_ERR_USAGE        int = 2
-const EXITCODE_ERR_NETWORK      int = 3
-const EXITCODE_ERR_HTTP_RESP    int = 4
+const EXIT_CODE_ERR_GENERAL     int = 1
+const EXIT_CODE_ERR_USAGE       int = 2
+const EXIT_CODE_ERR_NETWORK     int = 3
+const EXIT_CODE_ERR_HTTP_RESP   int = 4
 const NOT_ALLOWED               int = 149
-const EXITCODE_TIMED_OUT        int = 202
+const EXIT_CODE_TIMED_OUT       int = 202
+const EXIT_CODE_NOT_FOUND       int = 148
 
 const DISPLAY_MSG               bool = true
 const NO_DISPLAY_MSG            bool = false
diff --git a/wski18n/i18n_resources.go b/wski18n/i18n_resources.go
index e1da42b..b7418d9 100644
--- a/wski18n/i18n_resources.go
+++ b/wski18n/i18n_resources.go
@@ -113,7 +113,7 @@ func wski18nResourcesDe_deAllJson() (*asset, error) {
         return nil, err
     }
 
-    info := bindataFileInfo{name: "wski18n/resources/de_DE.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1500156677, 0)}
+    info := bindataFileInfo{name: "wski18n/resources/de_DE.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1502307767, 0)}
     a := &asset{bytes: bytes, info: info}
     return a, nil
 }
@@ -133,7 +133,7 @@ func wski18nResourcesEn_usAllJson() (*asset, error) {
         return nil, err
     }
 
-    info := bindataFileInfo{name: "wski18n/resources/en_US.all.json", size: 4659, mode: os.FileMode(420), modTime: time.Unix(1500156677, 0)}
+    info := bindataFileInfo{name: "wski18n/resources/en_US.all.json", size: 4659, mode: os.FileMode(420), modTime: time.Unix(1502307767, 0)}
     a := &asset{bytes: bytes, info: info}
     return a, nil
 }
@@ -153,7 +153,7 @@ func wski18nResourcesEs_esAllJson() (*asset, error) {
         return nil, err
     }
 
-    info := bindataFileInfo{name: "wski18n/resources/es_ES.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1500156677, 0)}
+    info := bindataFileInfo{name: "wski18n/resources/es_ES.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1502307767, 0)}
     a := &asset{bytes: bytes, info: info}
     return a, nil
 }
@@ -173,7 +173,7 @@ func wski18nResourcesFr_frAllJson() (*asset, error) {
         return nil, err
     }
 
-    info := bindataFileInfo{name: "wski18n/resources/fr_FR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1500156677, 0)}
+    info := bindataFileInfo{name: "wski18n/resources/fr_FR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1502307767, 0)}
     a := &asset{bytes: bytes, info: info}
     return a, nil
 }
@@ -193,7 +193,7 @@ func wski18nResourcesIt_itAllJson() (*asset, error) {
         return nil, err
     }
 
-    info := bindataFileInfo{name: "wski18n/resources/it_IT.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1500156677, 0)}
+    info := bindataFileInfo{name: "wski18n/resources/it_IT.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1502307767, 0)}
     a := &asset{bytes: bytes, info: info}
     return a, nil
 }
@@ -213,7 +213,7 @@ func wski18nResourcesJa_jaAllJson() (*asset, error) {
         return nil, err
     }
 
-    info := bindataFileInfo{name: "wski18n/resources/ja_JA.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1500156677, 0)}
+    info := bindataFileInfo{name: "wski18n/resources/ja_JA.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1502307767, 0)}
     a := &asset{bytes: bytes, info: info}
     return a, nil
 }
@@ -233,7 +233,7 @@ func wski18nResourcesKo_krAllJson() (*asset, error) {
         return nil, err
     }
 
-    info := bindataFileInfo{name: "wski18n/resources/ko_KR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1500156677, 0)}
+    info := bindataFileInfo{name: "wski18n/resources/ko_KR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1502307767, 0)}
     a := &asset{bytes: bytes, info: info}
     return a, nil
 }
@@ -253,7 +253,7 @@ func wski18nResourcesPt_brAllJson() (*asset, error) {
         return nil, err
     }
 
-    info := bindataFileInfo{name: "wski18n/resources/pt_BR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1500156677, 0)}
+    info := bindataFileInfo{name: "wski18n/resources/pt_BR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1502307767, 0)}
     a := &asset{bytes: bytes, info: info}
     return a, nil
 }
@@ -273,7 +273,7 @@ func wski18nResourcesZh_hansAllJson() (*asset, error) {
         return nil, err
     }
 
-    info := bindataFileInfo{name: "wski18n/resources/zh_Hans.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1500156677, 0)}
+    info := bindataFileInfo{name: "wski18n/resources/zh_Hans.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1502307767, 0)}
     a := &asset{bytes: bytes, info: info}
     return a, nil
 }
@@ -293,7 +293,7 @@ func wski18nResourcesZh_hantAllJson() (*asset, error) {
         return nil, err
     }
 
-    info := bindataFileInfo{name: "wski18n/resources/zh_Hant.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1500156677, 0)}
+    info := bindataFileInfo{name: "wski18n/resources/zh_Hant.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1502307767, 0)}
     a := &asset{bytes: bytes, info: info}
     return a, nil
 }

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

[incubator-openwhisk-client-go] 02/03: Remove "experimental" gateway api (#2547)

Posted by cs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-client-go.git

commit 0358422b67c2b02853ad2b775fe62345a0b1a09b
Author: David Cariello <dr...@us.ibm.com>
AuthorDate: Tue Aug 8 12:14:35 2017 -0500

    Remove "experimental" gateway api (#2547)
---
 whisk/api.go | 220 +++++------------------------------------------------------
 1 file changed, 18 insertions(+), 202 deletions(-)

diff --git a/whisk/api.go b/whisk/api.go
index 6408367..9667017 100644
--- a/whisk/api.go
+++ b/whisk/api.go
@@ -33,7 +33,6 @@ type ApiCreateRequest struct {
 }
 type ApiCreateRequestOptions ApiOptions
 type ApiCreateResponse RetApi
-type ApiCreateResponseV2 RetApiV2
 
 // wsk api list : Request, Response
 type ApiListRequest struct {
@@ -44,8 +43,8 @@ type ApiListRequestOptions struct {
     Skip            int       `url:"skip"`
     Docs            bool      `url:"docs,omitempty"`
 }
+//type ApiListResponse RetApiArray
 type ApiListResponse RetApiArray
-type ApiListResponseV2 RetApiArrayV2
 
 // wsk api get : Request, Response
 type ApiGetRequest struct {
@@ -53,7 +52,6 @@ type ApiGetRequest struct {
 }
 type ApiGetRequestOptions ApiOptions
 type ApiGetResponse RetApiArray
-type ApiGetResponseV2 RetApiArrayV2
 
 // wsk api delete : Request, Response
 type ApiDeleteRequest struct {
@@ -105,7 +103,7 @@ type RetApiArray struct {
 type ApiItem struct {
     ApiId           string    `json:"id,omitempty"`
     QueryKey        string    `json:"key,omitempty"`
-    ApiValue        *RetApi   `json:"value,omitempty"`
+    ApiValue        *RetApi `json:"value,omitempty"`
 }
 
 type RetApi struct {
@@ -120,33 +118,7 @@ type ApiSwagger struct {
     SwaggerName     string    `json:"swagger,omitempty"`
     BasePath        string    `json:"basePath,omitempty"`
     Info            *ApiSwaggerInfo `json:"info,omitempty"`
-    Paths           map[string]map[string]*ApiSwaggerOperationV1 `json:"paths,omitempty"`
-    XConfig         map[string]map[string][]map[string]map[string]interface{} `json:"x-ibm-configuration,omitempty"`
-}
-
-type RetApiArrayV2 struct {
-    Apis            []ApiItemV2 `json:"apis,omitempty"`
-}
-
-type ApiItemV2 struct {
-    ApiId           string    `json:"id,omitempty"`
-    QueryKey        string    `json:"key,omitempty"`
-    ApiValue        *RetApiV2 `json:"value,omitempty"`
-}
-
-type RetApiV2 struct {
-    Namespace       string    `json:"namespace"`
-    BaseUrl         string    `json:"gwApiUrl"`
-    Activated       bool      `json:"gwApiActivated"`
-    TenantId        string    `json:"tenantId"`
-    Swagger         *ApiSwaggerV2 `json:"apidoc,omitempty"`
-}
-
-type ApiSwaggerV2 struct {
-    SwaggerName     string    `json:"swagger,omitempty"`
-    BasePath        string    `json:"basePath,omitempty"`
-    Info            *ApiSwaggerInfo `json:"info,omitempty"`
-    Paths           map[string]map[string]*ApiSwaggerOperationV2 `json:"paths,omitempty"`  // Paths["/a/path"]["get"] -> a generic object
+    Paths           map[string]map[string]*ApiSwaggerOperation `json:"paths,omitempty"`  // Paths["/a/path"]["get"] -> a generic object
     SecurityDef     interface{} `json:"securityDefinitions,omitempty"`
     Security        interface{} `json:"security,omitempty"`
     XConfig         interface{} `json:"x-ibm-configuration,omitempty"`
@@ -158,26 +130,13 @@ type ApiSwaggerInfo struct {
     Version         string    `json:"version,omitempty"`
 }
 
-type ApiSwaggerOperationV1 struct {
-    Responses       interface{} `json:"responses"`
-    XOpenWhisk      *ApiSwaggerOpXOpenWhiskV1 `json:"x-ibm-op-ext,omitempty"`
-}
-
-type ApiSwaggerOperationV2 struct {
+type ApiSwaggerOperation struct {
     OperationId     string    `json:"operationId"`
     Responses       interface{} `json:"responses"`
-    XOpenWhisk      *ApiSwaggerOpXOpenWhiskV2 `json:"x-openwhisk,omitempty"`
+    XOpenWhisk      *ApiSwaggerOpXOpenWhisk `json:"x-openwhisk,omitempty"`
 }
 
-type ApiSwaggerOpXOpenWhiskV1 struct {
-    ActionName      string    `json:"actionName"`
-    Namespace       string    `json:"actionNamespace"`
-    ActionUrlVerb   string    `json:"backendMethod"`
-    ActionUrl       string    `json:"backendUrl"`
-    Policies        interface{} `json:"policies"`
-}
-
-type ApiSwaggerOpXOpenWhiskV2 struct {
+type ApiSwaggerOpXOpenWhisk struct {
     ActionName      string    `json:"action"`
     Namespace       string    `json:"namespace"`
     Package         string    `json:"package"`
@@ -199,154 +158,11 @@ const (
     DoNotOverwrite = false
 )
 
-////////////////////
+/////////////////
 // Api Methods //
-////////////////////
+/////////////////
 
 func (s *ApiService) List(apiListOptions *ApiListRequestOptions) (*ApiListResponse, *http.Response, error) {
-    route := "web/whisk.system/routemgmt/getApi.http"
-    Debug(DbgInfo, "Api GET/list route: %s\n", route)
-
-    routeUrl, err := addRouteOptions(route, apiListOptions)
-    if err != nil {
-        Debug(DbgError, "addRouteOptions(%s, %#v) error: '%s'\n", route, apiListOptions, err)
-        errMsg := wski18n.T("Unable to add route options '{{.options}}'",
-            map[string]interface{}{"options": apiListOptions})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG,
-            NO_DISPLAY_USAGE)
-        return nil, nil, whiskErr
-    }
-    Debug(DbgInfo, "Api GET/list route with api options: %s\n", routeUrl)
-
-    req, err := s.client.NewRequestUrl("GET", routeUrl, nil, DoNotIncludeNamespaceInUrl, AppendOpenWhiskPathPrefix, EncodeBodyAsJson, AuthRequired)
-    if err != nil {
-        Debug(DbgError, "http.NewRequestUrl(GET, %s, nil, DoNotIncludeNamespaceInUrl, AppendOpenWhiskPathPrefix, EncodeBodyAsJson, AuthRequired) error: '%s'\n", routeUrl, err)
-        errMsg := wski18n.T("Unable to create HTTP request for GET '{{.route}}': {{.err}}",
-            map[string]interface{}{"route": routeUrl, "err": err})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_NETWORK, DISPLAY_MSG,
-            NO_DISPLAY_USAGE)
-        return nil, nil, whiskErr
-    }
-
-    apiArray := new(ApiListResponse)
-    resp, err := s.client.Do(req, &apiArray, ExitWithErrorOnTimeout)
-    if err != nil {
-        Debug(DbgError, "s.client.Do() error - HTTP req %s; error '%s'\n", req.URL.String(), err)
-        return nil, resp, err
-    }
-
-    return apiArray, resp, err
-}
-
-func (s *ApiService) Insert(api *ApiCreateRequest, options *ApiCreateRequestOptions, overwrite bool) (*ApiCreateResponse, *http.Response, error) {
-    route := "web/whisk.system/routemgmt/createApi.http"
-    Debug(DbgInfo, "Api PUT route: %s\n", route)
-
-    routeUrl, err := addRouteOptions(route, options)
-    if err != nil {
-        Debug(DbgError, "addRouteOptions(%s, %#v) error: '%s'\n", route, options, err)
-        errMsg := wski18n.T("Unable to add route options '{{.options}}'",
-            map[string]interface{}{"options": options})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG,
-            NO_DISPLAY_USAGE)
-        return nil, nil, whiskErr
-    }
-    Debug(DbgError, "Api create route with options: %s\n", routeUrl)
-
-    req, err := s.client.NewRequestUrl("POST", routeUrl, api, DoNotIncludeNamespaceInUrl, AppendOpenWhiskPathPrefix, EncodeBodyAsJson, AuthRequired)
-    if err != nil {
-        Debug(DbgError, "http.NewRequestUrl(POST, %s, nil, DoNotIncludeNamespaceInUrl, AppendOpenWhiskPathPrefix, EncodeBodyAsJson) error: '%s'\n", route, err)
-        errMsg := wski18n.T("Unable to create HTTP request for POST '{{.route}}': {{.err}}",
-            map[string]interface{}{"route": route, "err": err})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_NETWORK, DISPLAY_MSG,
-            NO_DISPLAY_USAGE)
-        return nil, nil, whiskErr
-    }
-
-    retApi := new(ApiCreateResponse)
-    resp, err := s.client.Do(req, &retApi, ExitWithErrorOnTimeout)
-    if err != nil {
-        Debug(DbgError, "s.client.Do() error - HTTP req %s; error '%s'\n", req.URL.String(), err)
-        return nil, resp, err
-    }
-
-    return retApi, resp, nil
-}
-
-func (s *ApiService) Get(api *ApiGetRequest, options *ApiGetRequestOptions) (*ApiGetResponse, *http.Response, error) {
-    route := "web/whisk.system/routemgmt/getApi.http"
-    Debug(DbgInfo, "Api GET route: %s\n", route)
-
-    routeUrl, err := addRouteOptions(route, options)
-    if err != nil {
-        Debug(DbgError, "addRouteOptions(%s, %#v) error: '%s'\n", route, options, err)
-        errMsg := wski18n.T("Unable to add route options '{{.options}}'",
-            map[string]interface{}{"options": options})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG,
-            NO_DISPLAY_USAGE)
-        return nil, nil, whiskErr
-    }
-    Debug(DbgError, "Api get route with options: %s\n", routeUrl)
-
-    req, err := s.client.NewRequestUrl("GET", routeUrl, nil, DoNotIncludeNamespaceInUrl, AppendOpenWhiskPathPrefix, EncodeBodyAsJson, AuthRequired)
-    if err != nil {
-        Debug(DbgError, "http.NewRequestUrl(GET, %s, nil, DoNotIncludeNamespaceInUrl, AppendOpenWhiskPathPrefix, EncodeBodyAsJson, AuthRequired) error: '%s'\n", route, err)
-        errMsg := wski18n.T("Unable to create HTTP request for GET '{{.route}}': {{.err}}",
-            map[string]interface{}{"route": route, "err": err})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_NETWORK, DISPLAY_MSG,
-            NO_DISPLAY_USAGE)
-        return nil, nil, whiskErr
-    }
-
-    retApi := new(ApiGetResponse)
-    resp, err := s.client.Do(req, &retApi, ExitWithErrorOnTimeout)
-    if err != nil {
-        Debug(DbgError, "s.client.Do() error - HTTP req %s; error '%s'\n", req.URL.String(), err)
-        return nil, resp, err
-    }
-
-    return retApi, resp, nil
-}
-
-func (s *ApiService) Delete(api *ApiDeleteRequest, options *ApiDeleteRequestOptions) (*http.Response, error) {
-    route := "web/whisk.system/routemgmt/deleteApi.http"
-    Debug(DbgInfo, "Api DELETE route: %s\n", route)
-
-    routeUrl, err := addRouteOptions(route, options)
-    if err != nil {
-        Debug(DbgError, "addRouteOptions(%s, %#v) error: '%s'\n", route, options, err)
-        errMsg := wski18n.T("Unable to add route options '{{.options}}'",
-            map[string]interface{}{"options": options})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_GENERAL, DISPLAY_MSG,
-            NO_DISPLAY_USAGE)
-        return nil, whiskErr
-    }
-    Debug(DbgError, "Api DELETE route with options: %s\n", routeUrl)
-
-    req, err := s.client.NewRequestUrl("DELETE", routeUrl, nil, DoNotIncludeNamespaceInUrl, AppendOpenWhiskPathPrefix, EncodeBodyAsJson, AuthRequired)
-    if err != nil {
-        Debug(DbgError, "http.NewRequestUrl(DELETE, %s, nil, DoNotIncludeNamespaceInUrl, AppendOpenWhiskPathPrefix, EncodeBodyAsJson, AuthRequired) error: '%s'\n", route, err)
-        errMsg := wski18n.T("Unable to create HTTP request for DELETE '{{.route}}': {{.err}}",
-            map[string]interface{}{"route": route, "err": err})
-        whiskErr := MakeWskErrorFromWskError(errors.New(errMsg), err, EXITCODE_ERR_NETWORK, DISPLAY_MSG,
-            NO_DISPLAY_USAGE)
-        return nil, whiskErr
-    }
-
-    retApi := new(ApiDeleteResponse)
-    resp, err := s.client.Do(req, &retApi, ExitWithErrorOnTimeout)
-    if err != nil {
-        Debug(DbgError, "s.client.Do() error - HTTP req %s; error '%s'\n", req.URL.String(), err)
-        return resp, err
-    }
-
-    return nil, nil
-}
-
-/////////////
-// V2 Cmds //
-/////////////
-func (s *ApiService) ListV2(apiListOptions *ApiListRequestOptions) (*ApiListResponseV2, *http.Response, error) {
     route := "web/whisk.system/apimgmt/getApi.http"
 
     routeUrl, err := addRouteOptions(route, apiListOptions)
@@ -370,7 +186,7 @@ func (s *ApiService) ListV2(apiListOptions *ApiListRequestOptions) (*ApiListResp
         return nil, nil, whiskErr
     }
 
-    apiArray := new(ApiListResponseV2)
+    apiArray := new(ApiListResponse)
     resp, err := s.client.Do(req, &apiArray, ExitWithErrorOnTimeout)
     if err != nil {
         Debug(DbgError, "s.client.Do() error - HTTP req %s; error '%s'\n", req.URL.String(), err)
@@ -386,7 +202,7 @@ func (s *ApiService) ListV2(apiListOptions *ApiListRequestOptions) (*ApiListResp
     return apiArray, resp, err
 }
 
-func (s *ApiService) InsertV2(api *ApiCreateRequest, options *ApiCreateRequestOptions, overwrite bool) (*ApiCreateResponseV2, *http.Response, error) {
+func (s *ApiService) Insert(api *ApiCreateRequest, options *ApiCreateRequestOptions, overwrite bool) (*ApiCreateResponse, *http.Response, error) {
     route := "web/whisk.system/apimgmt/createApi.http"
     Debug(DbgInfo, "Api PUT route: %s\n", route)
 
@@ -411,7 +227,7 @@ func (s *ApiService) InsertV2(api *ApiCreateRequest, options *ApiCreateRequestOp
         return nil, nil, whiskErr
     }
 
-    retApi := new(ApiCreateResponseV2)
+    retApi := new(ApiCreateResponse)
     resp, err := s.client.Do(req, &retApi, ExitWithErrorOnTimeout)
     if err != nil {
         Debug(DbgError, "s.client.Do() error - HTTP req %s; error '%s'\n", req.URL.String(), err)
@@ -427,7 +243,7 @@ func (s *ApiService) InsertV2(api *ApiCreateRequest, options *ApiCreateRequestOp
     return retApi, resp, nil
 }
 
-func (s *ApiService) GetV2(api *ApiGetRequest, options *ApiGetRequestOptions) (*ApiGetResponseV2, *http.Response, error) {
+func (s *ApiService) Get(api *ApiGetRequest, options *ApiGetRequestOptions) (*ApiGetResponse, *http.Response, error) {
     route := "web/whisk.system/apimgmt/getApi.http"
     Debug(DbgInfo, "Api GET route: %s\n", route)
 
@@ -452,7 +268,7 @@ func (s *ApiService) GetV2(api *ApiGetRequest, options *ApiGetRequestOptions) (*
         return nil, nil, whiskErr
     }
 
-    retApi := new(ApiGetResponseV2)
+    retApi := new(ApiGetResponse)
     resp, err := s.client.Do(req, &retApi, ExitWithErrorOnTimeout)
     if err != nil {
         Debug(DbgError, "s.client.Do() error - HTTP req %s; error '%s'\n", req.URL.String(), err)
@@ -462,7 +278,7 @@ func (s *ApiService) GetV2(api *ApiGetRequest, options *ApiGetRequestOptions) (*
     return retApi, resp, nil
 }
 
-func (s *ApiService) DeleteV2(api *ApiDeleteRequest, options *ApiDeleteRequestOptions) (*http.Response, error) {
+func (s *ApiService) Delete(api *ApiDeleteRequest, options *ApiDeleteRequestOptions) (*http.Response, error) {
     route := "web/whisk.system/apimgmt/deleteApi.http"
     Debug(DbgInfo, "Api DELETE route: %s\n", route)
 
@@ -498,7 +314,7 @@ func (s *ApiService) DeleteV2(api *ApiDeleteRequest, options *ApiDeleteRequestOp
 }
 
 
-func validateApiListResponse(apiList *ApiListResponseV2) error {
+func validateApiListResponse(apiList *ApiListResponse) error {
     for i:=0; i<len(apiList.Apis); i++ {
         if apiList.Apis[i].ApiValue == nil {
             Debug(DbgError, "validateApiResponse: No value stanza in api %v\n", apiList.Apis[i])
@@ -515,7 +331,7 @@ func validateApiListResponse(apiList *ApiListResponseV2) error {
     return nil
 }
 
-func validateApiSwaggerResponse(swagger *ApiSwaggerV2) error {
+func validateApiSwaggerResponse(swagger *ApiSwagger) error {
     if swagger == nil {
         Debug(DbgError, "validateApiSwaggerResponse: No apidoc stanza in api\n")
         errMsg := wski18n.T("Internal error. Missing apidoc stanza in API configuration")
@@ -533,7 +349,7 @@ func validateApiSwaggerResponse(swagger *ApiSwaggerV2) error {
     return nil
 }
 
-func validateApiPath(path map[string]*ApiSwaggerOperationV2) error {
+func validateApiPath(path map[string]*ApiSwaggerOperation) error {
     for op, opv := range path {
         err := validateApiOperation(op, opv)
         if err != nil {
@@ -544,7 +360,7 @@ func validateApiPath(path map[string]*ApiSwaggerOperationV2) error {
     return nil
 }
 
-func validateApiOperation(opName string, op *ApiSwaggerOperationV2) error {
+func validateApiOperation(opName string, op *ApiSwaggerOperation) error {
     if (op.XOpenWhisk != nil && len(op.OperationId) == 0) {
         Debug(DbgError, "validateApiOperation: No operationId field in operation %v\n", op)
         errMsg := wski18n.T("Missing operationId field in API configuration for operation {{.op}}",

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

[incubator-openwhisk-client-go] 01/03: Limit length of HTTP body displayed when debugging. (#2491)

Posted by cs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-client-go.git

commit fdbb033f91cb048b6bd3cbb5095ea2e3c90d9c34
Author: Benjamin Poole <Be...@ibm.com>
AuthorDate: Fri Aug 4 10:34:44 2017 -0400

    Limit length of HTTP body displayed when debugging. (#2491)
    
    * Limited http req body in debug
    * Added error checking
    * Removed largeFile, added asset-cleaner, removed --debug from create and refined code
    * Removed temp file creation
    * Now only limits HTTP Req/Resp Body with flag --verbose
    * Now uses json to parse and find code field
    * Update based test location, JSON parsing and comments
---
 whisk/client.go | 52 ++++++++++++++++++++++++++++++++++++++++++++++++----
 whisk/trace.go  |  5 +++--
 2 files changed, 51 insertions(+), 6 deletions(-)

diff --git a/whisk/client.go b/whisk/client.go
index 10acb80..d3c3670 100644
--- a/whisk/client.go
+++ b/whisk/client.go
@@ -223,6 +223,29 @@ func (c *Client) addAuthHeader(req *http.Request, authRequired bool) error {
     return nil
 }
 
+// bodyTruncator limits the size of Req/Resp Body for --verbose ONLY.
+// It returns truncated Req/Resp Body, reloaded io.ReadCloser and any errors.
+func bodyTruncator(body io.ReadCloser) (string, io.ReadCloser, error) {
+    limit := 1000    // 1000 byte limit, anything over is truncated
+
+    data, err := ioutil.ReadAll(body)
+    if err != nil {
+        Verbose("ioutil.ReadAll(req.Body) error: %s\n", err)
+        werr := MakeWskError(err, EXITCODE_ERR_NETWORK, DISPLAY_MSG, NO_DISPLAY_USAGE)
+        return "", body, werr
+    }
+
+    reload := ioutil.NopCloser(bytes.NewBuffer(data))
+
+    if len(data) > limit {
+        Verbose("Body exceeds %d bytes and will be truncated\n", limit)
+        newData := string(data)[:limit] + "..."
+        return string(newData), reload, nil
+    }
+
+    return string(data), reload, nil
+}
+
 // Do sends an API request and returns the API response.  The API response is
 // JSON decoded and stored in the value pointed to by v, or returned as an
 // error if an API error has occurred.  If v implements the io.Writer
@@ -230,17 +253,27 @@ func (c *Client) addAuthHeader(req *http.Request, authRequired bool) error {
 // first decode it.
 func (c *Client) Do(req *http.Request, v interface{}, ExitWithErrorOnTimeout bool) (*http.Response, error) {
     var err error
+    var truncatedBody string
 
     if IsVerbose() {
         fmt.Println("REQUEST:")
         fmt.Printf("[%s]\t%s\n", req.Method, req.URL)
+
         if len(req.Header) > 0 {
             fmt.Println("Req Headers")
             PrintJSON(req.Header)
         }
+
         if req.Body != nil {
             fmt.Println("Req Body")
-            fmt.Println(req.Body)
+            if !IsDebug() {
+                if truncatedBody, req.Body, err = bodyTruncator(req.Body); err != nil {
+                    return nil, err
+                }
+                fmt.Println(truncatedBody)
+            } else {
+                fmt.Println(req.Body)
+            }
             Debug(DbgInfo, "Req Body (ASCII quoted string):\n%+q\n", req.Body)
         }
     }
@@ -252,10 +285,12 @@ func (c *Client) Do(req *http.Request, v interface{}, ExitWithErrorOnTimeout boo
         werr := MakeWskError(err, EXITCODE_ERR_NETWORK, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return nil, werr
     }
+
     // Don't "defer resp.Body.Close()" here because the body is reloaded to allow caller to
     // do custom body parsing, such as handling per-route error responses.
     Verbose("RESPONSE:")
     Verbose("Got response with code %d\n", resp.StatusCode)
+
     if (IsVerbose() && len(resp.Header) > 0) {
         fmt.Println("Resp Headers")
         PrintJSON(resp.Header)
@@ -268,14 +303,23 @@ func (c *Client) Do(req *http.Request, v interface{}, ExitWithErrorOnTimeout boo
         werr := MakeWskError(err, EXITCODE_ERR_NETWORK, DISPLAY_MSG, NO_DISPLAY_USAGE)
         return resp, werr
     }
-    Verbose("Response body size is %d bytes\n", len(data))
-    Verbose("Response body received:\n%s\n", string(data))
-    Debug(DbgInfo, "Response body received (ASCII quoted string):\n%+q\n", string(data))
 
     // Reload the response body to allow caller access to the body; otherwise,
     // the caller will have any empty body to read
     resp.Body = ioutil.NopCloser(bytes.NewBuffer(data))
 
+    Verbose("Response body size is %d bytes\n", len(data))
+
+    if !IsDebug() {
+        if truncatedBody, resp.Body, err = bodyTruncator(resp.Body); err != nil {
+            return nil, err
+        }
+        Verbose("Response body received:\n%s\n", truncatedBody)
+    } else {
+        Verbose("Response body received:\n%s\n", string(data))
+        Debug(DbgInfo, "Response body received (ASCII quoted string):\n%+q\n", string(data))
+    }
+
     // With the HTTP response status code and the HTTP body contents,
     // the possible response scenarios are:
     //
diff --git a/whisk/trace.go b/whisk/trace.go
index 16b4523..26f7c80 100644
--- a/whisk/trace.go
+++ b/whisk/trace.go
@@ -54,6 +54,9 @@ func SetVerbose (b bool) {
 func IsVerbose() bool {
     return isVerbose || isDebug
 }
+func IsDebug() bool {
+    return isDebug
+}
 
 /* Function for tracing debug level messages to stdout
    Output format:
@@ -90,5 +93,3 @@ func Verbose(msgFormat string, args ...interface{}) {
         fmt.Printf("%v", msg)
     }
 }
-
-

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