Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added custom repo #29

Merged
merged 2 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Functional examples are included in the
| members | Artifact Registry Reader and Writer roles for Users/SAs. Key names must be readers and/or writers | `map(list(string))` | `{}` | no |
| mode | The mode configures the repository to serve artifacts from different sources. Default value is STANDARD\_REPOSITORY. Possible values are: STANDARD\_REPOSITORY, VIRTUAL\_REPOSITORY, REMOTE\_REPOSITORY | `string` | `"STANDARD_REPOSITORY"` | no |
| project\_id | The project ID to create the repository | `string` | n/a | yes |
| remote\_repository\_config | Configuration specific for a Remote Repository. | <pre>object({<br> description = optional(string)<br> apt_repository = optional(object({<br> public_repository = optional(object({<br> repository_base = string<br> repository_path = string<br> }), null)<br> }), null)<br> docker_repository = optional(object({<br> public_repository = optional(string, "DOCKER_HUB")<br> }), null)<br> maven_repository = optional(object({<br> public_repository = optional(string, "MAVEN_CENTRAL")<br> }), null)<br> npm_repository = optional(object({<br> public_repository = optional(string, "NPMJS")<br> }), null)<br> python_repository = optional(object({<br> public_repository = optional(string, "PYPI")<br> }), null)<br> yum_repository = optional(object({<br> public_repository = optional(object({<br> repository_base = string<br> repository_path = string<br> }), null)<br> }), null)<br> })</pre> | `null` | no |
| remote\_repository\_config | Configuration specific for a Remote Repository. | <pre>object({<br> description = optional(string)<br> disable_upstream_validation = optional(bool, true)<br> upstream_credentials = optional(object({<br> username = string<br> password_secret_version = string<br> }), null)<br> apt_repository = optional(object({<br> public_repository = optional(object({<br> repository_base = string<br> repository_path = string<br> }), null)<br> }), null)<br> docker_repository = optional(object({<br> public_repository = optional(string, "DOCKER_HUB")<br> custom_repository = optional(object({<br> uri = string<br> }), null)<br> }), null)<br> maven_repository = optional(object({<br> public_repository = optional(string, "MAVEN_CENTRAL")<br> custom_repository = optional(object({<br> uri = string<br> }), null)<br> }), null)<br> npm_repository = optional(object({<br> public_repository = optional(string, "NPMJS")<br> custom_repository = optional(object({<br> uri = string<br> }), null)<br> }), null)<br> python_repository = optional(object({<br> public_repository = optional(string, "PYPI")<br> custom_repository = optional(object({<br> uri = string<br> }), null)<br> }), null)<br> yum_repository = optional(object({<br> public_repository = optional(object({<br> repository_base = string<br> repository_path = string<br> }), null)<br> }), null)<br> })</pre> | `null` | no |
| repository\_id | The repository name | `string` | n/a | yes |
| virtual\_repository\_config | Configuration specific for a Virtual Repository. | <pre>object({<br> upstream_policies = optional(list(object({<br> id = string<br> repository = string<br> priority = number<br> })), null)<br> })</pre> | `null` | no |
| vpcsc\_policy | The VPC SC policy for project and location. Possible values are: DENY, ALLOW | `string` | `"ALLOW"` | no |
Expand All @@ -78,7 +78,7 @@ These sections describe requirements for using this module.
The following dependencies must be available:

- [Terraform][terraform] v0.13+
- [Terraform Provider for GCP][terraform-provider-gcp] plugin v5.0+
- [Terraform Provider for GCP][terraform-provider-gcp] plugin v5.26.0+

### Service Account

