Skip to content

Commit

Permalink
Merge pull request #773 from hnaderi/add-releases-event-to-project-hook
Browse files Browse the repository at this point in the history
Added releases event webhook option
  • Loading branch information
timofurrer authored Feb 7, 2022
2 parents f818824 + d974dd6 commit 8e64303
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 internal/provider/resource_gitlab_project_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ var _ = registerResource("gitlab_project_hook", func() *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 internal/provider/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 @@ -110,6 +111,7 @@ type testAccGitlabProjectHookExpectedAttributes struct {
PipelineEvents bool
WikiPageEvents bool
DeploymentEvents bool
ReleasesEvents bool
EnableSSLVerification bool
}

Expand Down Expand Up @@ -171,6 +173,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 @@ -242,6 +248,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 8e64303

Please sign in to comment.