Skip to content

Commit 2f06bac

Browse files
authored
Merge pull request #1249 from pascal-hofmann/main
gitlab_projects(s): Add suggestion_commit_message
2 parents ee81e29 + db02fec commit 2f06bac

File tree

7 files changed

+33
-0
lines changed

7 files changed

+33
-0
lines changed

docs/data-sources/project.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ data "gitlab_project" "example" {
8282
- `snippets_enabled` (Boolean) Enable snippets for the project.
8383
- `squash_commit_template` (String) Template used to create squash commit message in merge requests. (Introduced in GitLab 14.6.)
8484
- `ssh_url_to_repo` (String) URL that can be provided to `git clone` to clone the
85+
- `suggestion_commit_message` (String) The commit message used to apply merge request suggestions.
8586
- `topics` (Set of String) The list of topics for the project.
8687
- `visibility_level` (String) Repositories are created as private by default.
8788
- `web_url` (String) URL that can be used to find the project in a browser.

docs/data-sources/projects.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ Read-Only:
158158
- `ssh_url_to_repo` (String)
159159
- `star_count` (Number)
160160
- `statistics` (Map of Number)
161+
- `suggestion_commit_message` (String)
161162
- `tag_list` (Set of String)
162163
- `topics` (Set of String)
163164
- `visibility` (String)

docs/resources/project.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ This attribute is only used during resource creation, thus changes are suppresse
144144
- `snippets_enabled` (Boolean) Enable snippets for the project.
145145
- `squash_commit_template` (String) Template used to create squash commit message in merge requests. (Introduced in GitLab 14.6.)
146146
- `squash_option` (String) Squash commits when merge request. Valid values are `never`, `always`, `default_on`, or `default_off`. The default value is `default_off`. [GitLab >= 14.1]
147+
- `suggestion_commit_message` (String) The commit message used to apply merge request suggestions.
147148
- `tags` (Set of String) The list of tags for a project; put array of tags, that should be finally assigned to a project. Use topics instead.
148149
- `template_name` (String) When used without use_custom_template, name of a built-in project template. When used with use_custom_template, name of a custom project template. This option is mutually exclusive with `template_project_id`.
149150
- `template_project_id` (Number) When used with use_custom_template, project ID of a custom project template. This is preferable to using template_name since template_name may be ambiguous (enterprise edition). This option is mutually exclusive with `template_name`. See `gitlab_group_project_file_template` to set a project as a template project. If a project has not been set as a template, using it here will result in an error.

internal/provider/data_source_gitlab_project.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,11 @@ var _ = registerDataSource("gitlab_project", func() *schema.Resource {
267267
Type: schema.TypeString,
268268
Computed: true,
269269
},
270+
"suggestion_commit_message": {
271+
Description: "The commit message used to apply merge request suggestions.",
272+
Type: schema.TypeString,
273+
Computed: true,
274+
},
270275
"topics": {
271276
Description: "The list of topics for the project.",
272277
Type: schema.TypeSet,
@@ -434,6 +439,7 @@ func dataSourceGitlabProjectRead(ctx context.Context, d *schema.ResourceData, me
434439
d.Set("requirements_access_level", string(found.RequirementsAccessLevel))
435440
d.Set("security_and_compliance_access_level", string(found.SecurityAndComplianceAccessLevel))
436441
d.Set("snippets_access_level", string(found.SnippetsAccessLevel))
442+
d.Set("suggestion_commit_message", found.SuggestionCommitMessage)
437443
if err := d.Set("topics", found.Topics); err != nil {
438444
return diag.Errorf("error setting topics: %v", err)
439445
}

internal/provider/data_source_gitlab_projects.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ func flattenProjects(projects []*gitlab.Project) (values []map[string]interface{
186186
"requirements_access_level": string(project.RequirementsAccessLevel),
187187
"security_and_compliance_access_level": string(project.SecurityAndComplianceAccessLevel),
188188
"snippets_access_level": string(project.SnippetsAccessLevel),
189+
"suggestion_commit_message": project.SuggestionCommitMessage,
189190
"topics": project.Topics,
190191
"wiki_access_level": string(project.WikiAccessLevel),
191192
"squash_commit_template": project.SquashCommitTemplate,
@@ -923,6 +924,11 @@ var _ = registerDataSource("gitlab_projects", func() *schema.Resource {
923924
Type: schema.TypeString,
924925
Computed: true,
925926
},
927+
"suggestion_commit_message": {
928+
Description: "The commit message used to apply merge request suggestions.",
929+
Type: schema.TypeString,
930+
Computed: true,
931+
},
926932
"topics": {
927933
Description: "The list of topics for the project.",
928934
Type: schema.TypeSet,

internal/provider/resource_gitlab_project.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,11 @@ var resourceGitLabProjectSchema = map[string]*schema.Schema{
564564
Computed: true,
565565
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice(validProjectAccessLevels, false)),
566566
},
567+
"suggestion_commit_message": {
568+
Description: "The commit message used to apply merge request suggestions.",
569+
Type: schema.TypeString,
570+
Optional: true,
571+
},
567572
"topics": {
568573
Description: "The list of topics for the project.",
569574
Type: schema.TypeSet,
@@ -769,6 +774,7 @@ func resourceGitlabProjectSetToState(ctx context.Context, client *gitlab.Client,
769774
d.Set("requirements_access_level", string(project.RequirementsAccessLevel))
770775
d.Set("security_and_compliance_access_level", string(project.SecurityAndComplianceAccessLevel))
771776
d.Set("snippets_access_level", string(project.SnippetsAccessLevel))
777+
d.Set("suggestion_commit_message", project.SuggestionCommitMessage)
772778
if err := d.Set("topics", project.Topics); err != nil {
773779
return fmt.Errorf("error setting topics: %v", err)
774780
}
@@ -974,6 +980,10 @@ func resourceGitlabProjectCreate(ctx context.Context, d *schema.ResourceData, me
974980
options.SnippetsAccessLevel = stringToAccessControlValue(v.(string))
975981
}
976982

983+
if v, ok := d.GetOk("suggestion_commit_message"); ok {
984+
options.SuggestionCommitMessage = gitlab.String(v.(string))
985+
}
986+
977987
if v, ok := d.GetOk("topics"); ok {
978988
options.Topics = stringSetToStringSlice(v.(*schema.Set))
979989
}
@@ -1514,6 +1524,10 @@ func resourceGitlabProjectUpdate(ctx context.Context, d *schema.ResourceData, me
15141524
options.SnippetsAccessLevel = stringToAccessControlValue(d.Get("snippets_access_level").(string))
15151525
}
15161526

1527+
if d.HasChange("suggestion_commit_message") {
1528+
options.SuggestionCommitMessage = gitlab.String(d.Get("suggestion_commit_message").(string))
1529+
}
1530+
15171531
if d.HasChange("topics") {
15181532
options.Topics = stringSetToStringSlice(d.Get("topics").(*schema.Set))
15191533
}

internal/provider/resource_gitlab_project_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ func TestAccGitlabProject_basic(t *testing.T) {
109109
RepositoryStorage: "default",
110110
SecurityAndComplianceAccessLevel: gitlab.EnabledAccessControl,
111111
SnippetsAccessLevel: gitlab.EnabledAccessControl,
112+
SuggestionCommitMessage: "hello suggestion",
112113
Topics: []string{"foo", "bar"},
113114
WikiAccessLevel: gitlab.EnabledAccessControl,
114115
SquashCommitTemplate: "hello squash",
@@ -1754,6 +1755,7 @@ resource "gitlab_project" "foo" {
17541755
repository_storage = "default"
17551756
security_and_compliance_access_level = "enabled"
17561757
snippets_access_level = "enabled"
1758+
suggestion_commit_message = "hello suggestion"
17571759
topics = ["foo", "bar"]
17581760
wiki_access_level = "enabled"
17591761
squash_commit_template = "hello squash"
@@ -1996,6 +1998,7 @@ resource "gitlab_project" "foo" {
19961998
repository_storage = "default"
19971999
security_and_compliance_access_level = "enabled"
19982000
snippets_access_level = "enabled"
2001+
suggestion_commit_message = "hello suggestion"
19992002
topics = ["foo", "bar"]
20002003
wiki_access_level = "enabled"
20012004
squash_commit_template = "hello squash"
@@ -2191,6 +2194,7 @@ resource "gitlab_project" "foo" {
21912194
repository_storage = "default"
21922195
security_and_compliance_access_level = "enabled"
21932196
snippets_access_level = "enabled"
2197+
suggestion_commit_message = "hello suggestion"
21942198
topics = ["foo", "bar"]
21952199
wiki_access_level = "enabled"
21962200
squash_commit_template = "hello squash"

0 commit comments

Comments
 (0)