Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azuredevops_branch_policy_auto_reviewers auto_reviewer_ids value #281

Closed
skarlupka opened this issue Jan 27, 2021 · 3 comments
Closed

azuredevops_branch_policy_auto_reviewers auto_reviewer_ids value #281

skarlupka opened this issue Jan 27, 2021 · 3 comments
Labels

Comments

@skarlupka
Copy link

The azuredevops_branch_policy_auto_reviewers resource has an auto_reviewer_ids setting. This setting doesn't work with the user.descriptor field like many of the other resources do in the provider. When using a descriptor the output complains that the descriptor can't be turned in to a System.GUID type. The azuredevops_users data type provides an origin_id field, but using this value throws a GUID's must be the identity of an individual or a group. error. Can the auto_reviewer_ids be updated to accept descriptors?

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and Azure DevOps Provider) Version

Terraform v0.14.3

  • provider registry.terraform.io/microsoft/azuredevops v0.1.1

Affected Resource(s)

  • azuredevops_branch_policy_auto_reviewers

Terraform Configuration Files

resource "azuredevops_branch_policy_auto_reviewers" "main" {
  project_id = var.project-id

  enabled  = true
  blocking = true

  settings {
    auto_reviewer_ids  = [ 
      tolist(data.azuredevops_users.foo.users)[0].descriptor
    ]
    submitter_can_vote = false
    message            = "Auto reviewer"

    scope {
      repository_id  = azuredevops_git_repository.repo.id
      repository_ref = azuredevops_git_repository.repo.default_branch
      match_type     = "Exact"
    }
  }
}

Debug Output

Error creating policy in Azure DevOps: TF402457: The settings for this policy are not correctly formatted. Error: Error converting value "" to type 'System.Guid'. Path 'requiredReviewerIds[0]', line 6, position 151.

Expected Behavior

The auto reviewer should have been added to the branch policy

Actual Behavior

Error creating policy in Azure DevOps: TF402457: The settings for this policy are not correctly formatted. Error: Error converting value "" to type 'System.Guid'. Path 'requiredReviewerIds[0]', line 6, position 151.

Steps to Reproduce

  1. terraform apply
  • #0000
@xuzhang3
Copy link
Collaborator

Hi @skarlupka azuredevops_users.origin_id is the origin user ID, if user is from AAD, the origin_id is AAD ID, devops cannot find the user by AAD ID. Auto reviews IDs cannot use descriptor, it is limited to GUID by service. In your scenario, you can use the group as the reviews.
Example:

data "azuredevops_group" "admin" {
  project_id = data.azuredevops_project.project.id
  name = "Build Administrators"

}
data "azuredevops_git_repository" "repo" {
  project_id = data.azuredevops_project.project.id
  name = "ADOTest"
}

resource "azuredevops_branch_policy_auto_reviewers" "repo" {
  project_id = data.azuredevops_project.project.id

  enabled = true
  blocking = true

  settings {
    auto_reviewer_ids = [
      data.azuredevops_group.admin.origin_id
    ]

    submitter_can_vote = true
    message = "Auto reviewer"

    scope {
      repository_id = data.azuredevops_git_repository.repo.id
      repository_ref = data.azuredevops_git_repository.repo.default_branch
      match_type = "Exact"
    }
  }
}

image

@skarlupka
Copy link
Author

@xuzhang3 Thank you so much for the detailed explanation. Your suggestion worked!

@meizenga
Copy link

meizenga commented Jun 7, 2023

@xuzhang3 working! thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants