Skip to content

Commit

Permalink
feat(kafka-trigger): added kafka trigger tests (#533)
Browse files Browse the repository at this point in the history
  • Loading branch information
VaibhavPage authored Mar 10, 2020
1 parent f808d96 commit 0d41182
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 15 additions & 1 deletion gateways/server/gitlab/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package gitlab

import (
"encoding/json"
"io/ioutil"
"net/http"
"reflect"
Expand All @@ -25,6 +26,7 @@ import (
"github.com/argoproj/argo-events/gateways"
"github.com/argoproj/argo-events/gateways/server"
"github.com/argoproj/argo-events/gateways/server/common/webhook"
"github.com/argoproj/argo-events/pkg/apis/events"
"github.com/argoproj/argo-events/pkg/apis/eventsources/v1alpha1"
"github.com/argoproj/argo-events/store"
"github.com/ghodss/yaml"
Expand Down Expand Up @@ -91,8 +93,20 @@ func (router *Router) HandleRoute(writer http.ResponseWriter, request *http.Requ
return
}

event := &events.GitLabEventData{
Headers: request.Header,
Body: (*json.RawMessage)(&body),
}

eventBody, err := json.Marshal(event)
if err != nil {
logger.Info("failed to marshal event")
common.SendErrorResponse(writer, "invalid event")
return
}

logger.Infoln("dispatching event on route's data channel")
route.DataCh <- body
route.DataCh <- eventBody

logger.Info("request successfully processed")
common.SendSuccessResponse(writer, "success")
Expand Down
4 changes: 3 additions & 1 deletion pkg/apis/events/event-data.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ type GithubEventData struct {

// GitLabEventData represents the event data generated by the GitLab gateway.
type GitLabEventData struct {
// Headers from the Gitlab http request.
Headers http.Header `json:"headers"`
// Body represents the message body
Body []byte `json:"body"`
Body *json.RawMessage `json:"body"`
}

// KafkaEventData represents the event data generated by the Kafka gateway.
Expand Down

0 comments on commit 0d41182

Please sign in to comment.