Skip to content

Allow adding groups and users in gitlab_tag_protection

Created by: r3nic1e

Feature Description

gitlab_tag_protection allows only no one, developer or maintainer as create_access_level. But via GitLab we can set custom groups and users there.

gitlab_branch_protection already supports the same: https://github.com/gitlabhq/terraform-provider-gitlab/pull/556

Do you want to implement this?

  • I would like to implement this myself 👷

Implementation Details

Implementing this issue will require several updates to the resource_gitlab_branch_protection.go file, including:

  • Update the schema block to include two new attributes:
    • group_id, which accepts an integer
    • user_id, which accepts an integer
    • access_level, which accepts an enumerated string that resolved to an integer (I.e., maintainers resolves to 40, developers+maintainers resolves to 30, etc)
  • Adds validation ensuring that group_id and user_id are mutually exclusive, and that when either are present, access_level is provided as well. This can be implemented by creating a new validation function and using it on access_level
  • Updating the CRUD functions to accept the new inputs
  • Creating several tests to ensure that the new values work appropriately, including:
    • create a test using group_id and access_level and ensure it works properly
    • create a test using user_id and access_level and ensure it works properly
    • create a test with both user_id and group_id and ensure it errors properly
    • create a test with user_id, but missing access_level, and ensure it errors properly
Edited by Patrick Rice