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 additional branch policy settings in the terraform provider #255

Conversation

billbirchatcoles
Copy link
Contributor

@billbirchatcoles billbirchatcoles commented Dec 15, 2020

This PR is to add new kinds of permissions to the branch policies.

  • submitter_can_vote - (Optional) Allow requestors to approve their own changes. Defaults to false.
  • last_pusher_cannot_approve(Optional) Prohibit the most recent pusher from approving their own changes. Defaults to false.
  • allow_completion_with_rejects_or_waits (Optional) Allow completion even if some reviewers vote to wait or reject. Defaults to false.
  • on_push_reset_approved_votes (Optional) When new changes are pushed reset all approval votes (does not reset votes to reject or wait). Defaults to false.
  • on_push_reset_all_votes (Optional) When new changes are pushed reset all code reviewer votes. Defaults to false.
  • on_last_iteration_require_vote (Optional) On last iteration require vote. Defaults to false.

All Submissions:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My code follows the code style of this project.
  • I ran lint checks locally prior to submission.
  • Have you checked to ensure there aren't other open PRs for the same update/change?

What about the current behavior has changed?

No changes

Issue Number: #206

Does this introduce a change to go.mod, go.sum or vendor/?

  • Yes
  • No

Does this introduce a breaking change?

  • Yes
  • No

Any relevant logs, error output, etc?

(If it’s long, please paste to https://ghostbin.com/ and insert the link here.)

Other information

@ghost
Copy link

ghost commented Dec 15, 2020

CLA assistant check
All CLA requirements met.

Copy link
Collaborator

@xuzhang3 xuzhang3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@billbirchatcoles azuredevops_branch_policy_auto_reviewers document not updated.

Comment on lines 63 to 72
settings := fmt.Sprintf(
`
reviewer_count = %d
submitter_can_vote = %t
`, reviewers, submitterCanVote,
allow_completion_with_rejects_or_waits = %t
last_pusher_cannot_approve = %t
on_last_iteration_require_vote = %t
on_push_reset_all_votes = %t
on_push_reset_approved_votes = %t
`, reviewers, flag, flag, flag, flag, flag, flag,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since flag was duplicate for 6 times, suggest change to

settings := fmt.Sprintf(
		`
		reviewer_count     = %[1]d
		submitter_can_vote = %[2]t
		allow_completion_with_rejects_or_waits = %[2]t
		last_pusher_cannot_approve = %[2]t
		on_last_iteration_require_vote = %[2]t
		on_push_reset_all_votes = %[2]t
		on_push_reset_approved_votes = %[2]t		
		`, reviewers, flag,
	)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 20 to 22
OnLastIterationRequireVote bool `json:"requireVoteOnLastIteration" tf:"on_last_iteration_require_vote"`
OnPushResetAllVotes bool `json:"resetRejectionsOnSourcePush" tf:"on_push_reset_all_votes"`
LastPusherCannotVote bool `json:"blockLastPusherVote" tf:"last_pusher_cannot_approve"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one of on_push_reset_approved_votes and on_push_reset_all_votes can be set to true at the same time. If set them all to true, on_push_reset_all_votes will eventually take effect. Can we add some checks and block the wrong configurations before send request to service?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

…ops-additional-branch-policy-settings-in-the-terraform-provider
@birchb1024
Copy link

Merged in latest master (3bd4c54). Retested.

…ops-additional-branch-policy-settings-in-the-terraform-provider
@birchb1024
Copy link

Merged in latest master (76e37e7).

@birchb1024
Copy link

Azdo build failed with

=== RUN   TestAccBranchPolicyAutoReviewers_CreateAndUpdate
    testing.go:684: Step 0 error: After applying this step and refreshing, the plan was not empty:

@birchb1024
Copy link

Maybe the min-reviewers test has deleted the '[email protected]' account but that is a wild guess. I can't see the test data...

@xuzhang3
Copy link
Collaborator

Sometimes the tests is unstable, re-run can handle this.

@xuzhang3
Copy link
Collaborator

LGTM

@xuzhang3 xuzhang3 merged commit 4508083 into microsoft:master Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants