From 366352d49ac63b10f4f10cf1eaceedc8974a9230 Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Fri, 5 Apr 2024 16:52:22 -0700 Subject: [PATCH 1/3] Fix incorrect package type of 'helmoci' repo Add tests to verify 'package_type' attribute. --- .../resource_artifactory_virtual_helmoci_repository.go | 2 +- .../resource_artifactory_virtual_repository_test.go | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/artifactory/resource/repository/virtual/resource_artifactory_virtual_helmoci_repository.go b/pkg/artifactory/resource/repository/virtual/resource_artifactory_virtual_helmoci_repository.go index 218f7804d..291d79ef2 100644 --- a/pkg/artifactory/resource/repository/virtual/resource_artifactory_virtual_helmoci_repository.go +++ b/pkg/artifactory/resource/repository/virtual/resource_artifactory_virtual_helmoci_repository.go @@ -28,7 +28,7 @@ func ResourceArtifactoryVirtualHelmOciRepository() *schema.Resource { unpackVirtualRepository := func(data *schema.ResourceData) (interface{}, string, error) { d := &utilsdk.ResourceData{ResourceData: data} repo := HelmOciVirtualRepositoryParams{ - RepositoryBaseParams: UnpackBaseVirtRepo(data, DockerPackageType), + RepositoryBaseParams: UnpackBaseVirtRepo(data, HelmOciPackageType), ResolveOCITagsByTimestamp: d.GetBool("resolve_oci_tags_by_timestamp", false), } diff --git a/pkg/artifactory/resource/repository/virtual/resource_artifactory_virtual_repository_test.go b/pkg/artifactory/resource/repository/virtual/resource_artifactory_virtual_repository_test.go index d2f22ef82..3c717ba94 100644 --- a/pkg/artifactory/resource/repository/virtual/resource_artifactory_virtual_repository_test.go +++ b/pkg/artifactory/resource/repository/virtual/resource_artifactory_virtual_repository_test.go @@ -767,8 +767,8 @@ func TestAccAllVirtualGradleLikeRepository(t *testing.T) { } // if you wish to override any of the default fields, just pass it as "extraFields" as these will overwrite -func mkNewVirtualTestCase(repoType string, t *testing.T, extraFields map[string]interface{}) (*testing.T, resource.TestCase) { - _, fqrn, name := testutil.MkNames("terraform-virtual-test-repo-full-", fmt.Sprintf("artifactory_virtual_%s_repository", repoType)) +func mkNewVirtualTestCase(packageType string, t *testing.T, extraFields map[string]interface{}) (*testing.T, resource.TestCase) { + _, fqrn, name := testutil.MkNames("terraform-virtual-test-repo-full-", fmt.Sprintf("artifactory_virtual_%s_repository", packageType)) remoteRepoName := fmt.Sprintf("%s-remote", name) defaultFields := map[string]interface{}{ "key": name, @@ -791,17 +791,19 @@ func mkNewVirtualTestCase(repoType string, t *testing.T, extraFields map[string] ` extraChecks := testutil.MapToTestChecks(fqrn, extraFields) defaultChecks := testutil.MapToTestChecks(fqrn, allFields) + defaultChecks = append(defaultChecks, resource.TestCheckResourceAttr(fqrn, "package_type", packageType)) checks := append(defaultChecks, extraChecks...) - config := fmt.Sprintf(virtualRepoFull, repoType, name, remoteRepoName, allFieldsHcl) + config := fmt.Sprintf(virtualRepoFull, packageType, name, remoteRepoName, allFieldsHcl) updatedFields := utilsdk.MergeMaps(defaultFields, extraFields, map[string]any{ "description": "", "notes": "", }) updatedFieldsHcl := utilsdk.FmtMapToHcl(updatedFields) - updatedConfig := fmt.Sprintf(virtualRepoFull, repoType, name, remoteRepoName, updatedFieldsHcl) + updatedConfig := fmt.Sprintf(virtualRepoFull, packageType, name, remoteRepoName, updatedFieldsHcl) updatedChecks := testutil.MapToTestChecks(fqrn, updatedFields) + updatedChecks = append(updatedChecks, resource.TestCheckResourceAttr(fqrn, "package_type", packageType)) return t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(t) }, From 62d8d44f6ee12c343e66f8e8cf283d826d223f4e Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Fri, 5 Apr 2024 16:54:12 -0700 Subject: [PATCH 2/3] Update CHANGELOG --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29d825f23..937c641b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 10.4.4 (Apr 8, 2024) + +BUG FIXES: + +* resource/artifactory_virtual_helmoci_repository: Fix incorrect package type Issue: [#925](https://github.com/jfrog/terraform-provider-artifactory/issues/925) PR: [#926](https://github.com/jfrog/terraform-provider-artifactory/pull/926) + ## 10.4.3 (Apr 1, 2024) BUG FIXES: From 03ad0619241f1815f514bfaa0803b3cd1220771e Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Fri, 5 Apr 2024 17:03:04 -0700 Subject: [PATCH 3/3] Update CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 937c641b4..171825abd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ BUG FIXES: -* resource/artifactory_virtual_helmoci_repository: Fix incorrect package type Issue: [#925](https://github.com/jfrog/terraform-provider-artifactory/issues/925) PR: [#926](https://github.com/jfrog/terraform-provider-artifactory/pull/926) +* resource/artifactory_virtual_helmoci_repository: Fix incorrect package type. Issue: [#925](https://github.com/jfrog/terraform-provider-artifactory/issues/925) PR: [#926](https://github.com/jfrog/terraform-provider-artifactory/pull/926) ## 10.4.3 (Apr 1, 2024)