Skip to content

Commit 56e825a

Browse files
committed
resource/gitlab_project: Fix passing ci_forward_deployment_enabled=false to API at project creation
This commit fixes an issue when passing `ci_forward_deployment_enabled=false` is ignored. Gitlab API only allow updating this parameter when editing a project.
1 parent 0db2a70 commit 56e825a

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

internal/provider/resource_gitlab_project.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,9 +539,9 @@ var resourceGitLabProjectSchema = map[string]*schema.Schema{
539539
},
540540
"repository_storage": {
541541
Description: " Which storage shard the repository is on. (administrator only)",
542-
Type: schema.TypeString,
543-
Optional: true,
544-
Computed: true,
542+
Type: schema.TypeString,
543+
Optional: true,
544+
Computed: true,
545545
},
546546
"requirements_access_level": {
547547
Description: fmt.Sprintf("Set the requirements access level. Valid values are %s.", renderValueListForDocs(validProjectAccessLevels)),
@@ -1204,6 +1204,12 @@ func resourceGitlabProjectCreate(ctx context.Context, d *schema.ResourceData, me
12041204
editProjectOptions.CIDefaultGitDepth = gitlab.Int(v.(int))
12051205
}
12061206

1207+
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
1208+
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
1209+
if v, ok := d.GetOkExists("ci_forward_deployment_enabled"); ok {
1210+
editProjectOptions.CIForwardDeploymentEnabled = gitlab.Bool(v.(bool))
1211+
}
1212+
12071213
if (editProjectOptions != gitlab.EditProjectOptions{}) {
12081214
if _, _, err := client.Projects.EditProject(d.Id(), &editProjectOptions, gitlab.WithContext(ctx)); err != nil {
12091215
return diag.Errorf("Could not update project %q: %s", d.Id(), err)

internal/provider/resource_gitlab_project_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,7 @@ func TestAccGitlabProject_SetDefaultFalseBooleansOnCreate(t *testing.T) {
13771377
public_builds = false
13781378
merge_pipelines_enabled = false
13791379
merge_trains_enabled = false
1380+
ci_forward_deployment_enabled = false
13801381
}`, rInt),
13811382
},
13821383
{

0 commit comments

Comments
 (0)