Merge branch 'master' into lcaggio/bqml
This commit is contained in:
commit
016390486d
|
@ -116,8 +116,27 @@ Initial population depends on a modules repository being configured in the `modu
|
|||
|
||||
### Commit configuration
|
||||
|
||||
Finally, a `commit_config` variable is optional: it can be used to configure author, email and message used in commits for initial population of files, its defaults are probably fine for most use cases.
|
||||
An optional variable `commit_config` can be used to configure the author, email, and message used in commits for the initial population of files. Its defaults are probably fine for most use cases.
|
||||
|
||||
### Pull Request configuration
|
||||
|
||||
An optional variable `pull_request_config` can be used to configure the title, body, head_ref, and base_ref of the pull request created for the initial population or update of files. By default, no pull request is created. To create a pull request, set the `create` attribute to `true`. `base_ref` defaults to `main` and `head_ref` to the head branch name. If the head branch does not exist, it will be created from the base_ref branch.
|
||||
|
||||
```hcl
|
||||
pull_request_config = {
|
||||
create = true
|
||||
title = "FAST: initial loading or update"
|
||||
body = ""
|
||||
base_ref = "main"
|
||||
head_ref = "fast-loader"
|
||||
}
|
||||
# tftest skip
|
||||
```
|
||||
|
||||
To start using a pull request workflow, if the initial loading was created without a pull request in the past, please use the following command to delete the actual branch files from the Terraform state to keep it in the current state:
|
||||
```bash
|
||||
terraform state list | grep github_repository_file | awk '{print "terraform state rm '\''"$1"'\''"}'
|
||||
```
|
||||
<!-- TFDOC OPTS files:1 -->
|
||||
<!-- BEGIN TFDOC -->
|
||||
|
||||
|
@ -126,7 +145,7 @@ Finally, a `commit_config` variable is optional: it can be used to configure aut
|
|||
| name | description | resources |
|
||||
|---|---|---|
|
||||
| [cicd-versions.tf](./cicd-versions.tf) | Provider version. | |
|
||||
| [main.tf](./main.tf) | Module-level locals and resources. | <code>github_actions_secret</code> · <code>github_repository</code> · <code>github_repository_deploy_key</code> · <code>github_repository_file</code> · <code>tls_private_key</code> |
|
||||
| [main.tf](./main.tf) | Module-level locals and resources. | <code>github_actions_secret</code> · <code>github_branch</code> · <code>github_repository</code> · <code>github_repository_deploy_key</code> · <code>github_repository_file</code> · <code>github_repository_pull_request</code> · <code>tls_private_key</code> |
|
||||
| [outputs.tf](./outputs.tf) | Module outputs. | |
|
||||
| [providers.tf](./providers.tf) | Provider configuration. | |
|
||||
| [variables.tf](./variables.tf) | Module variables. | |
|
||||
|
@ -138,7 +157,8 @@ Finally, a `commit_config` variable is optional: it can be used to configure aut
|
|||
| [organization](variables.tf#L51) | GitHub organization. | <code>string</code> | ✓ | |
|
||||
| [commmit_config](variables.tf#L17) | Configure commit metadata. | <code title="object({ author = optional(string, "FAST loader") email = optional(string, "fast-loader@fast.gcp.tf") message = optional(string, "FAST initial loading") })">object({…})</code> | | <code>{}</code> |
|
||||
| [modules_config](variables.tf#L28) | Configure access to repository module via key, and replacement for modules sources in stage repositories. | <code title="object({ repository_name = string source_ref = optional(string) module_prefix = optional(string, "") key_config = optional(object({ create_key = optional(bool, false) create_secrets = optional(bool, false) keypair_path = optional(string) }), {}) })">object({…})</code> | | <code>null</code> |
|
||||
| [repositories](variables.tf#L56) | Repositories to create. | <code title="map(object({ create_options = optional(object({ allow = optional(object({ auto_merge = optional(bool) merge_commit = optional(bool) rebase_merge = optional(bool) squash_merge = optional(bool) })) auto_init = optional(bool) description = optional(string) features = optional(object({ issues = optional(bool) projects = optional(bool) wiki = optional(bool) })) templates = optional(object({ gitignore = optional(string, "Terraform") license = optional(string) repository = optional(object({ name = string owner = string })) }), {}) visibility = optional(string, "private") })) populate_from = optional(string) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [pull_request_config](variables.tf#L56) | Configure pull request metadata. | <code title="object({ create = optional(bool, false) title = optional(string, "FAST: initial loading or update") body = optional(string, "") base_ref = optional(string, "main") head_ref = optional(string, "fast-loader") })">object({…})</code> | | <code>{}</code> |
|
||||
| [repositories](variables.tf#L69) | Repositories to create. | <code title="map(object({ create_options = optional(object({ allow = optional(object({ auto_merge = optional(bool) merge_commit = optional(bool) rebase_merge = optional(bool) squash_merge = optional(bool) })) auto_init = optional(bool) description = optional(string) features = optional(object({ issues = optional(bool) projects = optional(bool) wiki = optional(bool) })) templates = optional(object({ gitignore = optional(string, "Terraform") license = optional(string) repository = optional(object({ name = string owner = string })) }), {}) visibility = optional(string, "private") })) populate_from = optional(string) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
|
||||
## Outputs
|
||||
|
||||
|
|
|
@ -136,10 +136,21 @@ resource "github_actions_secret" "default" {
|
|||
)
|
||||
}
|
||||
|
||||
resource "github_branch" "default" {
|
||||
for_each = (
|
||||
try(var.pull_request_config.create, null) == true
|
||||
? local.repositories
|
||||
: {}
|
||||
)
|
||||
repository = each.key
|
||||
branch = var.pull_request_config.head_ref
|
||||
source_branch = var.pull_request_config.base_ref
|
||||
}
|
||||
|
||||
resource "github_repository_file" "default" {
|
||||
for_each = local.modules_repo == null ? {} : local.repository_files
|
||||
repository = local.repositories[each.value.repository]
|
||||
branch = "main"
|
||||
branch = try(var.pull_request_config.head_ref, "main")
|
||||
file = each.value.name
|
||||
content = (
|
||||
endswith(each.value.name, ".tf") && local.modules_repo != null
|
||||
|
@ -161,3 +172,16 @@ resource "github_repository_file" "default" {
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
resource "github_repository_pull_request" "default" {
|
||||
for_each = (
|
||||
try(var.pull_request_config.create, null) == true
|
||||
? local.repositories
|
||||
: {}
|
||||
)
|
||||
base_repository = each.key
|
||||
title = var.pull_request_config.title
|
||||
body = var.pull_request_config.body
|
||||
base_ref = var.pull_request_config.base_ref
|
||||
head_ref = var.pull_request_config.head_ref
|
||||
}
|
||||
|
|
|
@ -53,6 +53,19 @@ variable "organization" {
|
|||
type = string
|
||||
}
|
||||
|
||||
variable "pull_request_config" {
|
||||
description = "Configure pull request metadata."
|
||||
type = object({
|
||||
create = optional(bool, false)
|
||||
title = optional(string, "FAST: initial loading or update")
|
||||
body = optional(string, "")
|
||||
base_ref = optional(string, "main")
|
||||
head_ref = optional(string, "fast-loader")
|
||||
})
|
||||
default = {}
|
||||
nullable = false
|
||||
}
|
||||
|
||||
variable "repositories" {
|
||||
description = "Repositories to create."
|
||||
type = map(object({
|
||||
|
|
Loading…
Reference in New Issue