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

breaking: create and set branch configuration using var.branches #61

Merged
merged 4 commits into from
May 7, 2024

Conversation

shoekstra
Copy link
Member

@shoekstra shoekstra commented Oct 27, 2023

var.branches has been introduced to explicitly create branches, optionally from a source branch or SHA, and configure any branch protection rules.

Before this, we relied on implicitly specifying branches via var.branch_protection which a) didn't allow us to specify where the branch starts from and b) could cause problems if changing the default branch, where Terraform would try to destroy the existing default branch instead of just setting a new default.

This commit also implements some default values for branch protection:

  • enforce_admins defaults to false
  • required_approving_review_count defaults to 2
  • require_code_owner_reviews defaults to true
  • require_signed_commits defaults to true

Also moved tests to the test directory seeing as we cannot reuse modules for testing right now, so may as well use the default location for terraform test.

Signed-off-by: Stephen Hoekstra shoekstra@schubergphilis.com

@shoekstra shoekstra requested a review from a team as a code owner October 27, 2023 09:35
@github-actions
Copy link
Contributor

github-actions bot commented Oct 27, 2023

Terraform Format and Style 🖌success

Terraform Initialization ⚙️``

Terraform Lint 📖success

Terraform Validation 🤖skipped

Validation Output


@marwinbaumannsbp marwinbaumannsbp added the breaking This change is not backwards compatible label Oct 27, 2023
@marwinbaumannsbp marwinbaumannsbp changed the title Create and set branch configuration using var.branches breaking: create and set branch configuration using var.branches Oct 27, 2023
variables.tf Outdated Show resolved Hide resolved
@fatbasstard
Copy link
Contributor

@shoekstra Can you add in the V6 provider support?

Copy link
Contributor

@marwinbaumannsbp marwinbaumannsbp left a comment

Choose a reason for hiding this comment

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

  • Can you update the UPGRADING.md? With a bit of guidance how to change your variables to make it work with v1.0.0?
  • Is some kind of state move needed?
  • Where is the output of terraform test or an example plan?

variables.tf Show resolved Hide resolved
variables.tf Show resolved Hide resolved
@shoekstra
Copy link
Member Author

@shoekstra Can you add in the V6 provider support?

Done ✅

@shoekstra shoekstra force-pushed the add_branches_var branch 3 times, most recently from 2659dd1 to d861461 Compare April 4, 2024 13:07
fatbasstard
fatbasstard previously approved these changes Apr 8, 2024
require_signed_commits = optional(bool, false)

required_checks = optional(object({
strict = optional(bool)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we default this as well? (It's false)

`var.branches` has been introduced to explicitly create branches,
optionally from a source branch or SHA, and configure any branch
protection rules.

Before this, we relied on implicitly specifying branches via
`var.branch_protection` which a) didn't allow us to specify where the
branch starts from and b) could cause problems if changing the default
branch, where Terraform would try to destroy the existing default branch
instead of just setting a new default.

This commit also implements some default values for branch protection:
* `enforce_admins` defaults to `false`
* `required_approving_review_count` defaults to `2`
* `require_code_owner_reviews` defaults to `true`

Also moved tests to the `test` directory seeing as we cannot reuse
modules for testing right now, so may as well use the default location
for `terraform test`.

Signed-off-by: Stephen Hoekstra <shoekstra@schubergphilis.com>
…opulated

This is a more intuitive approach, previously you still needed to set
`use_default_branch_protection` to `false` which this commit fixes so
it's more natural to use.

Now you need to specify `use_branch_protection = false` to really opt
out of branch protection for your branch.

Signed-off-by: Stephen Hoekstra <shoekstra@schubergphilis.com>
Also fixed some checkov warnings, including setting required signed
commits to true.

Signed-off-by: Stephen Hoekstra <shoekstra@schubergphilis.com>
@shoekstra shoekstra merged commit 40b63b5 into master May 7, 2024
@shoekstra shoekstra deleted the add_branches_var branch May 7, 2024 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking This change is not backwards compatible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants