Skip to content

Commit

Permalink
feat: Set nested JSON properties in sensor payload (#606)
Browse files Browse the repository at this point in the history
  • Loading branch information
hobti01 authored Apr 23, 2020
1 parent 78d5eef commit 50f1103
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Argo Events is native to Kubernetes so you'll need a running Kubernetes cluster.
### Requirements
- Golang 1.12
- Docker
- dep
- [dep](https://golang.github.io/dep/docs/installation.html)

### Installation & Setup

Expand All @@ -32,6 +32,7 @@ cd $GOPATH/src/github.com/argoproj/argo-events

#### 2. Vendor dependencies
```
GO111MODULE=on go get github.com/cloudevents/sdk-go
dep ensure -vendor-only
```

Expand Down
10 changes: 7 additions & 3 deletions sensors/triggers/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (

// ConstructPayload constructs a payload for operations involving request and responses like HTTP request.
func ConstructPayload(sensor *v1alpha1.Sensor, parameters []v1alpha1.TriggerParameter) ([]byte, error) {
payload := make(map[string]string)
var payload []byte

events := ExtractEvents(sensor, parameters)
if events == nil {
Expand All @@ -47,10 +47,14 @@ func ConstructPayload(sensor *v1alpha1.Sensor, parameters []v1alpha1.TriggerPara
if err != nil {
return nil, err
}
payload[parameter.Dest] = value
tmp, err := sjson.SetBytes(payload, parameter.Dest, value)
if err != nil {
return nil, err
}
payload = tmp
}

return json.Marshal(payload)
return payload, nil
}

// ApplyTemplateParameters applies parameters to trigger template
Expand Down

0 comments on commit 50f1103

Please sign in to comment.