Expand Down
4 changes: 2 additions & 2 deletions examples/gar_docker_repo/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ terraform {
required_providers {
google = {
source = "hashicorp/google"
version = ">= 5.0, < 6"
version = ">= 5.26.0, < 6"
}
google-beta = {
source = "hashicorp/google-beta"
version = ">= 5.0, < 6"
version = ">= 5.26.0, < 6"
}
}
required_version = ">= 0.13"
Expand Down
36 changes: 36 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ resource "google_artifact_registry_repository" "repo" {
content {
description = remote_repository_config.value.description

disable_upstream_validation = remote_repository_config.value.disable_upstream_validation

dynamic "upstream_credentials" {
for_each = remote_repository_config.value.upstream_credentials[*]
content {
username_password_credentials {
username = upstream_credentials.value.username
password_secret_version = upstream_credentials.value.password_secret_version
}
}
}

dynamic "apt_repository" {
for_each = remote_repository_config.value.apt_repository[*]
content {
Expand All @@ -78,27 +90,51 @@ resource "google_artifact_registry_repository" "repo" {
for_each = remote_repository_config.value.docker_repository[*]
content {
public_repository = docker_repository.value.public_repository
dynamic "custom_repository" {
for_each = docker_repository.value.custom_repository[*]
content {
uri = custom_repository.value.uri
}
}
}
}

dynamic "maven_repository" {
for_each = remote_repository_config.value.maven_repository[*]
content {
public_repository = maven_repository.value.public_repository
dynamic "custom_repository" {
for_each = maven_repository.value.custom_repository[*]
content {
uri = custom_repository.value.uri
}
}
}
}

dynamic "npm_repository" {
for_each = remote_repository_config.value.npm_repository[*]
content {
public_repository = npm_repository.value.public_repository
dynamic "custom_repository" {
for_each = npm_repository.value.custom_repository[*]
content {
uri = custom_repository.value.uri
}
}
}
}

dynamic "python_repository" {
for_each = remote_repository_config.value.python_repository[*]
content {
public_repository = python_repository.value.public_repository
dynamic "custom_repository" {
for_each = python_repository.value.custom_repository[*]
content {
uri = custom_repository.value.uri
}
}
}
}

Expand Down
19 changes: 18 additions & 1 deletion metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,12 @@ spec:
description: Configuration specific for a Remote Repository.
type: |-
object({
description = optional(string)
description = optional(string)
disable_upstream_validation = optional(bool, true)
upstream_credentials = optional(object({
username = string
password_secret_version = string
}), null)
apt_repository = optional(object({
public_repository = optional(object({
repository_base = string
Expand All @@ -125,15 +130,27 @@ spec:
}), null)
docker_repository = optional(object({
public_repository = optional(string, "DOCKER_HUB")
custom_repository = optional(object({
uri = string
}), null)
}), null)
maven_repository = optional(object({
public_repository = optional(string, "MAVEN_CENTRAL")
custom_repository = optional(object({
uri = string
}), null)
}), null)
npm_repository = optional(object({
public_repository = optional(string, "NPMJS")
custom_repository = optional(object({
uri = string
}), null)
}), null)
python_repository = optional(object({
public_repository = optional(string, "PYPI")
custom_repository = optional(object({
uri = string
}), null)
}), null)
yum_repository = optional(object({
public_repository = optional(object({
Expand Down
19 changes: 18 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ variable "virtual_repository_config" {

variable "remote_repository_config" {
type = object({
description = optional(string)
description = optional(string)
disable_upstream_validation = optional(bool, true)
upstream_credentials = optional(object({
username = string
password_secret_version = string
}), null)
apt_repository = optional(object({
public_repository = optional(object({
repository_base = string
Expand All @@ -98,15 +103,27 @@ variable "remote_repository_config" {
}), null)
docker_repository = optional(object({
public_repository = optional(string, "DOCKER_HUB")
custom_repository = optional(object({
uri = string
}), null)
}), null)
maven_repository = optional(object({
public_repository = optional(string, "MAVEN_CENTRAL")
custom_repository = optional(object({
uri = string
}), null)
}), null)
npm_repository = optional(object({
public_repository = optional(string, "NPMJS")
custom_repository = optional(object({
uri = string
}), null)
}), null)
python_repository = optional(object({
public_repository = optional(string, "PYPI")
custom_repository = optional(object({
uri = string
}), null)
}), null)
yum_repository = optional(object({
public_repository = optional(object({
Expand Down
4 changes: 2 additions & 2 deletions versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ terraform {
required_providers {
google = {
source = "hashicorp/google"
version = ">= 5.0, < 6"
version = ">= 5.26.0, < 6"
}
google-beta = {
source = "hashicorp/google-beta"
version = ">= 5.0, < 6"
version = ">= 5.26.0, < 6"
}
}

Expand Down