Skip to content

Commit 333fffc

Browse files
committed
add support for 'deployment_events' in 'gitlab_project_hook' resource
1 parent b6465ca commit 333fffc

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

docs/resources/project_hook.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ The following arguments are supported:
4848
* `pipeline_events` - (Optional) Invoke the hook for pipeline events.
4949

5050
* `wiki_page_events` - (Optional) Invoke the hook for wiki page events.
51+
52+
* `deployment_events` - (Optional) Invoke the hook for deployment events.
5153

5254
## Attributes Reference
5355

gitlab/resource_gitlab_project_hook.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ func resourceGitlabProjectHook() *schema.Resource {
8484
Optional: true,
8585
Default: false,
8686
},
87+
"deployment_events": {
88+
Type: schema.TypeBool,
89+
Optional: true,
90+
Default: false,
91+
},
8792
"enable_ssl_verification": {
8893
Type: schema.TypeBool,
8994
Optional: true,
@@ -109,6 +114,7 @@ func resourceGitlabProjectHookCreate(d *schema.ResourceData, meta interface{}) e
109114
JobEvents: gitlab.Bool(d.Get("job_events").(bool)),
110115
PipelineEvents: gitlab.Bool(d.Get("pipeline_events").(bool)),
111116
WikiPageEvents: gitlab.Bool(d.Get("wiki_page_events").(bool)),
117+
DeploymentEvents: gitlab.Bool(d.Get("deployment_events").(bool)),
112118
EnableSSLVerification: gitlab.Bool(d.Get("enable_ssl_verification").(bool)),
113119
}
114120

@@ -154,6 +160,7 @@ func resourceGitlabProjectHookRead(d *schema.ResourceData, meta interface{}) err
154160
d.Set("job_events", hook.JobEvents)
155161
d.Set("pipeline_events", hook.PipelineEvents)
156162
d.Set("wiki_page_events", hook.WikiPageEvents)
163+
d.Set("deployment_events", hook.DeploymentEvents)
157164
d.Set("enable_ssl_verification", hook.EnableSSLVerification)
158165
return nil
159166
}
@@ -178,6 +185,7 @@ func resourceGitlabProjectHookUpdate(d *schema.ResourceData, meta interface{}) e
178185
JobEvents: gitlab.Bool(d.Get("job_events").(bool)),
179186
PipelineEvents: gitlab.Bool(d.Get("pipeline_events").(bool)),
180187
WikiPageEvents: gitlab.Bool(d.Get("wiki_page_events").(bool)),
188+
DeploymentEvents: gitlab.Bool(d.Get("deployment_events").(bool)),
181189
EnableSSLVerification: gitlab.Bool(d.Get("enable_ssl_verification").(bool)),
182190
}
183191

gitlab/resource_gitlab_project_hook_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func TestAccGitlabProjectHook_basic(t *testing.T) {
5050
JobEvents: true,
5151
PipelineEvents: true,
5252
WikiPageEvents: true,
53+
DeploymentEvents: true,
5354
EnableSSLVerification: false,
5455
}),
5556
),
@@ -109,6 +110,7 @@ type testAccGitlabProjectHookExpectedAttributes struct {
109110
JobEvents bool
110111
PipelineEvents bool
111112
WikiPageEvents bool
113+
DeploymentEvents bool
112114
EnableSSLVerification bool
113115
}
114116

@@ -166,6 +168,10 @@ func testAccCheckGitlabProjectHookAttributes(hook *gitlab.ProjectHook, want *tes
166168
return fmt.Errorf("got wiki_page_events %t; want %t", hook.WikiPageEvents, want.WikiPageEvents)
167169
}
168170

171+
if hook.DeploymentEvents != want.DeploymentEvents {
172+
return fmt.Errorf("got deployment_events %t; want %t", hook.DeploymentEvents, want.DeploymentEvents)
173+
}
174+
169175
return nil
170176
}
171177
}
@@ -238,6 +244,7 @@ resource "gitlab_project_hook" "foo" {
238244
job_events = true
239245
pipeline_events = true
240246
wiki_page_events = true
247+
deployment_events = true
241248
}
242249
`, rInt, rInt)
243250
}

0 commit comments

Comments
 (0)