gitlab_tag_protection resource is missing deploy_key_id property for the option allowed_to_create
Bug Report
When adding a protected tag, the Gitlab API allows you to give a Deploy Key create privileges for the protected tag. However the gitlab_tag_protection resource does not have this feature.
Relevant Terraform Configuration
resource "gitlab_tag_protection" "some_tag" {
project = "<some-project-id>"
tag = "<some-tag-name>"
allowed_to_create {
deploy_key_id = 472192738 # Error: Unsupported argument
}
}
Relevant Terraform Command
terraform plan
Additional Details
The gitlab_branch_protection resource correctly provides similar functionality using the allowed_to_push option. I guess the missing code for gitlab_tag_protection will be very similar to that in gitlab_branch_protection.
Implementation Guide
- Read the
CONTRIBUTING.mdguide for setting up your local development environment and clone the community fork of this project. - In
internal/provider/resource_gitlab_protected_tag.go, add a new attribute to theallowed_to_createblock in theSchema. This will be calleddeploy_key_idand have the same settings asuser_idother than the description. - Amend the validation rules for
allowed_to_create.access_levelso theExactlyOneOfrule also includes an entry todeploy_key_id. - Add
DeployKeyIDto thegitlabTagProtectionAllowedToObjectModelstruct in the same style asUserID. - In the
Createfunction, add an if block to theAllowedToCreateloop forDeployKeyIDto add the value toallowedToTagsPermissionOptionDataif present. - In the
populateTagAllowedToObjectListfunction, add an if block to setDeployKeyIDinallowedToDataif it has a value. - In
internal/provider/resource_gitlab_protected_tag_test.go, add tests for creating and updating the resource withdeploy_key_id, and checking the validation if it is set alongside one of the fields it conflicts with. - Run
make reviewablebefore raising a merge request.
Edited by 🤖 GitLab Bot 🤖