Skip to content

Commit f1f5db7

Browse files
committed
#53 removing logging, remove extraneous comments
1 parent a92dd93 commit f1f5db7

File tree

2 files changed

+3
-45
lines changed

2 files changed

+3
-45
lines changed

docker/docker.go

+3-41
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import (
1111
"io"
1212
"io/ioutil"
1313
"net/http"
14-
15-
log "github.com/Sirupsen/logrus"
1614
)
1715

1816
// parse errors
@@ -21,10 +19,10 @@ var (
2119
ErrParsingPayload = errors.New("error parsing payload")
2220
)
2321

24-
// Event defines a GitHub hook event type
22+
// Event defines a Docker hook event type
2523
type Event string
2624

27-
// GitHub hook types
25+
// Docker hook types (only one for now)
2826
const (
2927
BuildEvent Event = "build"
3028
)
@@ -58,40 +56,14 @@ type BuildPayload struct {
5856
} `json:"repository"`
5957
}
6058

61-
// there are no options for docker webhooks
62-
// however I'm leaving this here for now in anticipation of future support for Docker Trusted Registry
63-
64-
// // Option is a configuration option for the webhook
65-
// type Option func(*Webhook) error
66-
67-
// // Options is a namespace var for configuration options
68-
// var Options = WebhookOptions{}
69-
70-
// // WebhookOptions is a namespace for configuration option methods
71-
// type WebhookOptions struct{}
72-
73-
// // Secret registers the GitHub secret
74-
// func (WebhookOptions) Secret(secret string) Option {
75-
// return func(hook *Webhook) error {
76-
// hook.secret = secret
77-
// return nil
78-
// }
79-
// }
80-
8159
// Webhook instance contains all methods needed to process events
8260
type Webhook struct {
8361
secret string
8462
}
8563

86-
// New creates and returns a WebHook instance denoted by the Provider type
64+
// New creates and returns a WebHook instance
8765
func New() (*Webhook, error) {
88-
// func New(options ...Option) (*Webhook, error) {
8966
hook := new(Webhook)
90-
// for _, opt := range options {
91-
// if err := opt(hook); err != nil {
92-
// return nil, errors.New("Error applying Option")
93-
// }
94-
// }
9567
return hook, nil
9668
}
9769

@@ -106,24 +78,14 @@ func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error)
10678
return nil, ErrInvalidHTTPMethod
10779
}
10880

109-
// event := r.Header.Get("X-GitHub-Event")
110-
// if event == "" {
111-
// return nil, ErrMissingGithubEventHeader
112-
// }
113-
// gitHubEvent := Event(event)
114-
11581
payload, err := ioutil.ReadAll(r.Body)
11682
if err != nil || len(payload) == 0 {
117-
log.Error(ErrParsingPayload)
118-
log.Error(err)
11983
return nil, ErrParsingPayload
12084
}
12185

12286
var pl BuildPayload
12387
err = json.Unmarshal([]byte(payload), &pl)
12488
if err != nil {
125-
log.Error(ErrParsingPayload)
126-
log.Error(err)
12789
return nil, ErrParsingPayload
12890
}
12991
return pl, err

docker/docker_test.go

-4
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ func TestWebhooks(t *testing.T) {
6161
event: BuildEvent,
6262
typ: BuildPayload{},
6363
filename: "../testdata/docker/docker_hub_build_notice.json",
64-
headers: http.Header{
65-
"X-Github-Event": []string{"commit_comment"},
66-
},
6764
},
6865
}
6966

@@ -86,7 +83,6 @@ func TestWebhooks(t *testing.T) {
8683
defer server.Close()
8784
req, err := http.NewRequest(http.MethodPost, server.URL+path, payload)
8885
assert.NoError(err)
89-
req.Header = tc.headers
9086
req.Header.Set("Content-Type", "application/json")
9187

9288
resp, err := client.Do(req)

0 commit comments

Comments
 (0)