diff --git a/README.md b/README.md
index 832a95e..acd6132 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@ It's Open Source and licensed under the [APACHE2](LICENSE).
## Components
-- [GitHub Repositories](./github-repositories/README.md): responsible for managing GitHub repositories, including permissions, webhooks, pages, etc.
+- [GitHub Repositories](./components/github-repositories/README.md): responsible for managing GitHub repositories, including permissions, webhooks, pages, etc.
## Trunk Linter
diff --git a/github-repositories/README.md b/components/github-repositories/README.md
similarity index 90%
rename from github-repositories/README.md
rename to components/github-repositories/README.md
index 8a4da73..3d5ca03 100644
--- a/github-repositories/README.md
+++ b/components/github-repositories/README.md
@@ -54,6 +54,18 @@ module "gh_repos" {
}
```
+### Known Issues
+
+You may encounter the following error during import:
+
+```sh
+Cannot import non-existent remote object
+```
+
+To overcome this, set the required environment variables to authenticate with GitHub API depending on the way you've chosen, e.g. `GITHUB_TOKEN` and `GITHUB_OWNER`.
+
+Corresponding `integrations/terraform-provider-github` GitHub issue: [#647](https://github.com/integrations/terraform-provider-github/issues/647).
+
## Requirements
@@ -81,16 +93,16 @@ No resources.
## Inputs
-| Name | Description | Type | Default | Required |
-| --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | :------: |
-| [gh_app_auth_id](#input_gh_app_auth_id) | The ID of the GitHub App. | `string` | `""` | no |
-| [gh_app_auth_installation_id](#input_gh_app_auth_installation_id) | The ID of the GitHub App installation | `string` | `""` | no |
-| [gh_app_auth_pem_file_secret_name](#input_gh_app_auth_pem_file_secret_name) | The name of the secret retrieved by secrets mixin that contains
the contents of the GitHub App private key PEM file. | `string` | `null` | no |
-| [gh_base_url](#input_gh_base_url) | (Optional) This is the target GitHub base API endpoint.
Providing a value is a requirement when working with GitHub Enterprise.
It is optional to provide this value and it can also be sourced from the GITHUB_BASE_URL environment variable.
The value must end with a slash. | `string` | `null` | no |
-| [gh_owner](#input_gh_owner) | (Optional) This is the target GitHub organization or individual user account to manage.
For example, `torvalds` and `github` are valid owners. It is optional to provide this value
and it can also be sourced from the GITHUB_OWNER environment variable.
When not provided and a token is available, the individual user account owning the token will be used.
When not provided and no token is available, the provider may not function correctly. | `string` | `null` | no |
-| [gh_token_secret_name](#input_gh_token_secret_name) | The name of the secret retrieved by secrets mixin that contains the GitHub personal access token. | `string` | `null` | no |
-| [repos](#input_repos) | The GitHub repositories for this organization. |
map(object({| `{}` | no | -| [secret_mapping](#input_secret_mapping) | The list of secret mappings the application will need.
# Main Resource Configuration
# https://github.com/mineiros-io/terraform-github-repository/tree/main#main-resource-configuration
allow_auto_merge = optional(bool, false)
allow_merge_commit = optional(bool, true)
allow_rebase_merge = optional(bool, false)
allow_squash_merge = optional(bool, false)
archive_on_destroy = optional(bool, true)
archived = optional(bool, false)
default_branch = optional(string, null)
description = optional(string, "")
extra_topics = optional(list(string), [])
has_downloads = optional(bool, false)
has_issues = optional(bool, false)
has_projects = optional(bool, false)
has_wiki = optional(bool, false)
homepage_url = optional(string, "")
is_template = optional(bool, false)
pages = optional(object({
branch = string
cname = optional(string, null)
path = optional(string, "/")
}))
topics = optional(list(string), [])
visibility = optional(string, "private")
vulnerability_alerts = optional(bool, false)
# Extended Resource Configuration
## Repository Creation Configuration
# https://github.com/mineiros-io/terraform-github-repository/tree/main#repository-creation-configuration
auto_init = optional(bool, true)
gitignore_template = optional(string, "")
license_template = optional(string, "")
template = optional(object({
owner = string
repository = string
}))
## Teams Configuration
# https://github.com/mineiros-io/terraform-github-repository/tree/main#teams-configuration
admin_teams = optional(list(string), [])
maintain_teams = optional(list(string), [])
pull_teams = optional(list(string), [])
push_teams = optional(list(string), [])
triage_teams = optional(list(string), [])
## Collaborator Configuration
# https://github.com/mineiros-io/terraform-github-repository/tree/main#collaborator-configuration
admin_collaborators = optional(list(string), [])
maintain_collaborators = optional(list(string), [])
pull_collaborators = optional(list(string), [])
push_collaborators = optional(list(string), [])
triage_collaborators = optional(list(string), [])
## Branches Configuration
# https://github.com/mineiros-io/terraform-github-repository/tree/main#branches-configuration
branches = optional(list(object({
name = string
source_branch = optional(string, null)
source_sha = optional(bool, null)
})), [])
## Deploy Keys Configuration
# https://github.com/mineiros-io/terraform-github-repository/tree/main#deploy-keys-configuration
deploy_keys = optional(list(object({
id = optional(string, "md5(key)")
key = string
read_only = optional(bool, true)
title = optional(string, null)
})), [])
deploy_keys_computed = optional(list(object({
id = optional(string, "md5(key)")
key = string
read_only = optional(bool, true)
title = optional(string, null)
})), [])
## Branch Protections v4 Configuration
# https://github.com/mineiros-io/terraform-github-repository/tree/main#branch-protections-v4-configuration
branch_protections_v4 = optional(list(object({
pattern = string
\_key = optional(string)
allows_deletions = optional(bool, false)
allows_force_pushes = optional(bool, false)
blocks_creations = optional(bool, false)
enforce_admins = optional(bool, true)
push_restrictions = optional(list(string), [])
require_conversation_resolution = optional(bool, false)
require_signed_commits = optional(bool, false)
required_linear_history = optional(bool, false)
required_pull_request_reviews = optional(list(object({
dismiss_stale_reviews = optional(bool, true)
restrict_dismissals = optional(bool, false)
dismissal_restrictions = optional(list(string), [])
pull_request_bypassers = optional(list(string), [])
require_code_owner_reviews = optional(bool, true)
required_approving_review_count = optional(number, 1)
})), [])
required_status_checks = optional(list(object({
strict = optional(bool, false)
contexts = optional(list(string), [])
})), [])
})), [])
## Issue Labels Configuration
# https://github.com/mineiros-io/terraform-github-repository/tree/main#issue-labels-configuration
issue_labels = optional(list(object({
color = string
description = optional(string, null)
id = optional(string, "name")
name = string
})), [])
issue_labels_merge_with_github_labels = optional(bool)
issue_labels_create = optional(bool)
## Projects Configuration
# https://github.com/mineiros-io/terraform-github-repository/tree/main#projects-configuration
projects = optional(list(object({
body = optional(string, "")
id = optional(string, "name")
name = string
})), [])
## Webhooks Configuration
# https://github.com/mineiros-io/terraform-github-repository/tree/main#webhooks-configuration
webhooks = optional(list(object({
active = optional(bool, true)
content_type = optional(string, "form")
insecure_ssl = optional(bool, false)
events = list(string)
name = optional(string)
secret = optional(string)
url = string
})), [])
## Secrets Configuration
# https://github.com/mineiros-io/terraform-github-repository/tree/main#secrets-configuration
plaintext_secrets = optional(map(string), {})
encrypted_secrets = optional(map(string), {})
## Autolink References Configuration
# https://github.com/mineiros-io/terraform-github-repository/tree/main#autolink-references-configuration
autolink_references = optional(list(object({
key_prefix = string
target_url_template = string
})), [])
## App Installations
# https://github.com/mineiros-io/terraform-github-repository/tree/main#app-installations
app_installations = optional(set(string), [])
}))
list(object({| `[]` | no | +| Name | Description | Type | Default | Required | +| --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | :------: | +| [gh_app_auth_id](#input_gh_app_auth_id) | The ID of the GitHub App. | `string` | `""` | no | +| [gh_app_auth_installation_id](#input_gh_app_auth_installation_id) | The ID of the GitHub App installation | `string` | `""` | no | +| [gh_app_auth_pem_file_secret_name](#input_gh_app_auth_pem_file_secret_name) | The name of the secret retrieved by secrets mixin that contains
name = string
type = string
path = optional(string, null)
file = string
}))
map(object({| `{}` | no | +| [secret_mapping](#input_secret_mapping) | The list of secret mappings the application will need.
# Main Resource Configuration
# https://github.com/mineiros-io/terraform-github-repository/tree/main#main-resource-configuration
allow_auto_merge = optional(bool, false)
allow_merge_commit = optional(bool, false)
allow_rebase_merge = optional(bool, false)
allow_squash_merge = optional(bool, false)
archive_on_destroy = optional(bool, true)
archived = optional(bool, false)
default_branch = optional(string, "main")
delete_branch_on_merge = optional(bool, true)
description = optional(string, "")
extra_topics = optional(list(string), [])
has_downloads = optional(bool, true)
has_issues = optional(bool, true)
has_projects = optional(bool, true)
has_wiki = optional(bool, false)
homepage_url = optional(string, "")
is_template = optional(bool, false)
pages = optional(object({
branch = string
cname = optional(string, null)
path = optional(string, "/")
}))
topics = optional(list(string), [])
visibility = optional(string, "private")
vulnerability_alerts = optional(bool, true)
# Extended Resource Configuration
## Repository Creation Configuration
# https://github.com/mineiros-io/terraform-github-repository/tree/main#repository-creation-configuration
auto_init = optional(bool, true)
gitignore_template = optional(string, "")
license_template = optional(string, "")
template = optional(object({
owner = string
repository = string
}))
## Teams Configuration
# https://github.com/mineiros-io/terraform-github-repository/tree/main#teams-configuration
admin_teams = optional(list(string), [])
maintain_teams = optional(list(string), [])
pull_teams = optional(list(string), [])
push_teams = optional(list(string), [])
triage_teams = optional(list(string), [])
## Collaborator Configuration
# https://github.com/mineiros-io/terraform-github-repository/tree/main#collaborator-configuration
admin_collaborators = optional(list(string), [])
maintain_collaborators = optional(list(string), [])
pull_collaborators = optional(list(string), [])
push_collaborators = optional(list(string), [])
triage_collaborators = optional(list(string), [])
## Branches Configuration
# https://github.com/mineiros-io/terraform-github-repository/tree/main#branches-configuration
branches = optional(list(object({
name = string
source_branch = optional(string, null)
source_sha = optional(bool, null)
})), [])
## Deploy Keys Configuration
# https://github.com/mineiros-io/terraform-github-repository/tree/main#deploy-keys-configuration
deploy_keys = optional(list(object({
id = optional(string, "md5(key)")
key = string
read_only = optional(bool, true)
title = optional(string, null)
})), [])
deploy_keys_computed = optional(list(object({
id = optional(string, "md5(key)")
key = string
read_only = optional(bool, true)
title = optional(string, null)
})), [])
## Branch Protections v4 Configuration
# https://github.com/mineiros-io/terraform-github-repository/tree/main#branch-protections-v4-configuration
branch_protections_v4 = optional(list(object({
pattern = string
allows_deletions = optional(bool, false)
allows_force_pushes = optional(bool, false)
blocks_creations = optional(bool, false)
enforce_admins = optional(bool, true)
push_restrictions = optional(list(string), [])
require_conversation_resolution = optional(bool, false)
require_signed_commits = optional(bool, false)
required_linear_history = optional(bool, false)
required_pull_request_reviews = optional(object({
dismiss_stale_reviews = optional(bool, true)
restrict_dismissals = optional(bool, false)
dismissal_restrictions = optional(list(string), [])
pull_request_bypassers = optional(list(string), [])
require_code_owner_reviews = optional(bool, true)
required_approving_review_count = optional(number, 1)
}), {})
required_status_checks = optional(object({
strict = optional(bool, false)
contexts = optional(list(string), [])
}), {})
})), [])
## Issue Labels Configuration
# https://github.com/mineiros-io/terraform-github-repository/tree/main#issue-labels-configuration
issue_labels = optional(list(object({
color = string
description = optional(string, null)
id = optional(string, "name")
name = string
})), [])
issue_labels_merge_with_github_labels = optional(bool)
issue_labels_create = optional(bool)
## Projects Configuration
# https://github.com/mineiros-io/terraform-github-repository/tree/main#projects-configuration
projects = optional(list(object({
body = optional(string, "")
id = optional(string, "name")
name = string
})), [])
## Webhooks Configuration
# https://github.com/mineiros-io/terraform-github-repository/tree/main#webhooks-configuration
webhooks = optional(list(object({
active = optional(bool, true)
content_type = optional(string, "form")
insecure_ssl = optional(bool, false)
events = list(string)
name = optional(string)
secret = optional(string)
url = string
})), [])
## Secrets Configuration
# https://github.com/mineiros-io/terraform-github-repository/tree/main#secrets-configuration
plaintext_secrets = optional(map(string), {})
encrypted_secrets = optional(map(string), {})
## Autolink References Configuration
# https://github.com/mineiros-io/terraform-github-repository/tree/main#autolink-references-configuration
autolink_references = optional(list(object({
key_prefix = string
target_url_template = string
})), [])
## App Installations
# https://github.com/mineiros-io/terraform-github-repository/tree/main#app-installations
app_installations = optional(set(string), [])
}))
list(object({| `[]` | no | ## Outputs diff --git a/github-repositories/main.tf b/components/github-repositories/main.tf similarity index 100% rename from github-repositories/main.tf rename to components/github-repositories/main.tf diff --git a/github-repositories/providers.tf b/components/github-repositories/providers.tf similarity index 100% rename from github-repositories/providers.tf rename to components/github-repositories/providers.tf diff --git a/github-repositories/secrets.sops.tf b/components/github-repositories/secrets.sops.tf similarity index 100% rename from github-repositories/secrets.sops.tf rename to components/github-repositories/secrets.sops.tf diff --git a/github-repositories/variables.tf b/components/github-repositories/variables.tf similarity index 88% rename from github-repositories/variables.tf rename to components/github-repositories/variables.tf index fc4e6e0..2730bae 100644 --- a/github-repositories/variables.tf +++ b/components/github-repositories/variables.tf @@ -7,21 +7,22 @@ variable "repos" { type = map(object({ # Main Resource Configuration # https://github.com/mineiros-io/terraform-github-repository/tree/main#main-resource-configuration - allow_auto_merge = optional(bool, false) - allow_merge_commit = optional(bool, true) - allow_rebase_merge = optional(bool, false) - allow_squash_merge = optional(bool, false) - archive_on_destroy = optional(bool, true) - archived = optional(bool, false) - default_branch = optional(string, null) - description = optional(string, "") - extra_topics = optional(list(string), []) - has_downloads = optional(bool, false) - has_issues = optional(bool, false) - has_projects = optional(bool, false) - has_wiki = optional(bool, false) - homepage_url = optional(string, "") - is_template = optional(bool, false) + allow_auto_merge = optional(bool, false) + allow_merge_commit = optional(bool, false) + allow_rebase_merge = optional(bool, false) + allow_squash_merge = optional(bool, false) + archive_on_destroy = optional(bool, true) + archived = optional(bool, false) + default_branch = optional(string, "main") + delete_branch_on_merge = optional(bool, true) + description = optional(string, "") + extra_topics = optional(list(string), []) + has_downloads = optional(bool, true) + has_issues = optional(bool, true) + has_projects = optional(bool, true) + has_wiki = optional(bool, false) + homepage_url = optional(string, "") + is_template = optional(bool, false) pages = optional(object({ branch = string cname = optional(string, null) @@ -29,7 +30,7 @@ variable "repos" { })) topics = optional(list(string), []) visibility = optional(string, "private") - vulnerability_alerts = optional(bool, false) + vulnerability_alerts = optional(bool, true) # Extended Resource Configuration @@ -86,7 +87,6 @@ variable "repos" { # https://github.com/mineiros-io/terraform-github-repository/tree/main#branch-protections-v4-configuration branch_protections_v4 = optional(list(object({ pattern = string - _key = optional(string) allows_deletions = optional(bool, false) allows_force_pushes = optional(bool, false) blocks_creations = optional(bool, false) @@ -95,18 +95,18 @@ variable "repos" { require_conversation_resolution = optional(bool, false) require_signed_commits = optional(bool, false) required_linear_history = optional(bool, false) - required_pull_request_reviews = optional(list(object({ + required_pull_request_reviews = optional(object({ dismiss_stale_reviews = optional(bool, true) restrict_dismissals = optional(bool, false) dismissal_restrictions = optional(list(string), []) pull_request_bypassers = optional(list(string), []) require_code_owner_reviews = optional(bool, true) required_approving_review_count = optional(number, 1) - })), []) - required_status_checks = optional(list(object({ + }), {}) + required_status_checks = optional(object({ strict = optional(bool, false) contexts = optional(list(string), []) - })), []) + }), {}) })), []) ## Issue Labels Configuration diff --git a/github-repositories/versions.tf b/components/github-repositories/versions.tf similarity index 100% rename from github-repositories/versions.tf rename to components/github-repositories/versions.tf diff --git a/templates/component.yaml b/templates/component.yaml new file mode 100644 index 0000000..75bb2a1 --- /dev/null +++ b/templates/component.yaml @@ -0,0 +1,5 @@ +component: + name: COMPONENT_NAME + source: + uri: https://api.github.com/repos/masterpointio/terraform-components/tarball/ + version: COMPONENT_VERSION
name = string
type = string
path = optional(string, null)
file = string
}))