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 <jwdu...@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" <commits@openwhisk.apache.org>.