Skip to content
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
9 changes: 8 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,19 @@ locals {
{
rulePriority = i + 1
selection = merge(
{ for k, v in rule.selection : k => v if !(k == "tagPrefixList" || k == "tagPatternList") },
{
for k, v in rule.selection :
k => v
if !contains(["tagPrefixList", "tagPatternList", "countUnit"], k) || v != null
},
length(coalesce(lookup(rule.selection, "tagPrefixList", null), [])) > 0
? { tagPrefixList = coalesce(lookup(rule.selection, "tagPrefixList", null), []) }
: {},
length(coalesce(lookup(rule.selection, "tagPatternList", null), [])) > 0
? { tagPatternList = coalesce(lookup(rule.selection, "tagPatternList", null), []) }
: {},
try(rule.selection.countUnit, null) != null
? { countUnit = rule.selection.countUnit }
: {}
)
}
Expand Down
6 changes: 3 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ variable "custom_lifecycle_rules" {
validation {
condition = alltrue([
for rule in var.custom_lifecycle_rules :
rule.selection.tagStatus != "tagged" || (rule.selection.tagPrefixList > 0 || rule.selection.tagPatternList > 0)
rule.selection.tagStatus != "tagged" || (length(coalesce(rule.selection.tagPrefixList, [])) > 0 || length(coalesce(rule.selection.tagPatternList, [])) > 0)
])
error_message = "if tagStatus is tagged - specify tagPrefixList or tagPatternList"
}
Expand Down Expand Up @@ -190,8 +190,8 @@ variable "custom_lifecycle_rules" {
validation {
condition = alltrue([
for rule in var.custom_lifecycle_rules :
rule.selection.countType == "imageCountMoreThen" || rule.selection.countUnit != null
rule.selection.countType != "sinceImagePushed" || rule.selection.countUnit != null
])
error_message = "For sinceImagePushed countUnit should be specified"
error_message = "For countType = 'sinceImagePushed', countUnit must be specified."
}
}