Skip to content

Commit

Permalink
fix: switch slack lib and stop using deprecated APIs. Fixes #726 (#777)
Browse files Browse the repository at this point in the history
  • Loading branch information
whynowy authored Jul 29, 2020
1 parent c57bdb6 commit 527a45f
Show file tree
Hide file tree
Showing 21 changed files with 295 additions and 352 deletions.
4 changes: 0 additions & 4 deletions api/openapi-spec/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions api/sensor.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 0 additions & 23 deletions api/sensor.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions eventsources/common/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ func activateRoute(router Router, controller *Controller) {
}

// manageRouteChannels consumes data from route's data channel and stops the processing when the event source is stopped/removed
func manageRouteChannels(router Router, dispatcher func([]byte) error) {
func manageRouteChannels(router Router, dispatch func([]byte) error) {
route := router.GetRoute()
logger := route.Logger.Desugar()
for {
select {
case data := <-route.DataCh:
logger.Info("new event received, dispatching to gateway client")
err := dispatcher(data)
logger.Info("new event received, dispatching it...")
err := dispatch(data)
if err != nil {
logger.Error("failed to send event", zap.Error(err))
continue
Expand All @@ -148,7 +148,7 @@ func manageRouteChannels(router Router, dispatcher func([]byte) error) {
}

// ManagerRoute manages the lifecycle of a route
func ManageRoute(ctx context.Context, router Router, controller *Controller, dispatcher func([]byte) error) error {
func ManageRoute(ctx context.Context, router Router, controller *Controller, dispatch func([]byte) error) error {
route := router.GetRoute()

logger := route.Logger.Desugar()
Expand All @@ -167,7 +167,7 @@ func ManageRoute(ctx context.Context, router Router, controller *Controller, dis
}

logger.Info("listening to payloads for the route...")
go manageRouteChannels(router, dispatcher)
go manageRouteChannels(router, dispatch)

defer func() {
route.StopChan <- struct{}{}
Expand Down
2 changes: 1 addition & 1 deletion eventsources/sources/nsq/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (h *messageHandler) HandleMessage(m *nsq.Message) error {

eventBody, err := json.Marshal(eventData)
if err != nil {
h.logger.Error("failed to marshal the event data. rejecting the event...", zap.Error(err))
h.logger.Desugar().Error("failed to marshal the event data. rejecting the event...", zap.Error(err))
return err
}

Expand Down
1 change: 1 addition & 0 deletions eventsources/sources/nsq/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package nsq

import (
Expand Down
6 changes: 3 additions & 3 deletions eventsources/sources/slack/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import (
"io/ioutil"
"net/http"

"github.com/nlopes/slack"
"github.com/nlopes/slack/slackevents"
"github.com/pkg/errors"
"github.com/slack-go/slack"
"github.com/slack-go/slack/slackevents"
"go.uber.org/zap"

"github.com/argoproj/argo-events/common"
Expand Down Expand Up @@ -154,7 +154,7 @@ func (rc *Router) HandleRoute(writer http.ResponseWriter, request *http.Request)
route.DataCh <- data
}

logger.Info("request successfully processed")
logger.Debug("request successfully processed")
common.SendSuccessResponse(writer, "success")
}

Expand Down
2 changes: 1 addition & 1 deletion eventsources/sources/slack/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"time"

"github.com/ghodss/yaml"
"github.com/nlopes/slack/slackevents"
"github.com/slack-go/slack/slackevents"
"github.com/smartystreets/goconvey/convey"

"github.com/argoproj/argo-events/eventsources/common/webhook"
Expand Down
1 change: 0 additions & 1 deletion examples/sensors/slack-trigger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ spec:
slackToken:
key: token
name: slack-secret
namespace: argo-events
parameters:
- src:
dependencyName: test-dep
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ require (
github.com/googleapis/gnostic v0.4.0 // indirect
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect
github.com/gorilla/mux v1.7.3
github.com/gorilla/websocket v1.4.2 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.9.5
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hokaccha/go-prettyjson v0.0.0-20190818114111-108c894c2c0e // indirect
Expand All @@ -61,7 +60,6 @@ require (
github.com/nats-io/nkeys v0.1.4 // indirect
github.com/nats-io/stan.go v0.6.0
github.com/nicksnyder/go-i18n v1.10.1-0.20190510212457-b280125b035a // indirect
github.com/nlopes/slack v0.6.1-0.20200219171353-c05e07b0a5de
github.com/nsqio/go-nsq v1.0.8
github.com/pelletier/go-toml v1.7.0 // indirect
github.com/pierrec/lz4 v2.5.0+incompatible // indirect
Expand All @@ -72,6 +70,7 @@ require (
github.com/robfig/cron v1.2.0
github.com/sergi/go-diff v1.1.0 // indirect
github.com/sirupsen/logrus v1.6.0 // indirect
github.com/slack-go/slack v0.6.5
github.com/smartystreets/assertions v0.0.0-20190401211740-f487f9de1cd3 // indirect
github.com/smartystreets/goconvey v1.6.4
github.com/spf13/jwalterweatherman v1.1.0 // indirect
Expand Down
7 changes: 4 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4Hmx
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-test/deep v1.0.4 h1:u2CU3YKy9I2pmu9pX0eq50wCgjfGIt539SqR7FbHiho=
github.com/go-test/deep v1.0.4/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
github.com/gobuffalo/flect v0.2.0 h1:EWCvMGGxOjsgwlWaP+f4+Hh6yrrte7JeFL2S6b+0hdM=
github.com/gobuffalo/flect v0.2.0/go.mod h1:W3K3X9ksuZfir8f/LrfVtWmCDQFfayuylOJ7sz/Fj80=
github.com/gobwas/glob v0.2.4-0.20181002190808-e7a84e9525fe h1:zn8tqiUbec4wR94o7Qj3LZCAT6uGobhEgnDRg6isG5U=
Expand Down Expand Up @@ -324,7 +326,6 @@ github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51
github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
Expand Down Expand Up @@ -497,8 +498,6 @@ github.com/nicksnyder/go-i18n v1.10.1-0.20190510212457-b280125b035a h1:WsVgYECoT
github.com/nicksnyder/go-i18n v1.10.1-0.20190510212457-b280125b035a/go.mod h1:e4Di5xjP9oTVrC6y3C7C0HoSYXjSbhh/dU0eUV32nB4=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nlopes/slack v0.6.1-0.20200219171353-c05e07b0a5de h1:ri0yWD9OmI9MQfsv4qnS/WaqheJ5z7pM36M+TW7xLcs=
github.com/nlopes/slack v0.6.1-0.20200219171353-c05e07b0a5de/go.mod h1:JzQ9m3PMAqcpeCam7UaHSuBuupz7CmpjehYMayT6YOk=
github.com/nsqio/go-nsq v1.0.8 h1:3L2F8tNLlwXXlp2slDUrUWSBn2O3nMh8R1/KEDFTHPk=
github.com/nsqio/go-nsq v1.0.8/go.mod h1:vKq36oyeVXgsS5Q8YEO7WghqidAVXQlcFxzQbQTuDEY=
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
Expand Down Expand Up @@ -578,6 +577,8 @@ github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMB
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/slack-go/slack v0.6.5 h1:IkDKtJ2IROJNoe3d6mW870/NRKvq2fhLB/Q5XmzWk00=
github.com/slack-go/slack v0.6.5/go.mod h1:FGqNzJBmxIsZURAxh2a8D21AnOVvvXZvGligs4npPUM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/assertions v0.0.0-20190401211740-f487f9de1cd3 h1:hBSHahWMEgzwRyS6dRpxY0XyjZsHyQ61s084wo5PJe0=
Expand Down
4 changes: 4 additions & 0 deletions manifests/cluster-install/rbac/argo-events-cluster-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ rules:
- workflows/finalizers
- workflowtemplates
- workflowtemplates/finalizers
- cronworkflows
- cronworkflows/finalizers
- clusterworkflowtemplates
- clusterworkflowtemplates/finalizers
- sensors
- sensors/finalizers
- eventsources
Expand Down
4 changes: 4 additions & 0 deletions manifests/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ rules:
- workflows/finalizers
- workflowtemplates
- workflowtemplates/finalizers
- cronworkflows
- cronworkflows/finalizers
- clusterworkflowtemplates
- clusterworkflowtemplates/finalizers
- sensors
- sensors/finalizers
- eventsources
Expand Down
4 changes: 4 additions & 0 deletions manifests/namespace-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ rules:
- workflows/finalizers
- workflowtemplates
- workflowtemplates/finalizers
- cronworkflows
- cronworkflows/finalizers
- clusterworkflowtemplates
- clusterworkflowtemplates/finalizers
- sensors
- sensors/finalizers
- eventsources
Expand Down
4 changes: 4 additions & 0 deletions manifests/namespace-install/rbac/argo-events-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ rules:
- workflows/finalizers
- workflowtemplates
- workflowtemplates/finalizers
- cronworkflows
- cronworkflows/finalizers
- clusterworkflowtemplates
- clusterworkflowtemplates/finalizers
- sensors
- sensors/finalizers
- eventsources
Expand Down
Loading

0 comments on commit 527a45f

Please sign in to comment.