Skip to content

Commit

Permalink
Add printing_merge_request_link_enabled attribute to projects
Browse files Browse the repository at this point in the history
As mentioned on #782, the field is available on GitLab but still not
possible to use on terraform

Reference:
- https://github.com/gitlabhq/terraform-provider-gitlab/issues/782
  • Loading branch information
marceloboeira committed Jan 17, 2022
1 parent 912b647 commit 41fed04
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/data-sources/project.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ The following attributes are exported:

* `remove_source_branch_after_merge` - Enable `Delete source branch` option by default for all new merge requests

* `printing_merge_request_link_enabled` - Show link to create/view merge request when pushing from the command line.

* `packages_enabled` - Enable packages repository for the project.

* `push_rules` Push rules for the project (documented below).
Expand Down
2 changes: 2 additions & 0 deletions docs/resources/project.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ The following additional attributes are exported:

* `remove_source_branch_after_merge` - Enable `Delete source branch` option by default for all new merge requests.

* `printing_merge_request_link_enabled` - Show link to create/view merge request when pushing from the command line.

## Nested Blocks

### push_rules
Expand Down
1 change: 1 addition & 0 deletions examples/gitlab-managed-state/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ resource "gitlab_project" "api" {
only_allow_merge_if_all_discussions_are_resolved = true
only_allow_merge_if_pipeline_succeeds = true
remove_source_branch_after_merge = true
printing_merge_request_link_enabled = true

container_registry_enabled = false
lfs_enabled = false
Expand Down
5 changes: 5 additions & 0 deletions gitlab/data_source_gitlab_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ func dataSourceGitlabProject() *schema.Resource {
Type: schema.TypeBool,
Computed: true,
},
"printing_merge_request_link_enabled": {
Type: schema.TypeBool,
Computed: true,
},
// lintignore: S031 // TODO: Resolve this tfproviderlint issue
"push_rules": {
Type: schema.TypeList,
Expand Down Expand Up @@ -189,6 +193,7 @@ func dataSourceGitlabProjectRead(d *schema.ResourceData, meta interface{}) error
d.Set("runners_token", found.RunnersToken)
d.Set("archived", found.Archived)
d.Set("remove_source_branch_after_merge", found.RemoveSourceBranchAfterMerge)
d.Set("printing_merge_request_link_enabled", found.PrintingMergeRequestLinkEnabled)

log.Printf("[DEBUG] Reading Gitlab project %q push rules", d.Id())

Expand Down
4 changes: 4 additions & 0 deletions gitlab/resource_gitlab_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,10 @@ func resourceGitlabProjectUpdate(d *schema.ResourceData, meta interface{}) error
options.RemoveSourceBranchAfterMerge = gitlab.Bool(d.Get("remove_source_branch_after_merge").(bool))
}

if d.HasChange("printing_merge_request_link_enabled") {
options.RemoveSourceBranchAfterMerge = gitlab.Bool(d.Get("printing_merge_request_link_enabled").(bool))
}

if d.HasChange("packages_enabled") {
options.PackagesEnabled = gitlab.Bool(d.Get("packages_enabled").(bool))
}
Expand Down

0 comments on commit 41fed04

Please sign in to comment.