Skip to content

Commit

Permalink
Added releases event webhook option
Browse files Browse the repository at this point in the history
  • Loading branch information
hnaderi committed Feb 1, 2022
1 parent b5e4d4c commit 05feff6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/resources/project_hook.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ resource "gitlab_project_hook" "example" {
- **pipeline_events** (Boolean) Invoke the hook for pipeline events.
- **push_events** (Boolean) Invoke the hook for push events.
- **push_events_branch_filter** (String) Invoke the hook for push events on matching branches only.
- **releases_events** (Boolean) Invoke the hook for releases events.
- **tag_push_events** (Boolean) Invoke the hook for tag push events.
- **token** (String, Sensitive) A token to present when invoking the hook.
- **wiki_page_events** (Boolean) Invoke the hook for wiki page events.
Expand Down
9 changes: 9 additions & 0 deletions gitlab/resource_gitlab_project_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ func resourceGitlabProjectHook() *schema.Resource {
Optional: true,
Default: false,
},
"releases_events": {
Description: "Invoke the hook for releases events.",
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"enable_ssl_verification": {
Description: "Enable ssl verification when invoking the hook.",
Type: schema.TypeBool,
Expand Down Expand Up @@ -138,6 +144,7 @@ func resourceGitlabProjectHookCreate(ctx context.Context, d *schema.ResourceData
PipelineEvents: gitlab.Bool(d.Get("pipeline_events").(bool)),
WikiPageEvents: gitlab.Bool(d.Get("wiki_page_events").(bool)),
DeploymentEvents: gitlab.Bool(d.Get("deployment_events").(bool)),
ReleasesEvents: gitlab.Bool(d.Get("releases_events").(bool)),
EnableSSLVerification: gitlab.Bool(d.Get("enable_ssl_verification").(bool)),
}

Expand Down Expand Up @@ -189,6 +196,7 @@ func resourceGitlabProjectHookRead(ctx context.Context, d *schema.ResourceData,
d.Set("pipeline_events", hook.PipelineEvents)
d.Set("wiki_page_events", hook.WikiPageEvents)
d.Set("deployment_events", hook.DeploymentEvents)
d.Set("releases_events", hook.ReleasesEvents)
d.Set("enable_ssl_verification", hook.EnableSSLVerification)
return nil
}
Expand All @@ -214,6 +222,7 @@ func resourceGitlabProjectHookUpdate(ctx context.Context, d *schema.ResourceData
PipelineEvents: gitlab.Bool(d.Get("pipeline_events").(bool)),
WikiPageEvents: gitlab.Bool(d.Get("wiki_page_events").(bool)),
DeploymentEvents: gitlab.Bool(d.Get("deployment_events").(bool)),
ReleasesEvents: gitlab.Bool(d.Get("releases_events").(bool)),
EnableSSLVerification: gitlab.Bool(d.Get("enable_ssl_verification").(bool)),
}

Expand Down
7 changes: 7 additions & 0 deletions gitlab/resource_gitlab_project_hook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func TestAccGitlabProjectHook_basic(t *testing.T) {
PipelineEvents: true,
WikiPageEvents: true,
DeploymentEvents: true,
ReleasesEvents: true,
EnableSSLVerification: false,
}),
),
Expand Down Expand Up @@ -111,6 +112,7 @@ type testAccGitlabProjectHookExpectedAttributes struct {
PipelineEvents bool
WikiPageEvents bool
DeploymentEvents bool
ReleasesEvents bool
EnableSSLVerification bool
}

Expand Down Expand Up @@ -172,6 +174,10 @@ func testAccCheckGitlabProjectHookAttributes(hook *gitlab.ProjectHook, want *tes
return fmt.Errorf("got deployment_events %t; want %t", hook.DeploymentEvents, want.DeploymentEvents)
}

if hook.ReleasesEvents != want.ReleasesEvents {
return fmt.Errorf("got releases_events %t; want %t", hook.ReleasesEvents, want.ReleasesEvents)
}

return nil
}
}
Expand Down Expand Up @@ -245,6 +251,7 @@ resource "gitlab_project_hook" "foo" {
pipeline_events = true
wiki_page_events = true
deployment_events = true
releases_events = true
}
`, rInt, rInt)
}

0 comments on commit 05feff6

Please sign in to comment.