Skip to content

Commit

Permalink
Merge pull request #3 from schubergphilis/modify-settings
Browse files Browse the repository at this point in the history
feature: update module settings
  • Loading branch information
marwinbaumannsbp authored Jan 30, 2024
2 parents 0e74090 + b4c7678 commit 1acde9c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ IMPORTANT: We do not pin modules to versions in our examples. We highly recommen

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |

## Providers

Expand All @@ -36,12 +36,13 @@ No modules.
| <a name="input_name"></a> [name](#input\_name) | The name of the project | `string` | n/a | yes |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | The namespace (group or user) of the project | `string` | n/a | yes |
| <a name="input_approvals_before_merge"></a> [approvals\_before\_merge](#input\_approvals\_before\_merge) | Number of merge request approvals required for merging | `number` | `1` | no |
| <a name="input_branch_protection"></a> [branch\_protection](#input\_branch\_protection) | Branch protection settings | <pre>map(object({<br> push_access_level = string<br> merge_access_level = string<br> code_owner_approval_required = bool<br> }))</pre> | `null` | no |
| <a name="input_default_branch"></a> [default\_branch](#input\_default\_branch) | The default branch for the project | `string` | `"master"` | no |
| <a name="input_branch_protection"></a> [branch\_protection](#input\_branch\_protection) | Branch protection settings | <pre>map(object({<br> push_access_level = optional(string, "no one")<br> merge_access_level = optional(string, "developer")<br> code_owner_approval_required = optional(bool, false)<br> }))</pre> | `{}` | no |
| <a name="input_default_branch"></a> [default\_branch](#input\_default\_branch) | The default branch for the project | `string` | `"main"` | no |
| <a name="input_description"></a> [description](#input\_description) | A description for the GitLab project | `string` | `null` | no |
| <a name="input_initialize_with_readme"></a> [initialize\_with\_readme](#input\_initialize\_with\_readme) | Create default branch with first commit containing a README.md file | `bool` | `true` | no |
| <a name="input_issues_enabled"></a> [issues\_enabled](#input\_issues\_enabled) | Enable issue tracking for the project | `bool` | `false` | no |
| <a name="input_snippets_enabled"></a> [snippets\_enabled](#input\_snippets\_enabled) | Enable snippets for the project | `bool` | `false` | no |
| <a name="input_use_group_settings"></a> [use\_group\_settings](#input\_use\_group\_settings) | Ignore settings that can also be set on a group level to prevent conflicts | `bool` | `false` | no |
| <a name="input_visibility"></a> [visibility](#input\_visibility) | Set the GitLab project as public, private or internal | `string` | `"private"` | no |
| <a name="input_wiki_enabled"></a> [wiki\_enabled](#input\_wiki\_enabled) | Enable wiki for the project | `bool` | `false` | no |

Expand Down
5 changes: 3 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data "gitlab_group" "default" {

resource "gitlab_project" "default" {
name = var.name
approvals_before_merge = var.approvals_before_merge
approvals_before_merge = var.use_group_settings ? null : var.approvals_before_merge
default_branch = var.default_branch
description = var.description
initialize_with_readme = var.initialize_with_readme
Expand All @@ -26,7 +26,8 @@ resource "gitlab_project" "default" {
}

resource "gitlab_branch_protection" "default" {
for_each = local.branch_protection
for_each = local.branch_protection

project = gitlab_project.default.id
branch = each.key
push_access_level = each.value.push_access_level
Expand Down
16 changes: 11 additions & 5 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ variable "approvals_before_merge" {

variable "branch_protection" {
type = map(object({
push_access_level = string
merge_access_level = string
code_owner_approval_required = bool
push_access_level = optional(string, "no one")
merge_access_level = optional(string, "developer")
code_owner_approval_required = optional(bool, false)
}))
default = null
default = {}
description = "Branch protection settings"
}

variable "default_branch" {
type = string
default = "master"
default = "main"
description = "The default branch for the project"
}

Expand Down Expand Up @@ -54,6 +54,12 @@ variable "snippets_enabled" {
description = "Enable snippets for the project"
}

variable "use_group_settings" {
type = bool
default = false
description = "Ignore settings that can also be set on a group level to prevent conflicts"
}

variable "visibility" {
type = string
default = "private"
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ terraform {
source = "gitlabhq/gitlab"
}
}
required_version = ">= 0.13"
required_version = ">= 1.3.0"
}

0 comments on commit 1acde9c

Please sign in to comment.