From 2c53cdc1907e84664b5571378c3f642e505e68fe Mon Sep 17 00:00:00 2001 From: Ben Zarboni Date: Thu, 7 Mar 2024 16:37:28 -0500 Subject: [PATCH 1/5] feat: add license template support --- modules/private_repository/repository.tf | 1 + modules/private_repository/variables.tf | 8 +++++++- modules/public_repository/repository.tf | 1 + modules/public_repository/variables.tf | 6 ++++++ modules/repository_base/repository.tf | 2 ++ modules/repository_base/variables.tf | 6 ++++++ modules/repository_set/repositories.tf | 2 ++ modules/repository_set/variables.tf | 1 + 8 files changed, 26 insertions(+), 1 deletion(-) diff --git a/modules/private_repository/repository.tf b/modules/private_repository/repository.tf index b1d6310..e95445b 100644 --- a/modules/private_repository/repository.tf +++ b/modules/private_repository/repository.tf @@ -32,4 +32,5 @@ module "repository_base" { environments = var.environments template_repository = var.template_repository + license_template = var.license_template } diff --git a/modules/private_repository/variables.tf b/modules/private_repository/variables.tf index f566d3e..b9a111a 100644 --- a/modules/private_repository/variables.tf +++ b/modules/private_repository/variables.tf @@ -89,11 +89,17 @@ variable "environments" { } variable "template_repository" { - description = "A list of template repositories to use for the repository" + description = "A (Optional) list of template repositories to use for the repository" type = object({ owner = string repository = string include_all_branches = bool }) default = null +} + +variable "license_template" { + description = "The (Optional) license template to use for the repository" + type = string + default = null } \ No newline at end of file diff --git a/modules/public_repository/repository.tf b/modules/public_repository/repository.tf index 9ee5630..7eb7e5e 100644 --- a/modules/public_repository/repository.tf +++ b/modules/public_repository/repository.tf @@ -32,4 +32,5 @@ module "repository_base" { environments = var.environments template_repository = var.template_repository + license_template = var.license_template } \ No newline at end of file diff --git a/modules/public_repository/variables.tf b/modules/public_repository/variables.tf index 7920be8..6f6c740 100644 --- a/modules/public_repository/variables.tf +++ b/modules/public_repository/variables.tf @@ -96,4 +96,10 @@ variable "template_repository" { include_all_branches = bool }) default = null +} + +variable "license_template" { + description = "The (Optional) license template to apply to the repository" + type = string + default = null } \ No newline at end of file diff --git a/modules/repository_base/repository.tf b/modules/repository_base/repository.tf index c2cac64..b67e2a7 100644 --- a/modules/repository_base/repository.tf +++ b/modules/repository_base/repository.tf @@ -25,6 +25,8 @@ resource "github_repository" "repository" { homepage_url = var.homepage delete_branch_on_merge = var.delete_head_on_merge allow_auto_merge = var.allow_auto_merge + license_template = var.license_template + # A hacky way of getting around the 422 errors received from github api dynamic "security_and_analysis" { diff --git a/modules/repository_base/variables.tf b/modules/repository_base/variables.tf index dc33685..f00c23d 100644 --- a/modules/repository_base/variables.tf +++ b/modules/repository_base/variables.tf @@ -150,4 +150,10 @@ variable "template_repository" { include_all_branches = bool }) default = null +} + +variable "license_template" { + description = "The (Optional) license template to use for the repository" + type = string + default = null } \ No newline at end of file diff --git a/modules/repository_set/repositories.tf b/modules/repository_set/repositories.tf index 6b15ea1..af80a83 100644 --- a/modules/repository_set/repositories.tf +++ b/modules/repository_set/repositories.tf @@ -19,6 +19,7 @@ module "public_repositories" { dependabot_secrets = each.value.dependabot_secrets environments = each.value.environments template_repository = each.value.template_repository + license_template = each.value.license_template } module "private_repositories" { @@ -42,4 +43,5 @@ module "private_repositories" { dependabot_secrets = each.value.dependabot_secrets environments = each.value.environments template_repository = each.value.template_repository + license_template = each.value.license_template } diff --git a/modules/repository_set/variables.tf b/modules/repository_set/variables.tf index 692ee9f..9998511 100644 --- a/modules/repository_set/variables.tf +++ b/modules/repository_set/variables.tf @@ -22,6 +22,7 @@ variable "private_repositories" { repository = string include_all_branches = bool })) + license_template = optional(string) })) description = "A map of private repositories where the key is the repository name and the value is the configuration" } From 2ace44947d82e5bd926e07c48457ef1fdf987db7 Mon Sep 17 00:00:00 2001 From: Ben Zarboni Date: Thu, 7 Mar 2024 17:02:32 -0500 Subject: [PATCH 2/5] Missed adding a variable --- modules/repository_set/variables.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/repository_set/variables.tf b/modules/repository_set/variables.tf index 9998511..6bf4bb2 100644 --- a/modules/repository_set/variables.tf +++ b/modules/repository_set/variables.tf @@ -50,6 +50,7 @@ variable "public_repositories" { repository = string include_all_branches = bool })) + license_template = optional(string) })) description = "A map of public repositories where the key is the repository name and the value is the configuration" } From 6cdee3b85dd620a78a7a0ddbfc322642596adf4b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 8 Mar 2024 14:47:27 +0000 Subject: [PATCH 3/5] terraform-docs: automated action --- modules/private_repository/README.md | 3 ++- modules/public_repository/README.md | 1 + modules/repository_base/README.md | 1 + modules/repository_set/README.md | 4 ++-- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/private_repository/README.md b/modules/private_repository/README.md index f810a54..f76df21 100644 --- a/modules/private_repository/README.md +++ b/modules/private_repository/README.md @@ -34,10 +34,11 @@ No resources. | [description](#input\_description) | The description to give to the repository. Defaults to `""` | `string` | `""` | no | | [environments](#input\_environments) | Environments to create for the repository. |
map(object({
action_secrets = optional(map(string))
}))
| `{}` | no | | [homepage](#input\_homepage) | The homepage for the repository | `string` | `""` | no | +| [license\_template](#input\_license\_template) | The (Optional) license template to use for the repository | `string` | `null` | no | | [name](#input\_name) | The name of the repository to create/import. | `string` | n/a | yes | | [protected\_branches](#input\_protected\_branches) | A list of ref names or patterns that should be protected. Defaults `["main"]` | `list(string)` |
[
"main"
]
| no | | [repository\_team\_permissions](#input\_repository\_team\_permissions) | A map where the keys are github team slugs and the value is the permissions the team should have in the repository | `map(string)` | n/a | yes | -| [template\_repository](#input\_template\_repository) | A list of template repositories to use for the repository |
object({
owner = string
repository = string
include_all_branches = bool
})
| `null` | no | +| [template\_repository](#input\_template\_repository) | A (Optional) list of template repositories to use for the repository |
object({
owner = string
repository = string
include_all_branches = bool
})
| `null` | no | | [topics](#input\_topics) | The topics to apply to the repository | `list(string)` | `[]` | no | ## Outputs diff --git a/modules/public_repository/README.md b/modules/public_repository/README.md index a5909d7..102beef 100644 --- a/modules/public_repository/README.md +++ b/modules/public_repository/README.md @@ -34,6 +34,7 @@ No resources. | [description](#input\_description) | The description to give to the repository. Defaults to `""` | `string` | `""` | no | | [environments](#input\_environments) | Environments to create for the repository. |
map(object({
action_secrets = optional(map(string))
}))
| `{}` | no | | [homepage](#input\_homepage) | The homepage for the repository | `string` | `""` | no | +| [license\_template](#input\_license\_template) | The (Optional) license template to apply to the repository | `string` | `null` | no | | [name](#input\_name) | The name of the repository to create/import. | `string` | n/a | yes | | [protected\_branches](#input\_protected\_branches) | A list of ref names or patterns that should be protected. Defaults `["main"]` | `list(string)` |
[
"main"
]
| no | | [repository\_team\_permissions](#input\_repository\_team\_permissions) | A map where the keys are github team slugs and the value is the permissions the team should have in the repository | `map(string)` | n/a | yes | diff --git a/modules/repository_base/README.md b/modules/repository_base/README.md index 2240c6b..eec7ea0 100644 --- a/modules/repository_base/README.md +++ b/modules/repository_base/README.md @@ -51,6 +51,7 @@ No modules. | [has\_vulnerability\_alerts](#input\_has\_vulnerability\_alerts) | Enables security alerts for vulnerable dependencies for the repository | `bool` | `true` | no | | [has\_wiki](#input\_has\_wiki) | Enables Github Wiki for the repository | `bool` | `true` | no | | [homepage](#input\_homepage) | The homepage for the repository | `string` | `""` | no | +| [license\_template](#input\_license\_template) | The (Optional) license template to use for the repository | `string` | `null` | no | | [name](#input\_name) | The name of the repository to create/import. | `string` | n/a | yes | | [protected\_branches](#input\_protected\_branches) | A list of ref names or patterns that should be protected. Setting to `[]` means no protection. Defaults `["~DEFAULT_BRANCH"]` | `list(string)` |
[
"~DEFAULT_BRANCH"
]
| no | | [repository\_team\_permissions](#input\_repository\_team\_permissions) | A map where the keys are github team slugs and the value is the permissions the team should have in the repository | `map(string)` | n/a | yes | diff --git a/modules/repository_set/README.md b/modules/repository_set/README.md index 0584132..ae5af00 100644 --- a/modules/repository_set/README.md +++ b/modules/repository_set/README.md @@ -25,8 +25,8 @@ No resources. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | [default\_repository\_team\_permissions](#input\_default\_repository\_team\_permissions) | A map where the keys are github team slugs and the value is the permissions the team should have by default for every repository. If an entry exists in `repository_team_permissions_override` for a repository then that will take precedence over this default. | `map(string)` | n/a | yes | -| [private\_repositories](#input\_private\_repositories) | A map of private repositories where the key is the repository name and the value is the configuration |
map(object({
description = string
default_branch = string
repository_team_permissions_override = map(string)
protected_branches = list(string)
advance_security = bool
has_vulnerability_alerts = bool
topics = list(string)
homepage = string
delete_head_on_merge = bool
allow_auto_merge = bool
dependabot_security_updates = bool
action_secrets = optional(map(string))
codespace_secrets = optional(map(string))
dependabot_secrets = optional(map(string))
environments = optional(map(object({
action_secrets = optional(map(string))
})))
template_repository = optional(object({
owner = string
repository = string
include_all_branches = bool
}))
}))
| n/a | yes | -| [public\_repositories](#input\_public\_repositories) | A map of public repositories where the key is the repository name and the value is the configuration |
map(object({
description = string
default_branch = string
repository_team_permissions_override = map(string)
protected_branches = list(string)
advance_security = bool
topics = list(string)
homepage = string
delete_head_on_merge = bool
allow_auto_merge = bool
dependabot_security_updates = bool
action_secrets = optional(map(string))
codespace_secrets = optional(map(string))
dependabot_secrets = optional(map(string))
environments = optional(map(object({
action_secrets = optional(map(string))
})))
template_repository = optional(object({
owner = string
repository = string
include_all_branches = bool
}))
}))
| n/a | yes | +| [private\_repositories](#input\_private\_repositories) | A map of private repositories where the key is the repository name and the value is the configuration |
map(object({
description = string
default_branch = string
repository_team_permissions_override = map(string)
protected_branches = list(string)
advance_security = bool
has_vulnerability_alerts = bool
topics = list(string)
homepage = string
delete_head_on_merge = bool
allow_auto_merge = bool
dependabot_security_updates = bool
action_secrets = optional(map(string))
codespace_secrets = optional(map(string))
dependabot_secrets = optional(map(string))
environments = optional(map(object({
action_secrets = optional(map(string))
})))
template_repository = optional(object({
owner = string
repository = string
include_all_branches = bool
}))
license_template = optional(string)
}))
| n/a | yes | +| [public\_repositories](#input\_public\_repositories) | A map of public repositories where the key is the repository name and the value is the configuration |
map(object({
description = string
default_branch = string
repository_team_permissions_override = map(string)
protected_branches = list(string)
advance_security = bool
topics = list(string)
homepage = string
delete_head_on_merge = bool
allow_auto_merge = bool
dependabot_security_updates = bool
action_secrets = optional(map(string))
codespace_secrets = optional(map(string))
dependabot_secrets = optional(map(string))
environments = optional(map(object({
action_secrets = optional(map(string))
})))
template_repository = optional(object({
owner = string
repository = string
include_all_branches = bool
}))
license_template = optional(string)
}))
| n/a | yes | ## Outputs From de1dfea4c9936935a75dff0713ced49f24a9f93b Mon Sep 17 00:00:00 2001 From: Ben Zarboni Date: Fri, 8 Mar 2024 09:49:05 -0500 Subject: [PATCH 4/5] fix: Variable description inconsistency --- modules/public_repository/variables.tf | 2 +- modules/repository_base/variables.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/public_repository/variables.tf b/modules/public_repository/variables.tf index 6f6c740..3e84e32 100644 --- a/modules/public_repository/variables.tf +++ b/modules/public_repository/variables.tf @@ -89,7 +89,7 @@ variable "environments" { } variable "template_repository" { - description = "A list of template repositories to use for the repository" + description = "A (Optional) list of template repositories to use for the repository" type = object({ owner = string repository = string diff --git a/modules/repository_base/variables.tf b/modules/repository_base/variables.tf index f00c23d..a9a2f0d 100644 --- a/modules/repository_base/variables.tf +++ b/modules/repository_base/variables.tf @@ -143,7 +143,7 @@ variable "environments" { } variable "template_repository" { - description = "A list of template repositories to use for the repository" + description = "A (Optional) list of template repositories to use for the repository" type = object({ owner = string repository = string From 3d5c3bf829f39bc479cd7213ec92560c7f65c069 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 8 Mar 2024 14:49:47 +0000 Subject: [PATCH 5/5] terraform-docs: automated action --- modules/public_repository/README.md | 2 +- modules/repository_base/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/public_repository/README.md b/modules/public_repository/README.md index 102beef..2b1af93 100644 --- a/modules/public_repository/README.md +++ b/modules/public_repository/README.md @@ -38,7 +38,7 @@ No resources. | [name](#input\_name) | The name of the repository to create/import. | `string` | n/a | yes | | [protected\_branches](#input\_protected\_branches) | A list of ref names or patterns that should be protected. Defaults `["main"]` | `list(string)` |
[
"main"
]
| no | | [repository\_team\_permissions](#input\_repository\_team\_permissions) | A map where the keys are github team slugs and the value is the permissions the team should have in the repository | `map(string)` | n/a | yes | -| [template\_repository](#input\_template\_repository) | A list of template repositories to use for the repository |
object({
owner = string
repository = string
include_all_branches = bool
})
| `null` | no | +| [template\_repository](#input\_template\_repository) | A (Optional) list of template repositories to use for the repository |
object({
owner = string
repository = string
include_all_branches = bool
})
| `null` | no | | [topics](#input\_topics) | The topics to apply to the repository | `list(string)` | `[]` | no | ## Outputs diff --git a/modules/repository_base/README.md b/modules/repository_base/README.md index eec7ea0..c5d93de 100644 --- a/modules/repository_base/README.md +++ b/modules/repository_base/README.md @@ -57,7 +57,7 @@ No modules. | [repository\_team\_permissions](#input\_repository\_team\_permissions) | A map where the keys are github team slugs and the value is the permissions the team should have in the repository | `map(string)` | n/a | yes | | [secret\_scanning](#input\_secret\_scanning) | Enables secret scanning for the repository. If repository is private `advance_security` must also be enabled. | `bool` | `true` | no | | [secret\_scanning\_on\_push](#input\_secret\_scanning\_on\_push) | Enables secret scanning push protection for the repository. If repository is private `advance_security` must also be enabled. | `bool` | `true` | no | -| [template\_repository](#input\_template\_repository) | A list of template repositories to use for the repository |
object({
owner = string
repository = string
include_all_branches = bool
})
| `null` | no | +| [template\_repository](#input\_template\_repository) | A (Optional) list of template repositories to use for the repository |
object({
owner = string
repository = string
include_all_branches = bool
})
| `null` | no | | [topics](#input\_topics) | The topics to apply to the repository | `list(string)` | `[]` | no | | [visibility](#input\_visibility) | Sets the visibility property of a repository. Defaults to "private" | `string` | `"private"` | no |