Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'curated' attribute to Curation supported repository resources #844

Merged
merged 4 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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 CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
## 9.7.4 (Nov 3, 2023). Tested on Artifactory 7.71.3 with Terraform CLI v1.6.3
## 9.7.5 (Nov 8, 2023). Tested on Artifactory 7.71.4 with Terraform CLI v1.6.3

IMPROVEMENTS:

* resource/artifactory_remote_docker_repository, resource/artifactory_remote_maven_repository, resource/artifactory_npm_docker_repository,resource/artifactory_remote_pypi_repository: Add `curated` attribute to support enabling the repository resource for Curation Service. Issue: [#831](https://github.com/jfrog/terraform-provider-artifactory/issues/831) PR: [#844](https://github.com/jfrog/terraform-provider-artifactory/pull/844)
* resource/artifactory_pull_replication: Add missing deprecation message to documentation. PR: [#843](https://github.com/jfrog/terraform-provider-artifactory/pull/843)

## 9.7.4 (Nov 6, 2023). Tested on Artifactory 7.71.3 with Terraform CLI v1.6.3

IMPROVEMENTS:

Expand Down
1 change: 1 addition & 0 deletions docs/resources/remote_docker_repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ The following arguments are supported, along with the [common list of arguments
This value `[**]` must be assigned to the attribute manually, if user don't specify any other non-default values.
We don't want to make this attribute required, but it must be set to avoid the state drift on update. Note: Artifactory assigns
`[**]` on update if HCL doesn't have the attribute set or the list is empty.
* `curated` - (Optional, Default: `false`) Enable repository to be protected by the Curation service.

## Import

Expand Down
1 change: 1 addition & 0 deletions docs/resources/remote_maven_repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ The following arguments are supported, along with the [common list of arguments
* `reject_invalid_jars` - (Optional, Default: `false`) Reject the caching of jar files that are found to be invalid. For example, pseudo jars retrieved behind a "captive portal".
* `remote_repo_checksum_policy_type` - (Optional, Default: `generate-if-absent`) Checking the Checksum effectively verifies the integrity of a deployed resource. The Checksum Policy determines how the system behaves when a client checksum for a remote resource is missing or conflicts with the locally calculated checksum. Available policies are `generate-if-absent`, `fail`, `ignore-and-generate`, and `pass-thru`.
* `metadata_retrieval_timeout_secs` - (Optional, Default: 60) This value refers to the number of seconds to cache metadata files before checking for newer versions on remote server. A value of 0 indicates no caching. Cannot be larger than `retrieval_cache_period_seconds` attribute.
* `curated` - (Optional, Default: `false`) Enable repository to be protected by the Curation service.

## Import

Expand Down
1 change: 1 addition & 0 deletions docs/resources/remote_npm_repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ The following arguments are supported, along with the [common list of arguments
* `description` - (Optional)
* `notes` - (Optional)
* `url` - (Required) The remote repo URL.
* `curated` - (Optional, Default: `false`) Enable repository to be protected by the Curation service.

## Import

Expand Down
1 change: 1 addition & 0 deletions docs/resources/remote_pypi_repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ The following arguments are supported, along with the [common list of arguments
* `url` - (Required) The remote repo URL.
* `pypi_registry_url` - (Optional) To configure the remote repo to proxy public external PyPI repository, or a PyPI repository hosted on another Artifactory server. See JFrog Pypi documentation [here](https://www.jfrog.com/confluence/display/JFROG/PyPI+Repositories) for the usage details. Default value is `https://pypi.org`.
* `pypi_repository_suffix` - (Optional) Usually should be left as a default for `simple`, unless the remote is a PyPI server that has custom registry suffix, like +simple in DevPI. Default value is `simple`.
* `curated` - (Optional, Default: `false`) Enable repository to be protected by the Curation service.

## Import

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import (
"github.com/jfrog/terraform-provider-artifactory/v9/pkg/artifactory/resource/security"
"github.com/jfrog/terraform-provider-shared/testutil"
utilsdk "github.com/jfrog/terraform-provider-shared/util/sdk"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)

func skipFederatedRepo() (bool, string) {
Expand Down Expand Up @@ -89,10 +87,9 @@ func federatedTestCase(repoType string, t *testing.T) (*testing.T, resource.Test
}

func TestAccDataSourceFederatedRepoGenericTypes(t *testing.T) {
for _, repo := range federated.PackageTypesLikeGeneric {
title := cases.Title(language.AmericanEnglish).String(repo)
t.Run(title, func(t *testing.T) {
resource.Test(federatedTestCase(repo, t))
for _, packageType := range federated.PackageTypesLikeGeneric {
t.Run(packageType, func(t *testing.T) {
resource.Test(federatedTestCase(packageType, t))
})
}
}
Expand Down Expand Up @@ -827,10 +824,9 @@ func makeFederatedGradleLikeRepoTestCase(repoType string, t *testing.T) (*testin
}

func TestAccDataSourceFederatedAllGradleLikePackageTypes(t *testing.T) {
for _, repoType := range repository.GradleLikePackageTypes {
title := cases.Title(language.AmericanEnglish).String(repoType)
t.Run(title, func(t *testing.T) {
resource.Test(makeFederatedGradleLikeRepoTestCase(repoType, t))
for _, packageType := range repository.GradleLikePackageTypes {
t.Run(packageType, func(t *testing.T) {
resource.Test(makeFederatedGradleLikeRepoTestCase(packageType, t))
})
}
}
Expand Down Expand Up @@ -1134,8 +1130,7 @@ func makeFederatedTerraformRepoTestCase(registryType string, t *testing.T) (*tes

func TestAccDataSourceFederatedTerraformRepositories(t *testing.T) {
for _, registryType := range []string{"module", "provider"} {
title := cases.Title(language.AmericanEnglish).String(registryType)
t.Run(title, func(t *testing.T) {
t.Run(registryType, func(t *testing.T) {
resource.Test(makeFederatedTerraformRepoTestCase(registryType, t))
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package local_test

import (
"fmt"
"strings"
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
Expand All @@ -12,14 +11,11 @@ import (
"github.com/jfrog/terraform-provider-artifactory/v9/pkg/artifactory/resource/security"
"github.com/jfrog/terraform-provider-shared/testutil"
utilsdk "github.com/jfrog/terraform-provider-shared/util/sdk"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)

func TestAccDataSourceLocalAllPackageTypes(t *testing.T) {
for _, packageType := range local.PackageTypesLikeGeneric {
title := fmt.Sprintf("%s", cases.Title(language.AmericanEnglish).String(strings.ToLower(packageType)))
t.Run(title, func(t *testing.T) {
t.Run(packageType, func(t *testing.T) {
resource.Test(mkTestCase(packageType, t))
})
}
Expand Down Expand Up @@ -521,9 +517,9 @@ func makeDataSourceLocalGradleLikeRepoTestCase(repoType string, t *testing.T) (*
}

func TestAccDataSourceLocalAllGradleLikePackageTypes(t *testing.T) {
for _, repoType := range repository.GradleLikePackageTypes {
t.Run(fmt.Sprintf("TestDataSourceLocal%sRepo", strings.Title(strings.ToLower(repoType))), func(t *testing.T) {
resource.Test(makeDataSourceLocalGradleLikeRepoTestCase(repoType, t))
for _, packageType := range repository.GradleLikePackageTypes {
t.Run(packageType, func(t *testing.T) {
resource.Test(makeDataSourceLocalGradleLikeRepoTestCase(packageType, t))
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ func DataSourceArtifactoryRemoteMavenRepository() *schema.Resource {
return nil, err
}

return &remote.JavaRemoteRepo{
RepositoryRemoteBaseParams: remote.RepositoryRemoteBaseParams{
Rclass: rclass,
PackageType: remote.MavenPackageType,
RepoLayoutRef: repoLayout.(string),
return &remote.MavenRemoteRepo{
JavaRemoteRepo: remote.JavaRemoteRepo{
RepositoryRemoteBaseParams: remote.RepositoryRemoteBaseParams{
Rclass: rclass,
PackageType: remote.MavenPackageType,
RepoLayoutRef: repoLayout.(string),
},
SuppressPomConsistencyChecks: false,
},
SuppressPomConsistencyChecks: false,
}, nil
}

mavenSchema := remote.JavaRemoteSchema(false, remote.MavenPackageType, false)
mavenSchema := remote.MavenRemoteSchema(false)

return &schema.Resource{
Schema: mavenSchema,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package remote

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/jfrog/terraform-provider-artifactory/v9/pkg/artifactory/datasource/repository"
resource_repository "github.com/jfrog/terraform-provider-artifactory/v9/pkg/artifactory/resource/repository"
"github.com/jfrog/terraform-provider-artifactory/v9/pkg/artifactory/resource/repository/remote"
"github.com/jfrog/terraform-provider-shared/packer"
)

func DataSourceArtifactoryRemoteNpmRepository() *schema.Resource {
constructor := func() (interface{}, error) {
repoLayout, err := resource_repository.GetDefaultRepoLayoutRef(rclass, remote.GenericPackageType)()
if err != nil {
return nil, err
}

return &remote.NpmRemoteRepo{
RepositoryRemoteBaseParams: remote.RepositoryRemoteBaseParams{
Rclass: rclass,
PackageType: remote.NpmPackageType,
RepoLayoutRef: repoLayout.(string),
},
}, nil
}

npmSchema := remote.NpmRemoteSchema(false)

return &schema.Resource{
Schema: npmSchema,
ReadContext: repository.MkRepoReadDataSource(packer.Default(npmSchema), constructor),
Description: "Provides a data source for a remote NPM repository",
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ func TestAccDataSourceRemoteDockerRepository(t *testing.T) {
enable_token_authentication = true
block_pushing_schema1 = true
external_dependencies_patterns = ["*foo"]
curated = false
}

data "artifactory_remote_docker_repository" "{{ .name }}" {
Expand All @@ -293,6 +294,7 @@ func TestAccDataSourceRemoteDockerRepository(t *testing.T) {
resource.TestCheckResourceAttr(fqrn, "block_pushing_schema1", "true"),
resource.TestCheckResourceAttr(fqrn, "external_dependencies_patterns.#", "1"),
resource.TestCheckResourceAttr(fqrn, "external_dependencies_patterns.0", "*foo"),
resource.TestCheckResourceAttr(fqrn, "curated", "false"),
),
},
},
Expand Down Expand Up @@ -497,6 +499,7 @@ func TestAccDataSourceRemoteMavenRepository(t *testing.T) {
params["name"] = name
params["resource_name"] = "artifactory_remote_maven_repository"
params["suppress_pom_consistency_checks"] = false
params["curated"] = false

resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
Expand All @@ -514,6 +517,7 @@ func TestAccDataSourceRemoteMavenRepository(t *testing.T) {
resource.TestCheckResourceAttr(fqrn, "handle_snapshots", fmt.Sprintf("%t", params["handle_snapshots"])),
resource.TestCheckResourceAttr(fqrn, "suppress_pom_consistency_checks", fmt.Sprintf("%t", params["suppress_pom_consistency_checks"])),
resource.TestCheckResourceAttr(fqrn, "reject_invalid_jars", fmt.Sprintf("%t", params["reject_invalid_jars"])),
resource.TestCheckResourceAttr(fqrn, "curated", "false"),
),
},
},
Expand Down Expand Up @@ -571,8 +575,9 @@ func TestAccDataSourceRemotePypiRepository(t *testing.T) {
config := utilsdk.ExecuteTemplate(
"TestAccDataSourceRemotePypiRepository",
`resource "artifactory_remote_pypi_repository" "{{ .name }}" {
key = "{{ .name }}"
url = "http://tempurl.org"
key = "{{ .name }}"
url = "http://tempurl.org"
curated = false
}

data "artifactory_remote_pypi_repository" "{{ .name }}" {
Expand All @@ -595,6 +600,7 @@ func TestAccDataSourceRemotePypiRepository(t *testing.T) {
resource.TestCheckResourceAttr(fqrn, "url", "http://tempurl.org"),
resource.TestCheckResourceAttr(fqrn, "pypi_registry_url", "https://pypi.org"),
resource.TestCheckResourceAttr(fqrn, "pypi_repository_suffix", "simple"),
resource.TestCheckResourceAttr(fqrn, "curated", "false"),
),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package virtual_test

import (
"fmt"
"strings"
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
Expand All @@ -12,17 +11,11 @@ import (
"github.com/jfrog/terraform-provider-artifactory/v9/pkg/artifactory/resource/security"
"github.com/jfrog/terraform-provider-shared/testutil"
utilsdk "github.com/jfrog/terraform-provider-shared/util/sdk"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)

func TestAccDataSourceVirtualAllGenericLikePackageTypes(t *testing.T) {
for _, packageType := range virtual.PackageTypesLikeGeneric {
title := fmt.Sprintf(
"TestVirtual%sRepo",
cases.Title(language.AmericanEnglish).String(strings.ToLower(packageType)),
)
t.Run(title, func(t *testing.T) {
t.Run(packageType, func(t *testing.T) {
resource.Test(mkNewVirtualTestCase(packageType, t, map[string]interface{}{
"description": fmt.Sprintf("%s virtual repository public description testing.", packageType),
}))
Expand All @@ -32,11 +25,7 @@ func TestAccDataSourceVirtualAllGenericLikePackageTypes(t *testing.T) {

func TestAccDataSourceVirtualAllGenericLikeRetrievalPackageTypes(t *testing.T) {
for _, packageType := range virtual.PackageTypesLikeGenericWithRetrievalCachePeriodSecs {
title := fmt.Sprintf(
"TestVirtual%sRepo",
cases.Title(language.AmericanEnglish).String(strings.ToLower(packageType)),
)
t.Run(title, func(t *testing.T) {
t.Run(packageType, func(t *testing.T) {
resource.Test(mkNewVirtualTestCase(packageType, t, map[string]interface{}{
"description": fmt.Sprintf("%s virtual repository public description testing.", packageType),
"retrieval_cache_period_seconds": 650,
Expand All @@ -47,9 +36,7 @@ func TestAccDataSourceVirtualAllGenericLikeRetrievalPackageTypes(t *testing.T) {

func TestAccDataSourceVirtualAllGradleLikePackageTypes(t *testing.T) {
for _, packageType := range repository.GradleLikePackageTypes {
title := fmt.Sprintf("TestVirtual%sRepo",
cases.Title(language.AmericanEnglish).String(strings.ToLower(packageType)))
t.Run(title, func(t *testing.T) {
t.Run(packageType, func(t *testing.T) {
resource.Test(mkNewVirtualTestCase(packageType, t, map[string]interface{}{
"description": fmt.Sprintf("%s virtual repository public description testing.", packageType),
"force_maven_authentication": true,
Expand Down
1 change: 1 addition & 0 deletions pkg/artifactory/provider/datasources.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func datasourcesMap() map[string]*schema.Resource {
"artifactory_remote_go_repository": datasource_remote.DataSourceArtifactoryRemoteGoRepository(),
"artifactory_remote_helm_repository": datasource_remote.DataSourceArtifactoryRemoteHelmRepository(),
"artifactory_remote_maven_repository": datasource_remote.DataSourceArtifactoryRemoteMavenRepository(),
"artifactory_remote_npm_repository": datasource_remote.DataSourceArtifactoryRemoteNpmRepository(),
"artifactory_remote_nuget_repository": datasource_remote.DataSourceArtifactoryRemoteNugetRepository(),
"artifactory_remote_pypi_repository": datasource_remote.DataSourceArtifactoryRemotePypiRepository(),
"artifactory_remote_terraform_repository": datasource_remote.DataSourceArtifactoryRemoteTerraformRepository(),
Expand Down
1 change: 1 addition & 0 deletions pkg/artifactory/provider/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func resourcesMap() map[string]*schema.Resource {
"artifactory_remote_helm_repository": remote.ResourceArtifactoryRemoteHelmRepository(),
"artifactory_remote_huggingfaceml_repository": remote.ResourceArtifactoryRemoteHuggingFaceRepository(),
"artifactory_remote_maven_repository": remote.ResourceArtifactoryRemoteMavenRepository(),
"artifactory_remote_npm_repository": remote.ResourceArtifactoryRemoteNpmRepository(),
"artifactory_remote_nuget_repository": remote.ResourceArtifactoryRemoteNugetRepository(),
"artifactory_remote_pypi_repository": remote.ResourceArtifactoryRemotePypiRepository(),
"artifactory_remote_terraform_repository": remote.ResourceArtifactoryRemoteTerraformRepository(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import (
"github.com/jfrog/terraform-provider-shared/testutil"
utilsdk "github.com/jfrog/terraform-provider-shared/util/sdk"
"github.com/jfrog/terraform-provider-shared/validator"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)

// To make tests work add `ARTIFACTORY_URL_2=http://artifactory-2:8081` or `ARTIFACTORY_URL_2=http://host.docker.internal:9081`
Expand Down Expand Up @@ -183,10 +181,9 @@ func federatedTestCase(repoType string, t *testing.T) (*testing.T, resource.Test
}

func TestAccFederatedRepoGenericTypes(t *testing.T) {
for _, repo := range federated.PackageTypesLikeGeneric {
title := cases.Title(language.AmericanEnglish).String(repo)
t.Run(title, func(t *testing.T) {
resource.Test(federatedTestCase(repo, t))
for _, packageType := range federated.PackageTypesLikeGeneric {
t.Run(packageType, func(t *testing.T) {
resource.Test(federatedTestCase(packageType, t))
})
}
}
Expand Down Expand Up @@ -1122,10 +1119,9 @@ func makeFederatedGradleLikeRepoTestCase(repoType string, t *testing.T) (*testin
}

func TestAccFederatedAllGradleLikePackageTypes(t *testing.T) {
for _, repoType := range repository.GradleLikePackageTypes {
title := cases.Title(language.AmericanEnglish).String(repoType)
t.Run(title, func(t *testing.T) {
resource.Test(makeFederatedGradleLikeRepoTestCase(repoType, t))
for _, packageType := range repository.GradleLikePackageTypes {
t.Run(packageType, func(t *testing.T) {
resource.Test(makeFederatedGradleLikeRepoTestCase(packageType, t))
})
}
}
Expand Down Expand Up @@ -1369,8 +1365,7 @@ func makeFederatedTerraformRepoTestCase(registryType string, t *testing.T) (*tes

func TestAccFederatedTerraformRepositories(t *testing.T) {
for _, registryType := range []string{"module", "provider"} {
title := cases.Title(language.AmericanEnglish).String(registryType)
t.Run(title, func(t *testing.T) {
t.Run(registryType, func(t *testing.T) {
resource.Test(makeFederatedTerraformRepoTestCase(registryType, t))
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1042,9 +1042,9 @@ func makeLocalRepoTestCase(repoType string, t *testing.T) (*testing.T, resource.

// Test case to cover when repoLayoutRef not left as blank and set to some value other than default
func TestAccAllLocalRepoTypes(t *testing.T) {
for _, repo := range local.PackageTypesLikeGeneric {
t.Run(repo, func(t *testing.T) {
resource.Test(makeLocalRepoTestCase(repo, t))
for _, packageType := range local.PackageTypesLikeGeneric {
t.Run(packageType, func(t *testing.T) {
resource.Test(makeLocalRepoTestCase(packageType, t))
})
}
}
Expand Down Expand Up @@ -1087,9 +1087,9 @@ func makeLocalGradleLikeRepoTestCase(repoType string, t *testing.T) (*testing.T,
}

func TestAccAllGradleLikeLocalRepoTypes(t *testing.T) {
for _, repoType := range repository.GradleLikePackageTypes {
t.Run(fmt.Sprintf("TestLocal%sRepo", strings.Title(strings.ToLower(repoType))), func(t *testing.T) {
resource.Test(makeLocalGradleLikeRepoTestCase(repoType, t))
for _, packageType := range repository.GradleLikePackageTypes {
t.Run(packageType, func(t *testing.T) {
resource.Test(makeLocalGradleLikeRepoTestCase(packageType, t))
})
}
}
Expand Down
16 changes: 16 additions & 0 deletions pkg/artifactory/resource/repository/remote/curation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package remote

import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

type RepositoryCurationParams struct {
Curated bool `json:"curated"`
}

var CurationRemoteRepoSchema = map[string]*schema.Schema{
"curated": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Enable repository to be protected by the Curation service.",
},
}
Loading
Loading