Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ooaklee/Add-mattermost-notifier-integration #119

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
85 changes: 85 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ You can do this by using this command.

<img src="./misc/images/3.png" width="600">

<img src="./misc/images/4.png" width="500">

## Installation

Grab the binary from GitHub Releases (Recommended)
Expand Down Expand Up @@ -313,6 +315,89 @@ terraform:
```
</details>


<details>
<summary>For Mattermost</summary>

```yaml
---
ci: circleci
notifier:
mattermost:
webhook: $MATTERMOST_WEBHOOK
channel: $MATTERMOST_CHANNEL
bot: $MATTERMOST_BOT_NAME
terraform:
fmt:
template: |
{{if .Message}}**`Message`**: {{ .Message }}{{end}}
**`Context`**: [*(Click me) Explore the change(s) further*]( {{ .Link }} )

{{if .Result}}
## Result
```
{{ .Result }}
```
{{end}}

## Details

View the summary below

```
{{ .Body }}
```

plan:
template: |
{{if .Message}}**`Message`**: {{ .Message }}{{end}}
**`Context`**: [*(Click me) Explore the change(s) further*]( {{ .Link }} )

{{if .Result}}
## Result
```
{{ .Result }}
```
{{end}}

## Details

View the summary below

```
{{ .Body }}
```

when_destroy:
template: |
## :warning: WARNING: Resource Deletion will happen :warning:

This plan contains **resource deletion**. Please check the plan result very carefully!
apply:
template: |
{{if .Message}}**`Message`**: {{ .Message }}{{end}}
**`Context`**: [*(Click me) Explore the change(s) further*]( {{ .Link }} )

{{if .Result}}
## Result
```
{{ .Result }}
```
{{end}}

## Details

View the summary below

