@@ -2,71 +2,41 @@ package services
22
33import (
44 "bytes"
5- "context "
5+ "fmt "
66 texttemplate "text/template"
7-
8- slackutil "github.com/argoproj/notifications-engine/pkg/util/slack"
97)
108
119type DatadogNotification struct {
12- Attachments string `json:"attachments,omitempty"`
13- Blocks string `json:"blocks,omitempty"`
14- GroupingKey string `json:"groupingKey"`
15- NotifyBroadcast bool `json:"notifyBroadcast"`
16- DeliveryPolicy slackutil.DeliveryPolicy `json:"deliveryPolicy"`
10+ AlertType string `json:"alertType,omitempty"`
11+ Tags string `json:"tags,omitempty"`
1712}
1813
1914func (n * DatadogNotification ) GetTemplater (name string , f texttemplate.FuncMap ) (Templater , error ) {
20- slackAttachments , err := texttemplate .New (name ).Funcs (f ).Parse (n .Attachments )
21- if err != nil {
22- return nil , err
23- }
24- slackBlocks , err := texttemplate .New (name ).Funcs (f ).Parse (n .Blocks )
25- if err != nil {
26- return nil , err
27- }
28- groupingKey , err := texttemplate .New (name ).Funcs (f ).Parse (n .GroupingKey )
15+ tags , err := texttemplate .New (name ).Funcs (f ).Parse (n .Tags )
2916 if err != nil {
3017 return nil , err
3118 }
3219
3320 return func (notification * Notification , vars map [string ]interface {}) error {
34- if notification .Slack == nil {
35- notification .Slack = & SlackNotification {}
21+ if notification .Datadog == nil {
22+ notification .Datadog = & DatadogNotification {}
3623 }
37- var slackAttachmentsData bytes.Buffer
38- if err := slackAttachments .Execute (& slackAttachmentsData , vars ); err != nil {
39- return err
40- }
41- notification .Slack .Attachments = slackAttachmentsData .String ()
4224
43- var slackBlocksData bytes.Buffer
44- if err := slackBlocks .Execute (& slackBlocksData , vars ); err != nil {
45- return err
46- }
47- notification .Slack .Blocks = slackBlocksData .String ()
25+ notification .Datadog .AlertType = n .AlertType
4826
49- var groupingKeyData bytes.Buffer
50- if err := groupingKey .Execute (& groupingKeyData , vars ); err != nil {
27+ var tagsData bytes.Buffer
28+ if err := tags .Execute (& tagsData , vars ); err != nil {
5129 return err
5230 }
53- notification .Slack . GroupingKey = groupingKeyData .String ()
31+ notification .Datadog . Tags = tagsData .String ()
5432
55- notification .Slack .NotifyBroadcast = n .NotifyBroadcast
56- notification .Slack .DeliveryPolicy = n .DeliveryPolicy
5733 return nil
5834 }, nil
5935}
6036
6137type DatadogOptions struct {
62- Username string `json:"username"`
63- Icon string `json:"icon"`
64- Token string `json:"token"`
65- SigningSecret string `json:"signingSecret"`
66- Channels []string `json:"channels"`
67- InsecureSkipVerify bool `json:"insecureSkipVerify"`
68- ApiURL string `json:"apiURL"`
69- DisableUnfurl bool `json:"disableUnfurl"`
38+ DDApiKey string `json:"ddApiKey"`
39+ DDAppKey string `json:"ddAppKey"`
7040}
7141
7242type datadogService struct {
@@ -78,19 +48,8 @@ func NewDatadogService(opts DatadogOptions) NotificationService {
7848}
7949
8050func (s * datadogService ) Send (notification Notification , dest Destination ) error {
81- slackNotification , msgOptions , err := buildMessageOptions (notification , dest , s .opts )
82- if err != nil {
83- return err
84- }
85- return slackutil .NewThreadedClient (
86- newSlackClient (s .opts ),
87- slackState ,
88- ).SendMessage (
89- context .TODO (),
90- dest .Recipient ,
91- slackNotification .GroupingKey ,
92- slackNotification .NotifyBroadcast ,
93- slackNotification .DeliveryPolicy ,
94- msgOptions ,
95- )
51+ // print notificaiton.Datadog
52+ fmt .Printf ("%+v" , notification .Datadog )
53+
54+ return nil
9655}
0 commit comments