Skip to content

Commit

Permalink
fix(hooks): interpolate outgoing hook (#3738)
Browse files Browse the repository at this point in the history
close #3718
  • Loading branch information
yesnault authored and bnjjj committed Dec 17, 2018
1 parent f535713 commit e74556f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion engine/hooks/outgoing_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,14 @@ func (s *Service) doOutgoingWorkflowExecution(t *sdk.TaskExecution) error {

payloadValues := map[string]string{}
if payload, ok := hookRun.OutgoingHook.Config[sdk.Payload]; ok && payload.Value != "{}" {
mapParams := sdk.ParametersToMap(hookRun.BuildParameters)
payloadstr, err := interpolate.Do(payload.Value, mapParams)
if err != nil {
return handleError(errors.New("unable to interpolate values on payload hook for " + hookRunID))
}

var payloadInt interface{}
if err := json.Unmarshal([]byte(payload.Value), &payloadInt); err == nil {
if err := json.Unmarshal([]byte(payloadstr), &payloadInt); err == nil {
e := dump.NewDefaultEncoder(new(bytes.Buffer))
e.Formatters = []dump.KeyFormatterFunc{dump.WithDefaultLowerCaseFormatter()}
e.ExtraFields.DetailedMap = false
Expand Down

0 comments on commit e74556f

Please sign in to comment.