```
{{ .Body }}
```
```

> Note, for `notifier.mattermost.bot` to work override, you must ensure you enable application/ webhook overrides on your Mattermost system. If you do not, the webhook will, by default, take the name of its creator. If you cannot enable application/ webhook overrides, you might have to consider creating a dedicated `tfnotify` Mattermost user account.

</details>

<details>
<summary>For Slack</summary>

Expand Down
35 changes: 31 additions & 4 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ type Config struct {

// Notifier is a notification notifier
type Notifier struct {
Github GithubNotifier `yaml:"github"`
Gitlab GitlabNotifier `yaml:"gitlab"`
Slack SlackNotifier `yaml:"slack"`
Typetalk TypetalkNotifier `yaml:"typetalk"`
Github GithubNotifier `yaml:"github"`
Gitlab GitlabNotifier `yaml:"gitlab"`
Slack SlackNotifier `yaml:"slack"`
Typetalk TypetalkNotifier `yaml:"typetalk"`
Mattermost MattermostNotifier `yaml:"mattermost"`
}

// GithubNotifier is a notifier for GitHub
Expand Down Expand Up @@ -54,6 +55,13 @@ type SlackNotifier struct {
Bot string `yaml:"bot"`
}

// MattermostNotifier is a notifier for Mattermost
type MattermostNotifier struct {
Webhook string `yaml:"webhook"`
Channel string `yaml:"channel"`
Bot string `yaml:"bot"`
}

// TypetalkNotifier is a notifier for Typetalk
type TypetalkNotifier struct {
Token string `yaml:"token"`
Expand Down Expand Up @@ -172,6 +180,17 @@ func (cfg *Config) Validation() error {
return fmt.Errorf("slack channel id is missing")
}
}

if cfg.isDefinedMattermost() {
if cfg.Notifier.Mattermost.Channel == "" {
fmt.Println("[info] mattermost channel id not provided. Targetting webhook's default channel")
}

if cfg.Notifier.Mattermost.Webhook == "" {
return fmt.Errorf("mattermost webhook is missing")
}
}

if cfg.isDefinedTypetalk() {
if cfg.Notifier.Typetalk.TopicID == "" {
return fmt.Errorf("Typetalk topic id is missing")
Expand All @@ -194,6 +213,11 @@ func (cfg *Config) isDefinedGitlab() bool {
return cfg.Notifier.Gitlab != (GitlabNotifier{})
}

func (cfg *Config) isDefinedMattermost() bool {
// not empty
return cfg.Notifier.Mattermost != (MattermostNotifier{})
}

func (cfg *Config) isDefinedSlack() bool {
// not empty
return cfg.Notifier.Slack != (SlackNotifier{})
Expand All @@ -212,6 +236,9 @@ func (cfg *Config) GetNotifierType() string {
if cfg.isDefinedGitlab() {
return "gitlab"
}
if cfg.isDefinedMattermost() {
return "mattermost"
}
if cfg.isDefinedSlack() {
return "slack"
}
Expand Down
46 changes: 46 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ func TestLoadFile(t *testing.T) {
Token: "",
TopicID: "",
},
Mattermost: MattermostNotifier{
Webhook: "",
Channel: "",
Bot: "",
},
},
Terraform: Terraform{
Default: Default{
Expand Down Expand Up @@ -83,6 +88,11 @@ func TestLoadFile(t *testing.T) {
Token: "",
TopicID: "",
},
Mattermost: MattermostNotifier{
Webhook: "",
Channel: "",
Bot: "",
},
},
Terraform: Terraform{
Default: Default{
Expand Down Expand Up @@ -137,6 +147,11 @@ func TestLoadFile(t *testing.T) {
Token: "",
TopicID: "",
},
Mattermost: MattermostNotifier{
Webhook: "",
Channel: "",
Bot: "",
},
},
Terraform: Terraform{
Default: Default{
Expand Down Expand Up @@ -236,6 +251,14 @@ func TestValidation(t *testing.T) {
contents: []byte("ci: circleci\nnotifier:\n github:\n token: token\n"),
expected: "repository owner is missing",
},
{
contents: []byte("ci: circleci\nnotifier:\n mattermost:\n channel: test-channel\n"),
expected: "mattermost webhook is missing",
},
{
contents: []byte("ci: circleci\nnotifier:\n mattermost:\n webhook: webhook\n"),
expected: "",
},
{
contents: []byte(`
ci: circleci
Expand Down Expand Up @@ -270,6 +293,25 @@ notifier:
{
contents: []byte(`
ci: circleci
notifier:
mattermost:
channel: channel
`),
expected: "mattermost webhook is missing",
},
{
contents: []byte(`
ci: circleci
notifier:
mattermost:
webhook: webhook
channel: channel
`),
expected: "",
},
{
contents: []byte(`
ci: circleci
notifier:
slack:
token: token
Expand Down Expand Up @@ -394,6 +436,10 @@ func TestGetNotifierType(t *testing.T) {
contents: []byte("repository:\n owner: a\n name: b\nci: gitlabci\nnotifier:\n gitlab:\n token: token\n"),
expected: "gitlab",
},
{
contents: []byte("repository:\n owner: a\n name: b\nci: circleci\nnotifier:\n mattermost:\n webhook: webhook\n"),
expected: "mattermost",
},
}
for _, testCase := range testCases {
cfg, err := helperLoadConfig(testCase.contents)
Expand Down
6 changes: 6 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ module github.com/mercari/tfnotify
go 1.12

require (
github.com/ashwanthkumar/slack-go-webhook v0.0.0-20200209025033-430dd4e66960
github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819 // indirect
github.com/google/go-github v17.0.0+incompatible
github.com/kr/pretty v0.2.0 // indirect
github.com/lestrrat-go/slack v0.0.0-20190827134815-1aaae719550a
github.com/mattn/go-colorable v0.1.4
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/nulab/go-typetalk v2.1.1+incompatible
github.com/parnurzeal/gorequest v0.2.16 // indirect
github.com/smartystreets/goconvey v1.7.2 // indirect
github.com/stretchr/testify v1.4.0
github.com/urfave/cli v1.22.2
github.com/xanzy/go-gitlab v0.22.3
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa // indirect
Expand All @@ -17,4 +22,5 @@ require (
golang.org/x/sys v0.0.0-20200121082415-34d275377bf9 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v2 v2.2.7
moul.io/http2curl v1.0.0 // indirect
)
24 changes: 21 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/ashwanthkumar/slack-go-webhook v0.0.0-20200209025033-430dd4e66960 h1:MIEURpsIpyLyy+dZ+GnL8T5P49Tco0ik9cYaUQNnAxE=
github.com/ashwanthkumar/slack-go-webhook v0.0.0-20200209025033-430dd4e66960/go.mod h1:97O1qkjJBHSSaWJxsTShRIeFy0HWiygk+jnugO9aX3I=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819 h1:RIB4cRk+lBqKK3Oy0r2gRX4ui7tuhiZq2SuTtTCi0/0=
github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM=
github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2 h1:dWB6v3RcOy03t/bUadywsbyrQwCqZeNIEX6M1OtSZOM=
github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
Expand All @@ -23,20 +33,26 @@ github.com/lestrrat-go/slack v0.0.0-20190827134815-1aaae719550a h1:1SkDXQ4ho+45i
github.com/lestrrat-go/slack v0.0.0-20190827134815-1aaae719550a/go.mod h1:2wxkiO7lExZoef2wz5rt3Mt2IGSYzQchxuQoWV7mfRM=
github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/nulab/go-typetalk v2.1.1+incompatible h1:XdLjQuNVh77Wp7Qu4w8fqFdptxozGyy+Cq7n7/uUvMw=
github.com/nulab/go-typetalk v2.1.1+incompatible/go.mod h1:m2ResEyH1dMB+0oMK/iCwd/qzCdCT+WdncQILJo/7t4=
github.com/parnurzeal/gorequest v0.2.16 h1:T/5x+/4BT+nj+3eSknXmCTnEVGSzFzPGdpqmUVVZXHQ=
github.com/parnurzeal/gorequest v0.2.16/go.mod h1:3Kh2QUMJoqw3icWAecsyzkpY7UzRfDhbRdTjtNwNiUE=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-charset v0.0.0-20180617210344-2471d30d28b4/go.mod h1:qgYeAmZ5ZIpBWTGllZSQnw97Dj+woV0toclVaRGI8pc=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/smartystreets/assertions v1.2.0 h1:42S6lae5dvLc7BrLu/0ugRtcFVjoJNMC/N3yZFZkDFs=
github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
github.com/smartystreets/goconvey v1.7.2 h1:9RBaZCeXEQ3UselpuwUQHltGVXvdwm6cv1hgR6gDIPg=
github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3Pg9vgXWeJpQFMM=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
Expand All @@ -47,8 +63,8 @@ github.com/xanzy/go-gitlab v0.22.3/go.mod h1:t4Bmvnxj7k37S4Y17lfLx+nLqkf/oQwT2Ha
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181108082009-03003ca0c849/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa h1:F+8P+gmewFQYRk6JoLQLwjBCTu3mcIURZfNkVweuRKA=
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
Expand All @@ -60,12 +76,12 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200121082415-34d275377bf9 h1:N19i1HjUnR7TF7rMt8O4p3dLvqvmYyzB6ifMFmrbY50=
golang.org/x/sys v0.0.0-20200121082415-34d275377bf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
Expand All @@ -75,3 +91,5 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo=
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
moul.io/http2curl v1.0.0 h1:6XwpyZOYsgZJrU8exnG87ncVkU1FVCcTRpwzOkTDUi8=
moul.io/http2curl v1.0.0/go.mod h1:f6cULg+e4Md/oW1cYmwW4IWQOVl2lGbmCNGOHvzX2kE=
16 changes: 16 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/mercari/tfnotify/notifier"
"github.com/mercari/tfnotify/notifier/github"
"github.com/mercari/tfnotify/notifier/gitlab"
"github.com/mercari/tfnotify/notifier/mattermost"
"github.com/mercari/tfnotify/notifier/slack"
"github.com/mercari/tfnotify/notifier/typetalk"
"github.com/mercari/tfnotify/terraform"
Expand Down Expand Up @@ -151,6 +152,21 @@ func (t *tfnotify) Run() error {
return err
}
notifier = client.Notify
case "mattermost":
client, err := mattermost.NewClient(mattermost.Config{
Webhook: t.config.Notifier.Mattermost.Webhook,
Channel: t.config.Notifier.Mattermost.Channel,
Botname: t.config.Notifier.Mattermost.Bot,
Title: t.context.String("title"),
Message: t.context.String("message"),
CI: ci.URL,
Parser: t.parser,
Template: t.template,
})
if err != nil {
return err
}
notifier = client.Notify
case "slack":
client, err := slack.NewClient(slack.Config{
Token: t.config.Notifier.Slack.Token,
Expand Down
Binary file added misc/images/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading