You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/02/12 19:50:36 UTC

[GitHub] houshengbo closed pull request #62: Adding support for annotations in Rules

houshengbo closed pull request #62: Adding support for annotations in Rules
URL: https://github.com/apache/incubator-openwhisk-client-go/pull/62
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/whisk/rule.go b/whisk/rule.go
index 624d66ca..c9b56a09 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
 	}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services