Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.

Enhance webhook sink, add template feature to http headers #191

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion pkg/sinks/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,16 @@ func (w *Webhook) Send(ctx context.Context, ev *kube.EnhancedEvent) error {
}
req.Header.Add("Content-Type", "application/json")
for k, v := range w.cfg.Headers {
req.Header.Add(k, v)
for k, v := range w.cfg.Headers {
realValue, err := GetString(ev, v)
if err != nil {
log.Debug().Err(err).Msgf("parse template failed: %s", v)
req.Header.Add(k, v)
} else {
log.Debug().Msgf("request header: {%s: %s}", k, realValue)
req.Header.Add(k, realValue)
}
}
}
tlsClientConfig, err := setupTLS(&w.cfg.TLS)
if err != nil {
Expand Down