-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvariables.tf
101 lines (90 loc) · 4.07 KB
/
variables.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
variable "project_id" {
type = string
description = "The GCP project ID that hosts the Artifact Registry."
}
variable "enable_api" {
type = bool
description = "Enable the Artifact Registry API."
default = true
}
# The default location used for the Artifact Registry repositories.
variable "default_location" {
type = string
description = "The default location for the Artifact Registry repositories."
default = "europe-west1"
}
# Artifact Registry repositories.
variable "repositories" {
type = map(object({
description = string
format = optional(string, "DOCKER")
mode = optional(string, "STANDARD_REPOSITORY")
cleanup_policy_dry_run = optional(bool, true)
cleanup_policies = optional(map(object({
action = optional(string, ""),
condition = optional(object({
tag_state = optional(string),
tag_prefixes = optional(list(string), []),
version_name_prefixes = optional(list(string), []),
package_name_prefixes = optional(list(string), []),
older_than = optional(string),
newer_than = optional(string),
}), {}),
most_recent_versions = optional(object({
package_name_prefixes = optional(list(string), []),
keep_count = optional(number, 0)
}), {})
})), {})
docker_immutable_tags = optional(bool, true)
virtual_repository_config = optional(map(object({
repository = string
priority = optional(number, 0)
})), null)
remote_repository_config_docker = optional(object({
description = optional(string, "")
custom_repository_uri = string
disable_upstream_validation = optional(bool, false)
username_password_credentials_username = optional(string, "")
username_password_credentials_password_secret_name = optional(string, "")
username_password_credentials_password_secret_version = optional(string, "")
}), null)
readers = optional(list(string), [])
writers = optional(list(string), [])
location = optional(string, "")
labels = optional(map(string), {})
}))
description = "List of Artifact Registry repositories to create."
validation {
condition = alltrue([for policy in flatten([for repo in var.repositories : [for cp in repo.cleanup_policies : cp]]) : contains(["DELETE", "KEEP"], policy.action)])
error_message = "Cleanup policy action must be either DELETE or KEEP."
}
validation {
condition = alltrue([for policy in flatten([for repo in var.repositories : [for cp in repo.cleanup_policies : cp]]) : policy.condition.tag_state == null || contains(["ANY", "TAGGED", "UNTAGGED"], policy.condition.tag_state)])
error_message = "Tag state must be ANY, TAGGED, or UNTAGGED."
}
validation {
condition = alltrue([for policy in flatten([for repo in var.repositories : [for cp in repo.cleanup_policies : cp]]) : policy.most_recent_versions == {} || policy.most_recent_versions.keep_count == null || policy.most_recent_versions.keep_count >= 0])
error_message = "Keep count must be a non-negative number."
}
validation {
condition = alltrue([for repo in var.repositories : repo.mode == "REMOTE_REPOSITORY" ? lookup(repo, "remote_repository_config_docker", null) != null : true])
error_message = "Remote repository configuration is required for the REMOTE_REPOSITORY mode."
}
}
variable "artifact_registry_listers_custom_role_name" {
type = string
description = "Name of the custom role for Artifact Registry listers."
default = "custom.artifactRegistryLister"
}
variable "artifact_registry_listers" {
type = list(string)
description = "List of principals that can list Artifact Registry repositories."
default = []
}
variable "default_labels" {
type = map(string)
description = "Default labels to apply to all Artifact Registry resources."
default = {
"managed-by" = "terraform"
}
}