Tag protection generates the wrong URL #156
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When protecting a tag containing a wildcard (like v*), the terraform plugin generates an invalid URL and thus fails to protect it.
For example, the Terraform log contains:
2019/06/24 12:28:39 [DEBUG] read gitlab tag protection for project 38, tag v*
2019/06/24 12:28:39 [DEBUG] GitLab API Request Details:
---[ REQUEST ]---------------------------------------
GET /api/v4/projects/38/protected_tags/v%252A HTTP/1.1
Host: 10.164.61.17
User-Agent: go-gitlab
Accept: application/json
Private-Token: nyPXE9zGT9aisyXvpWyG
Accept-Encoding: gzip
This is the REST call that checks if a protected tag has been correctly created, after the creation occurred. The URL is completely broken (it includes a double URL encoding). The GitLab server answers with a 404 return code.
Branches work correctly:
2019/06/24 12:28:39 [DEBUG] read gitlab branch protection for project 38, branch release-*
2019/06/24 12:28:39 [DEBUG] GitLab API Request Details:
---[ REQUEST ]---------------------------------------
GET /api/v4/projects/38/protected_branches/release-* HTTP/1.1
Host: 10.164.61.17
User-Agent: go-gitlab
Accept: application/json
Private-Token: nyPXE9zGT9aisyXvpWyG
Accept-Encoding: gzip
So I aligned the code for protecting tags to the used code for protecting branches, thus removing the URL encoding. I think this issue is now visible because of changes in pull request #130 that made the code fail when the server returns 404.