Skip to content

Commit a57f5ee

Browse files
committed
resource/gitlab_branch_protection: fix issue claiming that no valid access level can be found. Closes #890
I don't really understand yet what happens here. However, that behavior changed from v3.9.1 to v3.10.0. Thus, I'm simply reverting it back. We've had a brief exchange about this already when the "broken" code was merged here: #881 (comment) Obviously, we made the wrong call in that this situation doesn't happen ... well, it happened. Looking at the `gitlab_branch_protection` resource I find that it's kinda unclear what's going on, also looking at the upstream API docs doesn't shed any lights on this as the documentation is quite sparse. Some of this was lately raised by @beekeep in https://github.com/gitlabhq/terraform-provider-gitlab/issues/878#issuecomment-1048902570 , that is that some fields are arguments in the provider, but optional in the upstream API. Also the implemented logic to retrieve the set `push_access_level` and `merge_access_level` can only be guessed when trying to understand how those values come to be from a `POST` to a `GET` request of the [Protected Branches API](https://docs.gitlab.com/ee/api/protected_branches.html). Closes #890
1 parent d2c6ece commit a57f5ee

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

CHANGELOG.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 3.10.0 (2022-02-24)
2+
3+
BUG FIXES:
4+
5+
* resource/gitlab_branch_protection: Fix issue which claimed that `no valid access level` can be found ([#892](https://github.com/gitlabhq/terraform-provider-gitlab/pull/892))
6+
17
## 3.10.0 (2022-02-23)
28

39
FEATURES:
@@ -19,7 +25,7 @@ IMPROVEMENTS:
1925
* resource/gitlab_service_jira: Add `api_url` attribute ([#597](https://github.com/gitlabhq/terraform-provider-gitlab/pull/597))
2026
* resource/gitlab_user: Add `state` attribute to allow blocking users ([#762](https://github.com/gitlabhq/terraform-provider-gitlab/pull/762))
2127

22-
BUG FIXES
28+
BUG FIXES:
2329

2430
* datasource/gitlab_projects: Allow to get archived and unarchived repositories ([#855](https://github.com/gitlabhq/terraform-provider-gitlab/pull/855))
2531
* resource/gitlab_group: Support setting `default_branch_protection` to `0` ([#856](https://github.com/gitlabhq/terraform-provider-gitlab/pull/856))

internal/provider/resource_gitlab_branch_protection.go

-4
Original file line numberDiff line numberDiff line change
@@ -173,16 +173,12 @@ func resourceGitlabBranchProtectionRead(ctx context.Context, d *schema.ResourceD
173173
if err := d.Set("push_access_level", accessLevelValueToName[*pushAccessLevel]); err != nil {
174174
return diag.Errorf("error setting push_access_level: %v", err)
175175
}
176-
} else {
177-
return diag.Errorf("unable to get push_access_level: %v", err)
178176
}
179177

180178
if mergeAccessLevels, err := firstValidAccessLevel(pb.MergeAccessLevels); err == nil {
181179
if err := d.Set("merge_access_level", accessLevelValueToName[*mergeAccessLevels]); err != nil {
182180
return diag.Errorf("error setting merge_access_level: %v", err)
183181
}
184-
} else {
185-
return diag.Errorf("unable to get merge_access_level: %v", err)
186182
}
187183

188184
if err := d.Set("allow_force_push", pb.AllowForcePush); err != nil {

0 commit comments

Comments
 (0)