Skip to content

Commit 62eb9ae

Browse files
feat: add support for custom host in gitlab (#328)
1 parent 43a5527 commit 62eb9ae

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

modules/cloudbuild_repo_connection/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Users will provide the required secrets through the `connection_config` variable
1313
|------|-------------|------|---------|:--------:|
1414
| cloud\_build\_repositories | Cloud Build repositories configuration:<br> - repository\_name: The name of the repository to be used in Cloud Build.<br> - repository\_url: The HTTPS clone URL for the repository. This URL must end with '.git' and be a valid HTTPS URL.<br><br>Each entry in this map must contain both `repository_name` and `repository_url` to properly integrate with the Cloud Build service. | <pre>map(object({<br> repository_name = string,<br> repository_url = string,<br> }))</pre> | n/a | yes |
1515
| cloudbuild\_connection\_name | Cloudbuild Connection Name. | `string` | `"generic-cloudbuild-connection"` | no |
16-
| connection\_config | Connection configuration options:<br> - connection\_type: Specifies the type of connection being used. Supported types are 'GITHUBv2' and 'GITLABv2'.<br> - github\_secret\_id: (Optional) The secret ID for GitHub credentials.<br> - github\_app\_id\_secret\_id: (Optional) The secret ID for the application ID for a GitHub App used for authentication. For app installation, follow this link: https://github.com/apps/google-cloud-build<br> - gitlab\_read\_authorizer\_credential\_secret\_id: (Optional) The secret ID for the GitLab read authorizer credential.<br> - gitlab\_authorizer\_credential\_secret\_id: (Optional) The secret ID for the GitLab authorizer credential.<br> - gitlab\_webhook\_secret\_id: (Optional) The secret ID for the GitLab WebHook. | <pre>object({<br> connection_type = string<br> github_secret_id = optional(string)<br> github_app_id_secret_id = optional(string)<br> gitlab_read_authorizer_credential_secret_id = optional(string)<br> gitlab_authorizer_credential_secret_id = optional(string)<br> gitlab_webhook_secret_id = optional(string)<br> })</pre> | n/a | yes |
16+
| connection\_config | Connection configuration options:<br> - connection\_type: Specifies the type of connection being used. Supported types are 'GITHUBv2' and 'GITLABv2'.<br> - github\_secret\_id: (Optional) The secret ID for GitHub credentials.<br> - github\_app\_id\_secret\_id: (Optional) The secret ID for the application ID for a GitHub App used for authentication. For app installation, follow this link: https://github.com/apps/google-cloud-build<br> - gitlab\_read\_authorizer\_credential\_secret\_id: (Optional) The secret ID for the GitLab read authorizer credential.<br> - gitlab\_authorizer\_credential\_secret\_id: (Optional) The secret ID for the GitLab authorizer credential.<br> - gitlab\_webhook\_secret\_id: (Optional) The secret ID for the GitLab WebHook.<br> - gitlab\_enterprise\_host\_uri: (Optional) The URI of the GitLab Enterprise host this connection is for. If not specified, the default value is https://gitlab.com.<br> - gitlab\_enterprise\_service\_directory: (Optional) Configuration for using Service Directory to privately connect to a GitLab Enterprise server. This should only be set if the GitLab Enterprise server is hosted on-premises and not reachable by public internet. If this field is left empty, calls to the GitLab Enterprise server will be made over the public internet. Format: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}.<br> - gitlab\_enterprise\_ca\_certificate: (Optional) SSL certificate to use for requests to GitLab Enterprise. | <pre>object({<br> connection_type = string<br> github_secret_id = optional(string)<br> github_app_id_secret_id = optional(string)<br> gitlab_read_authorizer_credential_secret_id = optional(string)<br> gitlab_authorizer_credential_secret_id = optional(string)<br> gitlab_webhook_secret_id = optional(string)<br> gitlab_enterprise_host_uri = optional(string)<br> gitlab_enterprise_service_directory = optional(string)<br> gitlab_enterprise_ca_certificate = optional(string)<br> })</pre> | n/a | yes |
1717
| location | Resources location. | `string` | `"us-central1"` | no |
1818
| project\_id | The project id to create the secret and assign cloudbuild service account permissions. | `string` | n/a | yes |
1919

modules/cloudbuild_repo_connection/main.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,14 @@ resource "google_cloudbuildv2_connection" "connection" {
5757
dynamic "gitlab_config" {
5858
for_each = local.is_gitlab ? [1] : []
5959
content {
60-
host_uri = null
60+
host_uri = var.connection_config.gitlab_enterprise_host_uri
61+
ssl_ca = var.connection_config.gitlab_enterprise_ca_certificate
62+
dynamic "service_directory_config" {
63+
for_each = var.connection_config.gitlab_enterprise_service_directory == null ? [] : [1]
64+
content {
65+
service = var.connection_config.gitlab_enterprise_service_directory
66+
}
67+
}
6168
authorizer_credential {
6269
user_token_secret_version = "${var.connection_config.gitlab_authorizer_credential_secret_id}/versions/latest"
6370
}

modules/cloudbuild_repo_connection/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ variable "connection_config" {
2828
- gitlab_read_authorizer_credential_secret_id: (Optional) The secret ID for the GitLab read authorizer credential.
2929
- gitlab_authorizer_credential_secret_id: (Optional) The secret ID for the GitLab authorizer credential.
3030
- gitlab_webhook_secret_id: (Optional) The secret ID for the GitLab WebHook.
31+
- gitlab_enterprise_host_uri: (Optional) The URI of the GitLab Enterprise host this connection is for. If not specified, the default value is https://gitlab.com.
32+
- gitlab_enterprise_service_directory: (Optional) Configuration for using Service Directory to privately connect to a GitLab Enterprise server. This should only be set if the GitLab Enterprise server is hosted on-premises and not reachable by public internet. If this field is left empty, calls to the GitLab Enterprise server will be made over the public internet. Format: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}.
33+
- gitlab_enterprise_ca_certificate: (Optional) SSL certificate to use for requests to GitLab Enterprise.
3134
EOT
3235
type = object({
3336
connection_type = string
@@ -36,6 +39,9 @@ variable "connection_config" {
3639
gitlab_read_authorizer_credential_secret_id = optional(string)
3740
gitlab_authorizer_credential_secret_id = optional(string)
3841
gitlab_webhook_secret_id = optional(string)
42+
gitlab_enterprise_host_uri = optional(string)
43+
gitlab_enterprise_service_directory = optional(string)
44+
gitlab_enterprise_ca_certificate = optional(string)
3945
})
4046

4147
validation {

0 commit comments

Comments
 (0)