Skip to content

Commit 29d0f37

Browse files
authored
Merge pull request #1107 from jfrog/GH-1105-fix-remote-repo-replication-errors
Fix unknown value error for 'check_binary_existence_in_filestore'
2 parents 7d22070 + 4110183 commit 29d0f37

8 files changed

+32
-13
lines changed

CHANGELOG.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
## 12.3.2 (October 29, 2024). Tested on Artifactory 7.90.15 with Terraform 1.9.8 and OpenTofu 1.8.4
1+
## 12.3.2 (October 30, 2024). Tested on Artifactory 7.98.7 with Terraform 1.9.8 and OpenTofu 1.8.4
2+
3+
IMPROVEMENTS:
4+
5+
* resource/artifactory_package_cleanup_policy: Update valid values for `package_types` attribute. PR: [#1107](https://github.com/jfrog/terraform-provider-artifactory/pull/1107)
26

37
BUG FIXES:
48

59
* resource/artifactory_mail_server: Fix error when unsetting an optional attribute. Issue: [#1103](https://github.com/jfrog/terraform-provider-artifactory/issues/1103) PR: [#1106](https://github.com/jfrog/terraform-provider-artifactory/pull/1106)
10+
* resource/artifactory_remote_repository_replication: Fix unknown value error for `check_binary_existence_in_filestore`. Issue: [#1105](https://github.com/jfrog/terraform-provider-artifactory/issues/1105) PR: [#1107](https://github.com/jfrog/terraform-provider-artifactory/pull/1107)
611

712
## 12.3.1 (October 18, 2024). Tested on Artifactory 7.90.14 with Terraform 1.9.8 and OpenTofu 1.8.3
813

docs/resources/package_cleanup_policy.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ resource "artifactory_package_cleanup_policy" "my-cleanup-policy" {
7171
Required:
7272

7373
- `included_packages` (Set of String) Specify a pattern for a package name or an explicit package name. It accept only single element which can be specific package or pattern, and for including all packages use `**`. Example: `included_packages = ["**"]`
74-
- `package_types` (Set of String) Types of packages to be removed. Support: conan, docker, generic, gradle, maven, npm, nuget, rpm.
74+
- `package_types` (Set of String) Types of packages to be removed. Support: conan, debian, docker, gems, generic, go, gradle, helm, maven, npm, nuget, pypi, yum.
7575
- `repos` (Set of String) Specify patterns for repository names or explicit repository names. For including all repos use `**`. Example: `repos = ["**"]`
7676

7777
Optional:

pkg/artifactory/datasource/artifact/datasource_artifactory_file_list.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@ func (d *FileListDataSource) Read(ctx context.Context, req datasource.ReadReques
241241
}
242242

243243
var fileList FileListAPIModel
244+
folderPath := ""
245+
if data.FolderPath.ValueString() != "/" { // only use config folder path if it isn't just "/"
246+
folderPath = data.FolderPath.ValueString()
247+
}
248+
244249
response, err := d.ProviderData.Client.R().
245250
SetQueryParams(map[string]string{
246251
"list": "",
@@ -253,7 +258,7 @@ func (d *FileListDataSource) Read(ctx context.Context, req datasource.ReadReques
253258
SetResult(&fileList).
254259
SetPathParams(map[string]string{
255260
"repoKey": data.RepositoryKey.ValueString(),
256-
"folderPath": data.FolderPath.ValueString(),
261+
"folderPath": folderPath,
257262
}).
258263
Get("artifactory/api/storage/{repoKey}/{folderPath}")
259264

pkg/artifactory/resource/configuration/resource_artifactory_package_cleanup_policy.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const (
3232
PackageCleanupPolicyEnablementEndpointPath = "artifactory/api/cleanup/packages/policies/{policyKey}/enablement"
3333
)
3434

35-
var cleanupPolicySupportedPackageType = []string{"conan", "docker", "generic", "gradle", "maven", "npm", "nuget", "rpm"}
35+
var cleanupPolicySupportedPackageType = []string{"conan", "debian", "docker", "gems", "generic", "go", "gradle", "helm", "maven", "npm", "nuget", "pypi", "yum"}
3636

3737
func NewPackageCleanupPolicyResource() resource.Resource {
3838
return &PackageCleanupPolicyResource{

pkg/artifactory/resource/configuration/resource_artifactory_package_cleanup_policy_test.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ func TestAccPackageCleanupPolicy_full(t *testing.T) {
270270
search_criteria = {
271271
package_types = ["docker", "maven", "gradle"]
272272
repos = ["**"]
273-
included_packages = ["com/jfrog"]
273+
included_packages = ["**"]
274274
excluded_packages = ["com/jfrog/latest"]
275275
include_all_projects = true
276276
created_before_in_months = 12
@@ -345,7 +345,7 @@ func TestAccPackageCleanupPolicy_full(t *testing.T) {
345345
resource.TestCheckNoResourceAttr(fqrn, "search_criteria.include_projects"),
346346
resource.TestCheckResourceAttr(fqrn, "search_criteria.include_all_projects", "true"),
347347
resource.TestCheckResourceAttr(fqrn, "search_criteria.included_packages.#", "1"),
348-
resource.TestCheckTypeSetElemAttr(fqrn, "search_criteria.included_packages.*", "com/jfrog"),
348+
resource.TestCheckTypeSetElemAttr(fqrn, "search_criteria.included_packages.*", "**"),
349349
resource.TestCheckResourceAttr(fqrn, "search_criteria.excluded_packages.#", "1"),
350350
resource.TestCheckResourceAttr(fqrn, "search_criteria.excluded_packages.0", "com/jfrog/latest"),
351351
resource.TestCheckResourceAttr(fqrn, "search_criteria.created_before_in_months", "12"),
@@ -415,7 +415,6 @@ func TestAccPackageCleanupPolicy_with_project_key(t *testing.T) {
415415
repos = [artifactory_local_docker_v2_repository.{{ .repoName }}.key]
416416
included_packages = ["**"]
417417
excluded_packages = ["com/jfrog/latest"]
418-
// include_all_projects = true
419418
included_projects = []
420419
created_before_in_months = 1
421420
last_downloaded_before_in_months = 6
@@ -455,9 +454,8 @@ func TestAccPackageCleanupPolicy_with_project_key(t *testing.T) {
455454
search_criteria = {
456455
package_types = ["docker", "maven", "gradle"]
457456
repos = ["**"]
458-
included_packages = ["com/jfrog"]
457+
included_packages = ["**"]
459458
excluded_packages = ["com/jfrog/latest"]
460-
// include_all_projects = true
461459
included_projects = []
462460
created_before_in_months = 12
463461
last_downloaded_before_in_months = 24
@@ -530,7 +528,7 @@ func TestAccPackageCleanupPolicy_with_project_key(t *testing.T) {
530528
resource.TestCheckTypeSetElemAttr(fqrn, "search_criteria.package_types.*", "gradle"),
531529
resource.TestCheckResourceAttr(fqrn, "search_criteria.repos.#", "1"),
532530
resource.TestCheckResourceAttr(fqrn, "search_criteria.repos.0", "**"),
533-
resource.TestCheckTypeSetElemAttr(fqrn, "search_criteria.included_packages.*", "com/jfrog"),
531+
resource.TestCheckTypeSetElemAttr(fqrn, "search_criteria.included_packages.*", "**"),
534532
resource.TestCheckResourceAttr(fqrn, "search_criteria.excluded_packages.#", "1"),
535533
resource.TestCheckResourceAttr(fqrn, "search_criteria.excluded_packages.0", "com/jfrog/latest"),
536534
resource.TestCheckResourceAttr(fqrn, "search_criteria.created_before_in_months", "12"),

pkg/artifactory/resource/replication/resource_artifactory_remote_repository_replication.go

+1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ func (r *RemoteRepositoryReplicationResource) Schema(ctx context.Context, req re
171171
"check_binary_existence_in_filestore": schema.BoolAttribute{
172172
Optional: true,
173173
Computed: true,
174+
Default: booldefault.StaticBool(false),
174175
MarkdownDescription: "Enabling the `check_binary_existence_in_filestore` flag requires an Enterprise+ license. When true, enables distributed checksum storage. For more information, see " +
175176
"[Optimizing Repository Replication with Checksum-Based Storage](https://www.jfrog.com/confluence/display/JFROG/Repository+Replication#RepositoryReplication-OptimizingRepositoryReplicationUsingStorageLevelSynchronizationOptions).",
176177
},

pkg/artifactory/resource/replication/resource_artifactory_remote_repository_replication_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ func TestAccRemoteRepositoryReplication_InvalidPushCron_fails(t *testing.T) {
8383
sync_properties = true
8484
include_path_prefix_pattern = "/some-repo/"
8585
exclude_path_prefix_pattern = "/some-other-repo/"
86-
check_binary_existence_in_filestore = true
8786
}
8887
`
8988
resource.Test(t, resource.TestCase{
@@ -113,7 +112,6 @@ func TestAccRemoteRepositoryReplication_InvalidRclass_fails(t *testing.T) {
113112
sync_properties = true
114113
include_path_prefix_pattern = "/some-repo/"
115114
exclude_path_prefix_pattern = "/some-other-repo/"
116-
check_binary_existence_in_filestore = false
117115
}
118116
`
119117
resource.Test(t, resource.TestCase{
@@ -169,7 +167,6 @@ func TestAccRemoteRepositoryReplication_full(t *testing.T) {
169167
sync_properties = false
170168
include_path_prefix_pattern = "/some-repo-modified/"
171169
exclude_path_prefix_pattern = "/some-other-repo-modified/"
172-
check_binary_existence_in_filestore = false
173170
}
174171
`, params)
175172

pkg/artifactory/resource/security/resource_artifactory_api_key_test.go

+13
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ import (
1212
)
1313

1414
func TestAccApiKey(t *testing.T) {
15+
client := acctest.GetTestResty(t)
16+
version, err := util.GetArtifactoryVersion(client)
17+
if err != nil {
18+
t.Fatal(err)
19+
}
20+
valid, err := util.CheckVersion(version, "7.98.1")
21+
if err != nil {
22+
t.Fatal(err)
23+
}
24+
if valid {
25+
t.Skipf("Artifactory version %s is 7.98.1 or later", version)
26+
}
27+
1528
fqrn := "artifactory_api_key.foobar"
1629
const apiKey = `
1730
resource "artifactory_api_key" "foobar" {}

0 commit comments

Comments
 (0)