prep v40.0.0

This commit is contained in:
Ludo
2025-05-21 10:25:45 +02:00
224 changed files with 2918 additions and 2779 deletions

View File

@@ -25,6 +25,35 @@ Gitlab hostname and SSH port on the `gitlab_config` section.
## Variable configuration
### Gitlab Config
The `gitlab_config` variable defines where projects will be hosted.
GitLab can either be the SaaS offering (with the default hostname `gitlab.com`)
or a self-hosted instance with a custom FQDN. If hostname is set to gitlab.com, you must
also set the `saas_group` variable to specify the group path where resources will be created.
This is an example that configures a SaaS gitlab instance using `my_group/gcp` as default group :
```hcl
gitlab_config = {
access_token = "glpat-XXX"
hostname = "gitlab.com"
ssh_port = 22
saas_group = "my_group/gcp"
}
# tftest skip
```
This is an example that configures an on-premise gitlab instance :
```hcl
gitlab_config = {
access_token = "glpat-XXX"
hostname = "my-gitlab.example.com"
}
# tftest skip
```
### Modules project and sources
The `modules_config` variable controls creation and management of both the
@@ -374,11 +403,11 @@ check if the plan pipeline executes successfully.
| name | description | type | required | default |
|---|---|:---:|:---:|:---:|
| [gitlab_config](variables.tf#L28) | Gitlab config. | <code title="object&#40;&#123;&#10; access_token &#61; string&#10; hostname &#61; optional&#40;string, &#34;gitlab.gcp.example.com&#34;&#41;&#10; ssh_port &#61; optional&#40;number, 2222&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | ✓ | |
| [groups](variables.tf#L37) | Gitlab groups. | <code title="map&#40;object&#40;&#123;&#10; name &#61; string&#10; path &#61; string&#10; description &#61; string&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | ✓ | |
| [gitlab_config](variables.tf#L28) | Gitlab config. | <code title="object&#40;&#123;&#10; access_token &#61; string&#10; hostname &#61; optional&#40;string, &#34;gitlab.com&#34;&#41;&#10; ssh_port &#61; optional&#40;number, 22&#41;&#10; saas_group &#61; optional&#40;string, &#34;&#34;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | ✓ | |
| [groups](variables.tf#L45) | Gitlab groups. | <code title="map&#40;object&#40;&#123;&#10; name &#61; string&#10; path &#61; string&#10; description &#61; string&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | ✓ | |
| [commit_config](variables.tf#L17) | Configure commit metadata. | <code title="object&#40;&#123;&#10; author &#61; optional&#40;string, &#34;FAST loader&#34;&#41;&#10; email &#61; optional&#40;string, &#34;fast-loader&#64;fast.gcp.tf&#34;&#41;&#10; message &#61; optional&#40;string, &#34;FAST initial loading&#34;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>&#123;&#125;</code> |
| [modules_config](variables.tf#L46) | Gitlab modules config. | <code title="object&#40;&#123;&#10; bootstrap &#61; optional&#40;bool, true&#41;&#10; module_prefix &#61; optional&#40;string, &#34;&#34;&#41;&#10; group &#61; optional&#40;string&#41;&#10; project_name &#61; string&#10; source_ref &#61; optional&#40;string&#41;&#10; key_config &#61; optional&#40;object&#40;&#123;&#10; create_key &#61; optional&#40;bool, false&#41;&#10; create_secrets &#61; optional&#40;bool, false&#41;&#10; keypair_path &#61; optional&#40;string&#41;&#10; &#125;&#41;, &#123;&#125;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [projects](variables.tf#L71) | Gitlab projects to create. | <code title="map&#40;object&#40;&#123;&#10; create_options &#61; optional&#40;object&#40;&#123;&#10; allow &#61; optional&#40;object&#40;&#123;&#10; auto_merge &#61; optional&#40;bool&#41;&#10; merge_commit &#61; optional&#40;bool&#41;&#10; rebase_merge &#61; optional&#40;bool&#41;&#10; squash_merge &#61; optional&#40;bool&#41;&#10; &#125;&#41;&#41;&#10; auto_init &#61; optional&#40;bool&#41;&#10; description &#61; optional&#40;string&#41;&#10; features &#61; optional&#40;object&#40;&#123;&#10; issues &#61; optional&#40;bool&#41;&#10; projects &#61; optional&#40;bool&#41;&#10; wiki &#61; optional&#40;bool&#41;&#10; &#125;&#41;&#41;&#10; templates &#61; optional&#40;object&#40;&#123;&#10; gitignore &#61; optional&#40;string, &#34;Terraform&#34;&#41;&#10; license &#61; optional&#40;string&#41;&#10; repository &#61; optional&#40;object&#40;&#123;&#10; name &#61; string&#10; owner &#61; string&#10; &#125;&#41;&#41;&#10; &#125;&#41;, &#123;&#125;&#41;&#10; visibility &#61; optional&#40;string, &#34;private&#34;&#41;&#10; &#125;&#41;&#41;&#10; group &#61; string&#10; populate_from &#61; optional&#40;string&#41;&#10; populate_samples &#61; optional&#40;bool, false&#41;&#10; workflow_file &#61; optional&#40;string, null&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [modules_config](variables.tf#L54) | Gitlab modules config. | <code title="object&#40;&#123;&#10; bootstrap &#61; optional&#40;bool, true&#41;&#10; module_prefix &#61; optional&#40;string, &#34;&#34;&#41;&#10; group &#61; optional&#40;string&#41;&#10; project_name &#61; string&#10; source_ref &#61; optional&#40;string&#41;&#10; key_config &#61; optional&#40;object&#40;&#123;&#10; create_key &#61; optional&#40;bool, false&#41;&#10; create_secrets &#61; optional&#40;bool, false&#41;&#10; keypair_path &#61; optional&#40;string&#41;&#10; &#125;&#41;, &#123;&#125;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [projects](variables.tf#L79) | Gitlab projects to create. | <code title="map&#40;object&#40;&#123;&#10; create_options &#61; optional&#40;object&#40;&#123;&#10; allow &#61; optional&#40;object&#40;&#123;&#10; auto_merge &#61; optional&#40;bool&#41;&#10; merge_commit &#61; optional&#40;bool&#41;&#10; rebase_merge &#61; optional&#40;bool&#41;&#10; squash_merge &#61; optional&#40;bool&#41;&#10; &#125;&#41;&#41;&#10; auto_init &#61; optional&#40;bool&#41;&#10; description &#61; optional&#40;string&#41;&#10; features &#61; optional&#40;object&#40;&#123;&#10; issues &#61; optional&#40;bool&#41;&#10; projects &#61; optional&#40;bool&#41;&#10; wiki &#61; optional&#40;bool&#41;&#10; &#125;&#41;&#41;&#10; templates &#61; optional&#40;object&#40;&#123;&#10; gitignore &#61; optional&#40;string, &#34;Terraform&#34;&#41;&#10; license &#61; optional&#40;string&#41;&#10; repository &#61; optional&#40;object&#40;&#123;&#10; name &#61; string&#10; owner &#61; string&#10; &#125;&#41;&#41;&#10; &#125;&#41;, &#123;&#125;&#41;&#10; visibility &#61; optional&#40;string, &#34;private&#34;&#41;&#10; &#125;&#41;&#41;&#10; group &#61; string&#10; populate_from &#61; optional&#40;string&#41;&#10; populate_samples &#61; optional&#40;bool, false&#41;&#10; workflow_file &#61; optional&#40;string, null&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
## Outputs

View File

@@ -28,6 +28,8 @@ locals {
] : []),
[for f in fileset(path.module, "${v.populate_from}/*.tf") : f],
[for f in fileset(path.module, "${v.populate_from}/templates/*.tpl") : f],
[for f in fileset(path.module, "${v.populate_from}/templates/*.yaml") : f],
[for f in fileset(path.module, "${v.populate_from}/schemas/*.json") : f],
[for f in fileset(path.module, "${v.populate_from}/terraform.tfvars") : f]
) : {
project = k
@@ -36,6 +38,9 @@ locals {
}
] if v.populate_from != null
])
gitlab_ssh_prefix = "git::ssh://git@${var.gitlab_config.hostname}:${var.gitlab_config.ssh_port}/"
gitlab_base_path = var.gitlab_config.hostname == "gitlab.com" ? "${var.gitlab_config.saas_group}/" : ""
gitlab_base_url = "${local.gitlab_ssh_prefix}${local.gitlab_base_path}${local.modules_group}/${local.modules_project}.git"
modules_files = {
for f in concat(
[for f in fileset(path.module, "../../../modules/*/*.svg") : f],
@@ -61,7 +66,7 @@ locals {
for k in local._repository_files :
"${k.project}/${k.name}" => k
if !endswith(k.name, ".tf") || (
!startswith(k.name, "0") && k.name != "globals.tf"
!startswith(k.name, "0") && !startswith(k.name, "1") && !startswith(k.name, "2") && k.name != "globals.tf"
)
},
{
@@ -76,11 +81,17 @@ locals {
)
}
data "gitlab_group" "saas" {
count = var.gitlab_config.hostname == "gitlab.com" ? 1 : 0
full_path = var.gitlab_config.saas_group
}
resource "gitlab_group" "default" {
for_each = var.groups
name = each.value.name
path = each.value.path
description = each.value.description
parent_id = var.gitlab_config.hostname == "gitlab.com" ? data.gitlab_group.saas[0].id : null
}
resource "gitlab_project" "modules" {
@@ -161,7 +172,7 @@ resource "gitlab_repository_file" "default" {
? base64encode(replace(
file(each.value.file),
"/source(\\s*)=\\s*\"../../../modules/([^/\"]+)\"/",
"source$1= \"git::ssh://git@${var.gitlab_config.hostname}:${var.gitlab_config.ssh_port}/${local.modules_group}/${local.modules_project}.git//${local.module_prefix}$2${local.modules_ref}\"" # "
"source$1= \"${local.gitlab_base_url}//${local.module_prefix}$2${local.modules_ref}\""
))
: endswith(each.value.name, ".png") || endswith(each.value.name, ".gif") || endswith(each.value.name, ".svg") ? filebase64(each.value.file) : base64encode(file(each.value.file))
)

View File

@@ -18,6 +18,6 @@ output "clone" {
description = "Clone projects commands."
value = {
for k, v in var.projects :
k => "ssh://git@${var.gitlab_config.hostname}:${var.gitlab_config.ssh_port}/${v.group}/${k}.git"
k => "ssh://git@${var.gitlab_config.hostname}:${var.gitlab_config.ssh_port}/${(var.gitlab_config.saas_group != "" ? "${var.gitlab_config.saas_group}/${v.group}" : "${v.group}")}/${k}.git"
}
}

View File

@@ -1,6 +1,10 @@
gitlab_config = {
access_token = "{token}"
access_token = "glpat-XXXXXXXXXXXXXXXXXXXXXXXX"
hostname = "gitlab.com"
ssh_port = 22
saas_group = "XXX" # Replace with path GitLab group
}
modules_config = {
project_name = "modules"
key_config = {

View File

@@ -29,9 +29,17 @@ variable "gitlab_config" {
description = "Gitlab config."
type = object({
access_token = string
hostname = optional(string, "gitlab.gcp.example.com")
ssh_port = optional(number, 2222)
hostname = optional(string, "gitlab.com")
ssh_port = optional(number, 22)
saas_group = optional(string, "")
})
validation {
condition = (
(var.gitlab_config.hostname == "gitlab.com" && var.gitlab_config.saas_group != "") ||
(var.gitlab_config.hostname != "gitlab.com" && var.gitlab_config.saas_group == "")
)
error_message = "Gitlab Saas parent group must be define."
}
}
variable "groups" {

View File

@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Fabric release: v40.0.0-rc1
# Fabric release: v40.0.0
terraform {
required_version = ">= 1.10.2"
@@ -27,9 +27,9 @@ terraform {
}
}
provider_meta "google" {
module_name = "google-pso-tool/cloud-foundation-fabric/fast/project-templates/managed-kafka:v40.0.0-rc1-tf"
module_name = "google-pso-tool/cloud-foundation-fabric/path:v40.0.0-tf"
}
provider_meta "google-beta" {
module_name = "google-pso-tool/cloud-foundation-fabric/fast/project-templates/managed-kafka:v40.0.0-rc1-tf"
module_name = "google-pso-tool/cloud-foundation-fabric/path:v40.0.0-tf"
}
}