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

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


The following commit(s) were added to refs/heads/master by this push:
     new a81a9be  Adding support for annotations in Rules (#62)
a81a9be is described below

commit a81a9be21faae877e858c6ab9122a40419577f95
Author: Priti Desai <pde...@us.ibm.com>
AuthorDate: Mon Feb 12 11:50:32 2018 -0800

    Adding support for annotations in Rules (#62)
    
    * adding annotation to rules
    
    * deleting debugging messages
    
    * go fmt
---
 whisk/rule.go | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/whisk/rule.go b/whisk/rule.go
index 624d66c..c9b56a0 100644
--- a/whisk/rule.go
+++ b/whisk/rule.go
@@ -31,13 +31,14 @@ type RuleService struct {
 }
 
 type Rule struct {
-       Namespace string      `json:"namespace,omitempty"`
-       Name      string      `json:"name,omitempty"`
-       Version   string      `json:"version,omitempty"`
-       Status    string      `json:"status"`
-       Trigger   interface{} `json:"trigger"`
-       Action    interface{} `json:"action"`
-       Publish   *bool       `json:"publish,omitempty"`
+       Namespace   string      `json:"namespace,omitempty"`
+       Name        string      `json:"name,omitempty"`
+       Version     string      `json:"version,omitempty"`
+       Annotations KeyValueArr `json:"annotations,omitempty"`
+       Status      string      `json:"status"`
+       Trigger     interface{} `json:"trigger"`
+       Action      interface{} `json:"action"`
+       Publish     *bool       `json:"publish,omitempty"`
 }
 
 type RuleListOptions struct {
@@ -113,11 +114,20 @@ func (s *RuleService) Insert(rule *Rule, overwrite bool) 
(*Rule, *http.Response,
        ruleName := (&url.URL{Path: rule.Name}).String()
        route := fmt.Sprintf("rules/%s?overwrite=%t", ruleName, overwrite)
 
-       req, err := s.client.NewRequest("PUT", route, rule, 
IncludeNamespaceInUrl)
+       routeUrl, err := url.Parse(route)
        if err != nil {
-               Debug(DbgError, "http.NewRequest(PUT, %s); error: '%s'\n", 
route, err)
+               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), EXIT_CODE_ERR_GENERAL, 
DISPLAY_MSG, NO_DISPLAY_USAGE)
+               return nil, nil, werr
+       }
+
+       req, err := s.client.NewRequestUrl("PUT", routeUrl, rule, 
IncludeNamespaceInUrl, AppendOpenWhiskPathPrefix, EncodeBodyAsJson, 
AuthRequired)
+       if err != nil {
+               Debug(DbgError, "http.NewRequestUrl(PUT, %s, %+v, 
IncludeNamespaceInUrl, AppendOpenWhiskPathPrefix, EncodeBodyAsJson, 
AuthRequired); error: '%s'\n", routeUrl, rule, err)
                errStr := wski18n.T("Unable to create HTTP request for PUT 
'{{.route}}': {{.err}}",
-                       map[string]interface{}{"route": route, "err": err})
+                       map[string]interface{}{"route": routeUrl, "err": err})
                werr := MakeWskErrorFromWskError(errors.New(errStr), err, 
EXIT_CODE_ERR_GENERAL, DISPLAY_MSG, NO_DISPLAY_USAGE)
                return nil, nil, werr
        }

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

Reply via email to