Browse Source

Make "original" field exported

master
Matei-Alexandru Gardus 8 months ago
parent
commit
dcd05d01dd
No known key found for this signature in database
2 changed files with 9 additions and 9 deletions
  1. 8
    8
      hooks/hooks.go
  2. 1
    1
      server/routes.go

+ 8
- 8
hooks/hooks.go View File

@@ -26,7 +26,7 @@ type PushEventWebhook struct {
26 26
 	pusher   string
27 27
 	commits  []Commit
28 28
 	URL      *url.URL
29
-	original originalWebhook
29
+	Original originalWebhook
30 30
 }
31 31
 
32 32
 // Parse reads the original webhook and parses it, in order to fill all the necessary fields
@@ -37,13 +37,13 @@ func (w PushEventWebhook) Parse() error {
37 37
 	var err error
38 38
 
39 39
 	// get normal entries
40
-	w.repo, err = jsonparser.GetString(w.original, "repository", "full_name")
40
+	w.repo, err = jsonparser.GetString(w.Original, "repository", "full_name")
41 41
 	if err != nil {
42 42
 		w.repo = ""
43 43
 		return err
44 44
 	}
45 45
 
46
-	ref, err := jsonparser.GetString(w.original, "ref")
46
+	ref, err := jsonparser.GetString(w.Original, "ref")
47 47
 	if err != nil {
48 48
 		w.branch = ""
49 49
 		return err
@@ -53,13 +53,13 @@ func (w PushEventWebhook) Parse() error {
53 53
 
54 54
 	w.branch = refSplit[2]
55 55
 
56
-	w.pusher, err = jsonparser.GetString(w.original, "pusher", "name")
56
+	w.pusher, err = jsonparser.GetString(w.Original, "pusher", "name")
57 57
 	if err != nil {
58 58
 		w.pusher = ""
59 59
 		return err
60 60
 	}
61 61
 
62
-	URLString, err := jsonparser.GetString(w.original, "compare")
62
+	URLString, err := jsonparser.GetString(w.Original, "compare")
63 63
 	if err != nil {
64 64
 		return err
65 65
 	}
@@ -70,7 +70,7 @@ func (w PushEventWebhook) Parse() error {
70 70
 	}
71 71
 
72 72
 	// iterate through commits object array from original webhook
73
-	_, err = jsonparser.ArrayEach(w.original, func(value []byte, dataType jsonparser.ValueType, offset int, err1 error) {
73
+	_, err = jsonparser.ArrayEach(w.Original, func(value []byte, dataType jsonparser.ValueType, offset int, err1 error) {
74 74
 		// these never fail, webhook object contains these, according to GitHub API documentation
75 75
 		id, _ := jsonparser.GetString(value, "id")
76 76
 		committer, _ := jsonparser.GetString(value, "author", "username")
@@ -142,7 +142,7 @@ type IssueEventWebhook struct {
142 142
 	action   string
143 143
 	issue    Issue
144 144
 	URL      *url.URL
145
-	original originalWebhook
145
+	Original originalWebhook
146 146
 }
147 147
 
148 148
 // PullRequestEventWebhook is a specialized struct of Webhook that holds all pull request event information inside other specialized fields
@@ -150,7 +150,7 @@ type PullRequestEventWebhook struct {
150 150
 	action      string
151 151
 	pullRequest PullRequest
152 152
 	URL         *url.URL
153
-	original    originalWebhook
153
+	Original    originalWebhook
154 154
 }
155 155
 
156 156
 // Webhook is a struct that holds a generic received webhook

+ 1
- 1
server/routes.go View File

@@ -52,7 +52,7 @@ func (s *server) handleGitHubHook() http.HandlerFunc {
52 52
 		switch eventType {
53 53
 		case "push":
54 54
 			webhook := hooks.PushEventWebhook{
55
-				original: body,
55
+				Original: body,
56 56
 			}
57 57
 			err = webhook.Parse()
58 58
 			if err != nil {

Loading…
Cancel
Save