@@ -2,71 +2,41 @@ package services
2
2
3
3
import (
4
4
"bytes"
5
- "context "
5
+ "fmt "
6
6
texttemplate "text/template"
7
-
8
- slackutil "github.com/argoproj/notifications-engine/pkg/util/slack"
9
7
)
10
8
11
9
type 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"`
17
12
}
18
13
19
14
func (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 )
29
16
if err != nil {
30
17
return nil , err
31
18
}
32
19
33
20
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 {}
36
23
}
37
- var slackAttachmentsData bytes.Buffer
38
- if err := slackAttachments .Execute (& slackAttachmentsData , vars ); err != nil {
39
- return err
40
- }
41
- notification .Slack .Attachments = slackAttachmentsData .String ()
42
24
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
48
26
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 {
51
29
return err
52
30
}
53
- notification .Slack . GroupingKey = groupingKeyData .String ()
31
+ notification .Datadog . Tags = tagsData .String ()
54
32
55
- notification .Slack .NotifyBroadcast = n .NotifyBroadcast
56
- notification .Slack .DeliveryPolicy = n .DeliveryPolicy
57
33
return nil
58
34
}, nil
59
35
}
60
36
61
37
type 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"`
70
40
}
71
41
72
42
type datadogService struct {
@@ -78,19 +48,8 @@ func NewDatadogService(opts DatadogOptions) NotificationService {
78
48
}
79
49
80
50
func (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
96
55
}
0 commit comments