Skip to content

Commit

Permalink
Merge pull request #1107 from jfrog/GH-1105-fix-remote-repo-replicati…
Browse files Browse the repository at this point in the history
…on-errors

Fix unknown value error for 'check_binary_existence_in_filestore'
  • Loading branch information
alexhung authored Oct 30, 2024
2 parents 7d22070 + 4110183 commit 29d0f37
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 13 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
## 12.3.2 (October 29, 2024). Tested on Artifactory 7.90.15 with Terraform 1.9.8 and OpenTofu 1.8.4
## 12.3.2 (October 30, 2024). Tested on Artifactory 7.98.7 with Terraform 1.9.8 and OpenTofu 1.8.4

IMPROVEMENTS:

* resource/artifactory_package_cleanup_policy: Update valid values for `package_types` attribute. PR: [#1107](https://github.com/jfrog/terraform-provider-artifactory/pull/1107)

BUG FIXES:

* 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)
* 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)

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

Expand Down
2 changes: 1 addition & 1 deletion docs/resources/package_cleanup_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ resource "artifactory_package_cleanup_policy" "my-cleanup-policy" {
Required:

- `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 = ["**"]`
- `package_types` (Set of String) Types of packages to be removed. Support: conan, docker, generic, gradle, maven, npm, nuget, rpm.
- `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.
- `repos` (Set of String) Specify patterns for repository names or explicit repository names. For including all repos use `**`. Example: `repos = ["**"]`

Optional:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ func (d *FileListDataSource) Read(ctx context.Context, req datasource.ReadReques
}

var fileList FileListAPIModel
folderPath := ""
if data.FolderPath.ValueString() != "/" { // only use config folder path if it isn't just "/"
folderPath = data.FolderPath.ValueString()
}

response, err := d.ProviderData.Client.R().
SetQueryParams(map[string]string{
"list": "",
Expand All @@ -253,7 +258,7 @@ func (d *FileListDataSource) Read(ctx context.Context, req datasource.ReadReques
SetResult(&fileList).
SetPathParams(map[string]string{
"repoKey": data.RepositoryKey.ValueString(),
"folderPath": data.FolderPath.ValueString(),
"folderPath": folderPath,
}).
Get("artifactory/api/storage/{repoKey}/{folderPath}")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const (
PackageCleanupPolicyEnablementEndpointPath = "artifactory/api/cleanup/packages/policies/{policyKey}/enablement"
)

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

func NewPackageCleanupPolicyResource() resource.Resource {
return &PackageCleanupPolicyResource{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func TestAccPackageCleanupPolicy_full(t *testing.T) {
search_criteria = {
package_types = ["docker", "maven", "gradle"]
repos = ["**"]
included_packages = ["com/jfrog"]
included_packages = ["**"]
excluded_packages = ["com/jfrog/latest"]
include_all_projects = true
created_before_in_months = 12
Expand Down Expand Up @@ -345,7 +345,7 @@ func TestAccPackageCleanupPolicy_full(t *testing.T) {
resource.TestCheckNoResourceAttr(fqrn, "search_criteria.include_projects"),
resource.TestCheckResourceAttr(fqrn, "search_criteria.include_all_projects", "true"),
resource.TestCheckResourceAttr(fqrn, "search_criteria.included_packages.#", "1"),
resource.TestCheckTypeSetElemAttr(fqrn, "search_criteria.included_packages.*", "com/jfrog"),
resource.TestCheckTypeSetElemAttr(fqrn, "search_criteria.included_packages.*", "**"),
resource.TestCheckResourceAttr(fqrn, "search_criteria.excluded_packages.#", "1"),
resource.TestCheckResourceAttr(fqrn, "search_criteria.excluded_packages.0", "com/jfrog/latest"),
resource.TestCheckResourceAttr(fqrn, "search_criteria.created_before_in_months", "12"),
Expand Down Expand Up @@ -415,7 +415,6 @@ func TestAccPackageCleanupPolicy_with_project_key(t *testing.T) {
repos = [artifactory_local_docker_v2_repository.{{ .repoName }}.key]
included_packages = ["**"]
excluded_packages = ["com/jfrog/latest"]
// include_all_projects = true
included_projects = []
created_before_in_months = 1
last_downloaded_before_in_months = 6
Expand Down Expand Up @@ -455,9 +454,8 @@ func TestAccPackageCleanupPolicy_with_project_key(t *testing.T) {
search_criteria = {
package_types = ["docker", "maven", "gradle"]
repos = ["**"]
included_packages = ["com/jfrog"]
included_packages = ["**"]
excluded_packages = ["com/jfrog/latest"]
// include_all_projects = true
included_projects = []
created_before_in_months = 12
last_downloaded_before_in_months = 24
Expand Down Expand Up @@ -530,7 +528,7 @@ func TestAccPackageCleanupPolicy_with_project_key(t *testing.T) {
resource.TestCheckTypeSetElemAttr(fqrn, "search_criteria.package_types.*", "gradle"),
resource.TestCheckResourceAttr(fqrn, "search_criteria.repos.#", "1"),
resource.TestCheckResourceAttr(fqrn, "search_criteria.repos.0", "**"),
resource.TestCheckTypeSetElemAttr(fqrn, "search_criteria.included_packages.*", "com/jfrog"),
resource.TestCheckTypeSetElemAttr(fqrn, "search_criteria.included_packages.*", "**"),
resource.TestCheckResourceAttr(fqrn, "search_criteria.excluded_packages.#", "1"),
resource.TestCheckResourceAttr(fqrn, "search_criteria.excluded_packages.0", "com/jfrog/latest"),
resource.TestCheckResourceAttr(fqrn, "search_criteria.created_before_in_months", "12"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ func (r *RemoteRepositoryReplicationResource) Schema(ctx context.Context, req re
"check_binary_existence_in_filestore": schema.BoolAttribute{
Optional: true,
Computed: true,
Default: booldefault.StaticBool(false),
MarkdownDescription: "Enabling the `check_binary_existence_in_filestore` flag requires an Enterprise+ license. When true, enables distributed checksum storage. For more information, see " +
"[Optimizing Repository Replication with Checksum-Based Storage](https://www.jfrog.com/confluence/display/JFROG/Repository+Replication#RepositoryReplication-OptimizingRepositoryReplicationUsingStorageLevelSynchronizationOptions).",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ func TestAccRemoteRepositoryReplication_InvalidPushCron_fails(t *testing.T) {
sync_properties = true
include_path_prefix_pattern = "/some-repo/"
exclude_path_prefix_pattern = "/some-other-repo/"
check_binary_existence_in_filestore = true
}
`
resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -113,7 +112,6 @@ func TestAccRemoteRepositoryReplication_InvalidRclass_fails(t *testing.T) {
sync_properties = true
include_path_prefix_pattern = "/some-repo/"
exclude_path_prefix_pattern = "/some-other-repo/"
check_binary_existence_in_filestore = false
}
`
resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -169,7 +167,6 @@ func TestAccRemoteRepositoryReplication_full(t *testing.T) {
sync_properties = false
include_path_prefix_pattern = "/some-repo-modified/"
exclude_path_prefix_pattern = "/some-other-repo-modified/"
check_binary_existence_in_filestore = false
}
`, params)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@ import (
)

func TestAccApiKey(t *testing.T) {
client := acctest.GetTestResty(t)
version, err := util.GetArtifactoryVersion(client)
if err != nil {
t.Fatal(err)
}
valid, err := util.CheckVersion(version, "7.98.1")
if err != nil {
t.Fatal(err)
}
if valid {
t.Skipf("Artifactory version %s is 7.98.1 or later", version)
}

fqrn := "artifactory_api_key.foobar"
const apiKey = `
resource "artifactory_api_key" "foobar" {}
Expand Down

0 comments on commit 29d0f37

Please sign in to comment.