Skip to content

Commit d008758

Browse files
Add internal_repository (#59)
* feat: add module for internal repo * feat: add internal repositories to repository_set * terraform-docs: automated action * feat: set a default value of {} for internal_repositories * terraform-docs: automated action --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 106d9b7 commit d008758

12 files changed

Lines changed: 661 additions & 6 deletions
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
## Requirements
2+
3+
| Name | Version |
4+
|------|---------|
5+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.6 |
6+
| <a name="requirement_github"></a> [github](#requirement\_github) | ~> 6.0 |
7+
8+
## Providers
9+
10+
No providers.
11+
12+
## Modules
13+
14+
| Name | Source | Version |
15+
|------|--------|---------|
16+
| <a name="module_repository_base"></a> [repository\_base](#module\_repository\_base) | ../repository_base | n/a |
17+
18+
## Resources
19+
20+
No resources.
21+
22+
## Inputs
23+
24+
| Name | Description | Type | Default | Required |
25+
|------|-------------|------|---------|:--------:|
26+
| <a name="input_action_secrets"></a> [action\_secrets](#input\_action\_secrets) | An (Optional) map of GitHub Actions secrets to create for this repository. The key is the name of the secret and the value is the encrypted value. | `map(string)` | `{}` | no |
27+
| <a name="input_advance_security"></a> [advance\_security](#input\_advance\_security) | Enables advance security for the repository. If repository is public `advance_security` is enabled by default and cannot be changed. | `bool` | `true` | no |
28+
| <a name="input_allow_auto_merge"></a> [allow\_auto\_merge](#input\_allow\_auto\_merge) | Allow auto-merging pull requests on the repository | `bool` | `true` | no |
29+
| <a name="input_allow_merge_commit"></a> [allow\_merge\_commit](#input\_allow\_merge\_commit) | (Optional) Set to `false` to disable merge commits on the repository. | `bool` | `true` | no |
30+
| <a name="input_allow_rebase_merge"></a> [allow\_rebase\_merge](#input\_allow\_rebase\_merge) | (Optional) Set to `false` to disable rebase merges on the repository. | `bool` | `true` | no |
31+
| <a name="input_allow_squash_merge"></a> [allow\_squash\_merge](#input\_allow\_squash\_merge) | (Optional) Set to `false` to disable squash merges on the repository. | `bool` | `true` | no |
32+
| <a name="input_codespace_secrets"></a> [codespace\_secrets](#input\_codespace\_secrets) | An (Optional) map of GitHub Codespace secrets to create for this repository. The key is the name of the secret and the value is the encrypted value. | `map(string)` | `{}` | no |
33+
| <a name="input_default_branch"></a> [default\_branch](#input\_default\_branch) | The branch to set as the default branch for this repository. Defaults to "main" | `string` | `"main"` | no |
34+
| <a name="input_delete_head_on_merge"></a> [delete\_head\_on\_merge](#input\_delete\_head\_on\_merge) | Sets the delete head on merge option for the repository. If true it will delete pull request branches automatically on merge. Defaults to true | `bool` | `true` | no |
35+
| <a name="input_dependabot_secrets"></a> [dependabot\_secrets](#input\_dependabot\_secrets) | An (Optional) map of Dependabot secrets to create for this repository. The key is the name of the secret and the value is the encrypted value. | `map(string)` | `{}` | no |
36+
| <a name="input_dependabot_security_updates"></a> [dependabot\_security\_updates](#input\_dependabot\_security\_updates) | Enables dependabot security updates. Only works when `has_vulnerability_alerts` is set because that is required to enable dependabot for the repository. | `bool` | `true` | no |
37+
| <a name="input_description"></a> [description](#input\_description) | The description to give to the repository. Defaults to `""` | `string` | `""` | no |
38+
| <a name="input_environments"></a> [environments](#input\_environments) | Environments to create for the repository. | <pre>map(object({<br/> wait_timer = optional(number)<br/> can_admins_bypass = optional(bool)<br/> prevent_self_review = optional(bool)<br/> action_secrets = optional(map(string))<br/> reviewers = optional(object({<br/> teams = optional(list(string))<br/> users = optional(list(string))<br/> }))<br/> deployment_branch_policy = optional(object({<br/> protected_branches = bool<br/> custom_branch_policies = bool<br/> branch_patterns = list(string)<br/> }))<br/> }))</pre> | `{}` | no |
39+
| <a name="input_homepage"></a> [homepage](#input\_homepage) | The homepage for the repository | `string` | `""` | no |
40+
| <a name="input_license_template"></a> [license\_template](#input\_license\_template) | The (Optional) license template to apply to the repository | `string` | `null` | no |
41+
| <a name="input_merge_commit_message"></a> [merge\_commit\_message](#input\_merge\_commit\_message) | (Optional) Can be `PR_BODY`, `PR_TITLE`, or `BLANK` for a default merge commit message. Applicable only if allow\_merge\_commit is `true`. | `string` | `"PR_TITLE"` | no |
42+
| <a name="input_merge_commit_title"></a> [merge\_commit\_title](#input\_merge\_commit\_title) | (Optional) Can be `PR_TITLE` or `MERGE_MESSAGE` for a default merge commit title. Applicable only if allow\_merge\_commit is `true`. | `string` | `"MERGE_MESSAGE"` | no |
43+
| <a name="input_name"></a> [name](#input\_name) | The name of the repository to create/import. | `string` | n/a | yes |
44+
| <a name="input_pages"></a> [pages](#input\_pages) | The (Optional) configuration for GitHub Pages for the repository | <pre>object({<br/> source = optional(object({<br/> branch = string<br/> path = optional(string)<br/> }))<br/> build_type = optional(string)<br/> cname = optional(string)<br/> })</pre> | `null` | no |
45+
| <a name="input_protected_branches"></a> [protected\_branches](#input\_protected\_branches) | A list of ref names or patterns that should be protected. Defaults `["main"]` | `list(string)` | <pre>[<br/> "main"<br/>]</pre> | no |
46+
| <a name="input_repository_team_permissions"></a> [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 |
47+
| <a name="input_repository_user_permissions"></a> [repository\_user\_permissions](#input\_repository\_user\_permissions) | A map where the keys are github usernames and the value is the permissions the user should have in the repository | `map(string)` | n/a | yes |
48+
| <a name="input_requires_web_commit_signing"></a> [requires\_web\_commit\_signing](#input\_requires\_web\_commit\_signing) | If set commit signatures are required for commits to the organization. Defaults to `false`. | `bool` | `false` | no |
49+
| <a name="input_rulesets"></a> [rulesets](#input\_rulesets) | n/a | <pre>map(object({<br/> bypass_actors = optional(object({<br/> repository_roles = optional(list(object({<br/> role = string<br/> always_bypass = optional(bool)<br/> })))<br/> teams = optional(list(object({<br/> team = string<br/> always_bypass = optional(bool)<br/> })))<br/> integrations = optional(list(object({<br/> installation_id = number<br/> always_bypass = optional(bool)<br/> })))<br/> organization_admins = optional(list(object({<br/> user = string<br/> always_bypass = optional(bool)<br/> })))<br/> }))<br/> conditions = optional(object({<br/> ref_name = object({<br/> include = list(string)<br/> exclude = list(string)<br/> })<br/> }))<br/> rules = object({<br/> branch_name_pattern = optional(object({<br/> operator = string<br/> pattern = string<br/> name = optional(string)<br/> negate = optional(bool)<br/> }))<br/> tag_name_pattern = optional(object({<br/> operator = string<br/> pattern = string<br/> name = optional(string)<br/> negate = optional(bool)<br/> }))<br/> commit_author_email_pattern = optional(object({<br/> operator = string<br/> pattern = string<br/> name = optional(string)<br/> negate = optional(bool)<br/> }))<br/> commit_message_pattern = optional(object({<br/> operator = string<br/> pattern = string<br/> name = optional(string)<br/> negate = optional(bool)<br/> }))<br/> committer_email_pattern = optional(object({<br/> operator = string<br/> pattern = string<br/> name = optional(string)<br/> negate = optional(bool)<br/> }))<br/> creation = optional(bool)<br/> deletion = optional(bool)<br/> update = optional(bool)<br/> non_fast_forward = optional(bool)<br/> required_linear_history = optional(bool)<br/> required_signatures = optional(bool)<br/> update_allows_fetch_and_merge = optional(bool)<br/> pull_request = optional(object({<br/> dismiss_stale_reviews_on_push = optional(bool)<br/> require_code_owner_review = optional(bool)<br/> require_last_push_approval = optional(bool)<br/> required_approving_review_count = optional(number)<br/> required_review_thread_resolution = optional(bool)<br/> }))<br/> required_status_checks = optional(object({<br/> required_check = list(object({<br/> context = string<br/> integration_id = optional(number)<br/> }))<br/> strict_required_status_check_policy = optional(bool)<br/> }))<br/> required_deployment_environments = optional(list(string))<br/> })<br/> target = string<br/> enforcement = string<br/> }))</pre> | `{}` | no |
50+
| <a name="input_squash_merge_commit_message"></a> [squash\_merge\_commit\_message](#input\_squash\_merge\_commit\_message) | (Optional) Can be `PR_BODY`, `COMMIT_MESSAGES`, or `BLANK` for a default squash merge commit message. Applicable only if allow\_squash\_merge is `true`. | `string` | `"PR_BODY"` | no |
51+
| <a name="input_squash_merge_commit_title"></a> [squash\_merge\_commit\_title](#input\_squash\_merge\_commit\_title) | (Optional) Can be `PR_TITLE` or `COMMIT_OR_PR_TITLE` for a default squash merge commit title. Applicable only if allow\_squash\_merge is `true`. | `string` | `"PR_TITLE"` | no |
52+
| <a name="input_template_repository"></a> [template\_repository](#input\_template\_repository) | A (Optional) list of template repositories to use for the repository | <pre>object({<br/> owner = string<br/> repository = string<br/> include_all_branches = bool<br/> })</pre> | `null` | no |
53+
| <a name="input_topics"></a> [topics](#input\_topics) | The topics to apply to the repository | `list(string)` | `[]` | no |
54+
55+
## Outputs
56+
57+
| Name | Description |
58+
|------|-------------|
59+
| <a name="output_id"></a> [id](#output\_id) | The ID of the repository |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "id" {
2+
value = module.repository_base.id
3+
description = "The ID of the repository"
4+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
module "repository_base" {
2+
source = "../repository_base"
3+
4+
name = var.name
5+
description = var.description
6+
homepage = var.homepage
7+
topics = var.topics
8+
visibility = "internal"
9+
has_downloads = false
10+
has_issues = true
11+
has_projects = true
12+
has_wiki = true
13+
has_discussions = true
14+
15+
repository_team_permissions = var.repository_team_permissions
16+
repository_user_permissions = var.repository_user_permissions
17+
18+
default_branch = var.default_branch
19+
protected_branches = var.protected_branches
20+
delete_head_on_merge = var.delete_head_on_merge
21+
allow_auto_merge = var.allow_auto_merge
22+
allow_merge_commit = var.allow_merge_commit
23+
allow_rebase_merge = var.allow_rebase_merge
24+
allow_squash_merge = var.allow_squash_merge
25+
squash_merge_commit_message = var.squash_merge_commit_message
26+
squash_merge_commit_title = var.squash_merge_commit_title
27+
merge_commit_message = var.merge_commit_message
28+
merge_commit_title = var.merge_commit_title
29+
requires_web_commit_signing = var.requires_web_commit_signing
30+
pages = var.pages
31+
32+
secret_scanning = true
33+
secret_scanning_on_push = true
34+
has_vulnerability_alerts = true
35+
advance_security = var.advance_security
36+
dependabot_security_updates = var.dependabot_security_updates
37+
38+
codespace_secrets = var.codespace_secrets
39+
dependabot_secrets = var.dependabot_secrets
40+
action_secrets = var.action_secrets
41+
42+
environments = var.environments
43+
44+
template_repository = var.template_repository
45+
license_template = var.license_template
46+
47+
rulesets = var.rulesets
48+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
mock_provider "github" {}
2+
3+
variables {
4+
name = "github-foundations-modules"
5+
description = "A collection of terraform modules used in the Github Foundations framework."
6+
visibility = "internal"
7+
has_downloads = true
8+
has_issues = true
9+
has_projects = true
10+
has_wiki = true
11+
has_discussions = true
12+
has_vulnerability_alerts = true
13+
topics = ["terraform", "github", "foundations"]
14+
homepage = "myhomepage"
15+
delete_head_on_merge = false
16+
allow_auto_merge = true
17+
allow_squash_merge = false
18+
squash_merge_commit_message = "COMMIT_MESSAGES"
19+
squash_merge_commit_title = "COMMIT_OR_PR_TITLE"
20+
allow_merge_commit = false
21+
merge_commit_message = "PR_BODY"
22+
merge_commit_title = "PR_TITLE"
23+
allow_rebase_merge = true
24+
requires_web_commit_signing = false
25+
license_template = "mit"
26+
dependabot_security_updates = true
27+
advance_security = true
28+
secret_scanning = true
29+
secret_scanning_on_push = true
30+
31+
default_branch = "main"
32+
protected_branches = ["main", "develop"]
33+
34+
template_repository = {
35+
owner = "owner"
36+
repository = "template_repository"
37+
include_all_branches = true
38+
}
39+
40+
pages = {
41+
source = {
42+
branch = "main"
43+
path = "path"
44+
}
45+
cname = "cname"
46+
}
47+
48+
repository_team_permissions = {
49+
"repo_team1" = "push"
50+
"repo_team2" = "admin"
51+
}
52+
repository_user_permissions = {
53+
"user1" = "push"
54+
"user2" = "admin"
55+
}
56+
}
57+
58+
run "create_test" {
59+
command = apply
60+
61+
assert {
62+
condition = module.repository_base.id != null
63+
error_message = "The repository was not created"
64+
}
65+
}

0 commit comments

Comments
 (0)