Skip to content

Commit e8f3a34

Browse files
author
Julien Pivotto
authored
Merge pull request #242 from rin-amezquita/slack
Changing notify_only_default_branch for branches_to_be_notified on slack
2 parents 7dbdd83 + 0b6850e commit e8f3a34

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

gitlab/resource_gitlab_service_slack.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ func resourceGitlabServiceSlack() *schema.Resource {
3737
Computed: true,
3838
},
3939
"notify_only_default_branch": {
40-
Type: schema.TypeBool,
40+
Type: schema.TypeBool,
41+
Optional: true,
42+
Computed: true,
43+
Deprecated: "use 'branches_to_be_notified' argument instead",
44+
},
45+
"branches_to_be_notified": {
46+
Type: schema.TypeString,
4147
Optional: true,
4248
Computed: true,
4349
},
@@ -140,6 +146,7 @@ func resourceGitlabServiceSlackSetToState(d *schema.ResourceData, service *gitla
140146
d.Set("username", service.Properties.Username)
141147
d.Set("notify_only_broken_pipelines", service.Properties.NotifyOnlyBrokenPipelines.UnmarshalJSON)
142148
d.Set("notify_only_default_branch", service.Properties.NotifyOnlyDefaultBranch.UnmarshalJSON)
149+
d.Set("branches_to_be_notified", service.Properties.BranchesToBeNotified)
143150
d.Set("push_events", service.PushEvents)
144151
d.Set("push_channel", service.Properties.PushChannel)
145152
d.Set("issues_events", service.IssuesEvents)
@@ -175,6 +182,7 @@ func resourceGitlabServiceSlackCreate(d *schema.ResourceData, meta interface{})
175182
opts.Username = gitlab.String(d.Get("username").(string))
176183
opts.NotifyOnlyBrokenPipelines = gitlab.Bool(d.Get("notify_only_broken_pipelines").(bool))
177184
opts.NotifyOnlyDefaultBranch = gitlab.Bool(d.Get("notify_only_default_branch").(bool))
185+
opts.BranchesToBeNotified = gitlab.String(d.Get("branches_to_be_notified").(string))
178186
opts.PushEvents = gitlab.Bool(d.Get("push_events").(bool))
179187
opts.PushChannel = gitlab.String(d.Get("push_channel").(string))
180188
opts.IssuesEvents = gitlab.Bool(d.Get("issues_events").(bool))

gitlab/resource_gitlab_service_slack_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ resource "gitlab_service_slack" "slack" {
213213
wiki_page_channel = "test"
214214
notify_only_broken_pipelines = true
215215
notify_only_default_branch = true
216+
branches_to_be_notified = "all"
216217
}
217218
`, rInt)
218219
}
@@ -251,6 +252,7 @@ resource "gitlab_service_slack" "slack" {
251252
wiki_page_channel = "test wiki_page_channel"
252253
notify_only_broken_pipelines = false
253254
notify_only_default_branch = false
255+
branches_to_be_notified = "all"
254256
}
255257
`, rInt)
256258
}

website/docs/r/service_slack.html.markdown

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ The following arguments are supported:
4040

4141
* `notify_only_broken_pipelines` - (Optional) Send notifications for broken pipelines.
4242

43-
* `notify_only_default_branch` - (Optional) Send notifications only for the default branch.
43+
* `notify_only_default_branch` - (Optional) DEPRECATED: This parameter has been replaced with `branches_to_be_notified`.
44+
45+
* `branches_to_be_notified` - (Optional) Branches to send notifications for. Valid options are "all", "default", "protected", and "default_and_protected".
4446

4547
* `push_events` - (Optional) Enable notifications for push events.
4648

0 commit comments

Comments
 (0)