-
Notifications
You must be signed in to change notification settings - Fork 122
Resource resource_artifactory_package_cleanup_policy - "included_packages" not working for maven #1367
Description
Describe the bug
In resource resource_artifactory_package_cleanup_policy, currently only included_packages is provided. In the Cloud we have 2 fields: "Include Package Name Pattern" and "Include Package Version Pattern".
The resources, always fills both fields with the same value that is provided in "included_packages".
In case of maven policy, this generates an error with the following parameters
type: version-based
keep_last_n_versions: 3
included_packages: "com/sartorius"
In the UI, "com/sartorius" is invalid for "Include Package Name Pattern" but valid for "Include Package Version Pattern".
I'm on Cloud Enterprise+ and use the latest versions of the provider
Expected behavior
Please expose both parameters separately in the resource.
Additional context
This is the resource definition in my terraform
resource "artifactory_package_cleanup_policy" "cleanup_policies" {
for_each = local.repos_with_cleanup
key = "${replace(each.value.key, "_", "-")}-cleanup-${format("%02d", each.value.policy_index)}"
description = "Cleanup policy ${each.value.policy_index + 1} for ${each.value.key}"
cron_expression = each.value.cleanup_config.cron_expression
duration_in_minutes = try(each.value.cleanup_config.duration_in_minutes, 60)
enabled = try(each.value.cleanup_config.enabled, true) == true
skip_trashcan = try(each.value.cleanup_config.skip_trashcan, false)
search_criteria = merge(
{
package_types = [each.value.type]
repos = [each.value.key]
included_packages = [try(each.value.cleanup_config.included_packages, "**")]
included_projects = []
},
# Excluded packages (optional, only include if specified - must be a single pattern)
try(each.value.cleanup_config.excluded_packages, null) != null ? {
excluded_packages = [each.value.cleanup_config.excluded_packages]
} : {},
# Excluded properties (optional, can be combined with any condition type)
try(each.value.cleanup_config.excluded_properties, null) != null ? {
excluded_properties = each.value.cleanup_config.excluded_properties
} : {},
# Time-based cleanup (mutually exclusive with version-based and properties-based)
try(each.value.cleanup_config.type, "") == "time" ? {
created_before_in_days = try(each.value.cleanup_config.items_older_than_days, null)
last_downloaded_before_in_days = try(each.value.cleanup_config.last_downloaded_days, null)
} : {},
# Version-based cleanup (mutually exclusive with time-based and properties-based)
try(each.value.cleanup_config.type, "") == "version" ? {
keep_last_n_versions = try(each.value.cleanup_config.keep_last_n_versions, null)
} : {},
# Properties-based cleanup (mutually exclusive with time-based and version-based)
try(each.value.cleanup_config.type, "") == "properties" ? {
included_properties = each.value.cleanup_config.included_properties
} : {}
)
project_key = replace(each.value.id, "_", "-")
Ensure repositories are assigned to projects before creating cleanup policies
depends_on = [project_repository.this]
}