0
0
Fork 0
mirror of https://github.com/crazy-max/diun.git synced 2025-01-27 01:08:50 +00:00
crazy-max_diun/internal/model/notif_slack.go
CrazyMax fc64b132ff
Option to render fields (#480)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-09-04 18:41:42 +02:00

26 lines
1 KiB
Go

package model
import "github.com/crazy-max/diun/v4/pkg/utl"
// NotifSlackDefaultTemplateBody ...
const NotifSlackDefaultTemplateBody = "<!channel> Docker tag {{ if .Entry.Image.HubLink }}<{{ .Entry.Image.HubLink }}|`{{ .Entry.Image }}`>{{ else }}`{{ .Entry.Image }}`{{ end }} {{ if (eq .Entry.Status \"new\") }}available{{ else }}updated{{ end }}."
// NotifSlack holds slack notification configuration details
type NotifSlack struct {
WebhookURL string `yaml:"webhookURL,omitempty" json:"webhookURL,omitempty" validate:"required"`
RenderFields *bool `yaml:"renderFields,omitempty" json:"renderFields,omitempty" validate:"required"`
TemplateBody string `yaml:"templateBody,omitempty" json:"templateBody,omitempty" validate:"required"`
}
// GetDefaults gets the default values
func (s *NotifSlack) GetDefaults() *NotifSlack {
n := &NotifSlack{}
n.SetDefaults()
return n
}
// SetDefaults sets the default values
func (s *NotifSlack) SetDefaults() {
s.RenderFields = utl.NewTrue()
s.TemplateBody = NotifSlackDefaultTemplateBody
}