Adding webhooks and webhook invocation to RB-Gateway

Review Request #9402 — Created Nov. 26, 2017 and discarded

Information

rb-gateway
master

Reviewers

Adding the ability to register and invoke webhooks to RB-Gateway will allow the service to notify a url of repository events. Currently this project involves adding code to rb-gateway for configuring and invoking webhooks and adding in a rb-gateway command to invoke webhooks and integrate into repository hook scripts. see https://www.notion.so/reviewboard/RB-Gateway-Webhooks-29b5037924d14aff83e2b53b86087a23 for more project details (this review request covers task 1 and 2).

Webhooks can now be registered into config.json. Functions to register webhooks into the config and saving of the config have been implemented but have not yet been hooked up into routes.go.

Webhooks can be invoked by calling a send-webhook command of rb-gateway while passing appropriate data. Currently only post-commit events are supported.

A sample hookscript for invoking rb-gateway webhooks for git repository post-commit events has been included.

Currently there are no automated tests for testing the new features but they are testable by running the sample git post-commit hookscript:
First, configure the config.json appropriately using the sample_config.json as a base. for the sample webhook Configuration url, you can use https://requestb.in/ as a receiving url. Try running rb-gateway to makesure config.json is parsed correctly.
Second, configure the sample hookscript: "sample_Git_post-commit_hookscript.sh". Make sure the repo name field and path to rb-gateway is correct and that the file is executable. You can test out the webhook invocation simply by running the script or installing it into your repository. It won't do anything if your repo has no commits yet. This testing method only works for git repos for now unless you modify the hookscript to be compatible with other scms.

Description From Last Updated

Payload is laid out in nice columns, but Commit and Webhook aren't. This might be because your text editor is …

RC rcreagha

The trailing whitespace should be removed from this line.

RC rcreagha
CL
RC
  1. I don't know Go, but everything looks pretty good from what I can tell. I just have a couple small stylistic issues.

  2. webhook.go (Diff revision 2)
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    Show all issues

    Payload is laid out in nice columns, but Commit and Webhook aren't. This might be because your text editor is set to use smaller tabs than reviewboard's diff viewer.

    It looks like the file git_repository.go avoids issues from different tab settings by using spaces instead.

  3. webhook.go (Diff revision 2)
     
     
    Show all issues

    The trailing whitespace should be removed from this line.

  4. 
      
CL
CL
CL
CL
CL
CL
CL
CL
david
Review request changed
Status:
Discarded