Skip to content

Commit 69b0949

Browse files
committed
Refactoring and new plugin lib
This commit is doing a general refactoring of the current code base and it also integrates the new plugin lib.
1 parent e14fb4b commit 69b0949

File tree

9 files changed

+339
-257
lines changed

9 files changed

+339
-257
lines changed

.drone.starlark

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,34 @@ def testing():
4545
}
4646
]
4747
},
48+
{
49+
'name': 'lint',
50+
'image': 'golang:1.12',
51+
'pull': 'always',
52+
'commands': [
53+
'go run golang.org/x/lint/golint -set_exit_status ./...'
54+
],
55+
'volumes': [
56+
{
57+
'name': 'gopath',
58+
'path': '/go'
59+
}
60+
]
61+
},
62+
{
63+
'name': 'staticcheck',
64+
'image': 'golang:1.12',
65+
'pull': 'always',
66+
'commands': [
67+
'go run honnef.co/go/tools/cmd/staticcheck ./...'
68+
],
69+
'volumes': [
70+
{
71+
'name': 'gopath',
72+
'path': '/go'
73+
}
74+
]
75+
},
4876
{
4977
'name': 'test',
5078
'image': 'golang:1.12',

.drone.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
{"kind": "pipeline", "type": "docker", "name": "testing", "platform": {"os": "linux", "arch": "amd64"}, "steps": [{"name": "vet", "image": "golang:1.12", "pull": "always", "commands": ["go vet ./..."], "volumes": [{"name": "gopath", "path": "/go"}]}, {"name": "test", "image": "golang:1.12", "pull": "always", "commands": ["go test -cover ./..."], "volumes": [{"name": "gopath", "path": "/go"}]}], "volumes": [{"name": "gopath", "temp": {}}], "trigger": {"ref": ["refs/heads/master", "refs/tags/**", "refs/pull/**"]}}
2+
{"kind": "pipeline", "type": "docker", "name": "testing", "platform": {"os": "linux", "arch": "amd64"}, "steps": [{"name": "vet", "image": "golang:1.12", "pull": "always", "commands": ["go vet ./..."], "volumes": [{"name": "gopath", "path": "/go"}]}, {"name": "lint", "image": "golang:1.12", "pull": "always", "commands": ["go run golang.org/x/lint/golint -set_exit_status ./..."], "volumes": [{"name": "gopath", "path": "/go"}]}, {"name": "staticcheck", "image": "golang:1.12", "pull": "always", "commands": ["go run honnef.co/go/tools/cmd/staticcheck ./..."], "volumes": [{"name": "gopath", "path": "/go"}]}, {"name": "test", "image": "golang:1.12", "pull": "always", "commands": ["go test -cover ./..."], "volumes": [{"name": "gopath", "path": "/go"}]}], "volumes": [{"name": "gopath", "temp": {}}], "trigger": {"ref": ["refs/heads/master", "refs/tags/**", "refs/pull/**"]}}
33
---
44
{"kind": "pipeline", "type": "docker", "name": "linux-amd64", "platform": {"os": "linux", "arch": "amd64"}, "steps": [{"name": "build-push", "image": "golang:1.12", "pull": "always", "environment": {"CGO_ENABLED": "0"}, "commands": ["go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/amd64/drone-webhook"], "when": {"event": {"exclude": ["tag"]}}}, {"name": "build-tag", "image": "golang:1.12", "pull": "always", "environment": {"CGO_ENABLED": "0"}, "commands": ["go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/amd64/drone-webhook"], "when": {"event": ["tag"]}}, {"name": "executable", "image": "golang:1.12", "pull": "always", "commands": ["./release/linux/amd64/drone-webhook --help"]}, {"name": "dryrun", "image": "plugins/docker", "pull": "always", "settings": {"dry_run": true, "tags": "linux-amd64", "dockerfile": "docker/Dockerfile.linux.amd64", "repo": "plugins/webhook", "username": {"from_secret": "docker_username"}, "password": {"from_secret": "docker_password"}}, "when": {"event": ["pull_request"]}}, {"name": "publish", "image": "plugins/docker", "pull": "always", "settings": {"auto_tag": true, "auto_tag_suffix": "linux-amd64", "dockerfile": "docker/Dockerfile.linux.amd64", "repo": "plugins/webhook", "username": {"from_secret": "docker_username"}, "password": {"from_secret": "docker_password"}}, "when": {"event": {"exclude": ["pull_request"]}}}], "depends_on": ["testing"], "trigger": {"ref": ["refs/heads/master", "refs/tags/**", "refs/pull/**"]}}
55
---

defaults.go

Lines changed: 0 additions & 16 deletions
This file was deleted.

go.mod

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ module github.com/drone-plugins/drone-webhook
33
require (
44
bou.ke/monkey v1.0.1 // indirect
55
github.com/aymerick/raymond v2.0.2+incompatible // indirect
6+
github.com/drone-plugins/drone-plugin-lib v0.0.0-20190916204527-6b33d765aca4
67
github.com/drone/drone-template-lib v0.0.0-20181004051823-4019baa6c594
8+
github.com/jackspirou/syscerts v0.0.0-20160531025014-b68f5469dff1
79
github.com/pkg/errors v0.8.1 // indirect
10+
github.com/sirupsen/logrus v1.4.2
811
github.com/stretchr/testify v1.3.0 // indirect
912
github.com/tkuchiki/faketime v0.1.1 // indirect
10-
github.com/urfave/cli v1.20.0
11-
gopkg.in/yaml.v2 v2.2.2 // indirect
13+
github.com/urfave/cli v1.21.0
14+
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac // indirect
15+
honnef.co/go/tools v0.0.1-2019.2.3 // indirect
1216
)

go.sum

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,64 @@
11
bou.ke/monkey v1.0.1 h1:zEMLInw9xvNakzUUPjfS4Ds6jYPqCFx3m7bRmG5NH2U=
22
bou.ke/monkey v1.0.1/go.mod h1:FgHuK96Rv2Nlf+0u1OOVDpCMdsWyOFmeeketDHE7LIg=
3+
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
4+
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
35
github.com/aymerick/raymond v2.0.2+incompatible h1:VEp3GpgdAnv9B2GFyTvqgcKvY+mfKMjPOA3SbKLtnU0=
46
github.com/aymerick/raymond v2.0.2+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
57
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
68
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
9+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
10+
github.com/drone-plugins/drone-plugin-lib v0.0.0-20190905223702-0352df680f17 h1:x441B4/1FGRHg92xWAithZQUhsUysY+hZca3Wo6fuTQ=
11+
github.com/drone-plugins/drone-plugin-lib v0.0.0-20190916204527-6b33d765aca4 h1:CxEkk5WIstHlmg+locKHxTnJ/rzk08P3FE5W1hFCEBk=
12+
github.com/drone-plugins/drone-plugin-lib v0.0.0-20190916204527-6b33d765aca4/go.mod h1:Jd/3DVk8GYEuFXhOZ2UZ3D7iwoXIfZXdIQ1BaBpBBls=
713
github.com/drone/drone-template-lib v0.0.0-20181004051823-4019baa6c594 h1:zPRVfiHpXeGt1XGpK2TQcaj2lRydiGdVz1AoHkaC554=
814
github.com/drone/drone-template-lib v0.0.0-20181004051823-4019baa6c594/go.mod h1:u34woe41m58Whrf21iH6z/xLOIRM3650LhWAyUc7Oik=
15+
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
16+
github.com/jackspirou/syscerts v0.0.0-20160531025014-b68f5469dff1 h1:9Xm8CKtMZIXgcopfdWk/qZ1rt0HjMgfMR9nxxSeK6vk=
17+
github.com/jackspirou/syscerts v0.0.0-20160531025014-b68f5469dff1/go.mod h1:zuHl3Hh+e9P6gmBPvcqR1HjkaWHC/csgyskg6IaFKFo=
18+
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
19+
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
20+
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
21+
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
22+
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
923
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
1024
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
1125
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1226
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
27+
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
28+
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
29+
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
1330
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
31+
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
32+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
1433
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
1534
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
1635
github.com/tkuchiki/faketime v0.1.1 h1:UZjBlktFAi23wo+jWuHuNoHUpLnB0j/5B62bl5nCPls=
1736
github.com/tkuchiki/faketime v0.1.1/go.mod h1:RXY/TXAwGGL36IKDjrHFMcjpUrEiyWSEtLhFPw3UWF0=
1837
github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw=
1938
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
39+
github.com/urfave/cli v1.21.0 h1:wYSSj06510qPIzGSua9ZqsncMmWE3Zr55KBERygyrxE=
40+
github.com/urfave/cli v1.21.0/go.mod h1:lxDj6qX9Q6lWQxIrbrT0nwecwUtRnhVZAJjJZrVUZZQ=
41+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
42+
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
43+
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac h1:8R1esu+8QioDxo4E4mX6bFztO+dMTM49DNAaWfO5OeY=
44+
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
45+
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
46+
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
47+
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
48+
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
49+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
50+
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
51+
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
52+
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
53+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
54+
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
55+
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac h1:MQEvx39qSf8vyrx3XRaOe+j1UDIzKwkYOVObRgGPVqI=
56+
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
2057
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
2158
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
59+
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
60+
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
2261
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
2362
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
63+
honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=
64+
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=

helper.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package main
2+
3+
// intInSlice checks if int is in slice of ints
4+
func intInSlice(s []int, e int) bool {
5+
for _, a := range s {
6+
if a == e {
7+
return true
8+
}
9+
}
10+
11+
return false
12+
}

0 commit comments

Comments
 (0)