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

GH-657 update project key validation #662

Merged
merged 4 commits into from
Feb 24, 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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 6.30.1 (February 25, 2023).

BUG FIXES:
* resource/artifactory_*_repository: Update `project_key` attribute validation to match Artifactory Project. PR: [#662](https://github.com/jfrog/terraform-provider-artifactory/pull/662)

## 6.30.0 (February 24, 2023).

IMPROVEMENTS:
Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/repository/local/local.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ In addition to all arguments above, the following attributes are exported for al
contain spaces or special characters.
* `description` - Description of the repository
* `notes`
* `project_key` - Project key for assigning this repository to. Will be 3 - 10 lowercase alphanumeric and
* `project_key` - Project key for assigning this repository to. Will be 2 - 20 lowercase alphanumeric and
hyphen characters. When assigning repository to a project, repository key must be prefixed with project key, separated
by a dash. We don't recommend using this attribute to assign the repository to the project. Use the `repos` attribute
in Project provider to manage the list of repositories.
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/local.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The following arguments are supported:
contain spaces or special characters.
* `description` - (Optional)
* `notes` - (Optional)
* `project_key` - (Optional) Project key for assigning this repository to. Must be 3 - 10 lowercase alphanumeric and hyphen characters.
* `project_key` - (Optional) Project key for assigning this repository to. Must be 2 - 20 lowercase alphanumeric and hyphen characters.
When assigning repository to a project, repository key must be prefixed with project key, separated by a dash.
We don't recommend using this attribute to assign the repository to the project. Use the `repos` attribute in Project provider
to manage the list of repositories.
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/remote.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ All generic repo arguments are supported, in addition to:
* `key` - (Required) A mandatory identifier for the repository that must be unique. It cannot begin with a number or contain spaces or special characters.
* `description` - (Optional) Public description.
* `notes` - (Optional) Internal description.
* `project_key` - (Optional) Project key for assigning this repository to. Must be 3 - 10 lowercase alphanumeric and hyphen characters.
* `project_key` - (Optional) Project key for assigning this repository to. Must be 2 - 20 lowercase alphanumeric and hyphen characters.
When assigning repository to a project, repository key must be prefixed with project key, separated by a dash.
We don't recommend using this attribute to assign the repository to the project. Use the `repos` attribute in Project provider
to manage the list of repositories.
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/virtual.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The following arguments are supported:
* `key` - (Required) A mandatory identifier for the repository that must be unique. It cannot begin with a number or
contain spaces or special characters.
* `repositories` - (Optional) The effective list of actual repositories included in this virtual repository.
* `project_key` - (Optional) Project key for assigning this repository to. Must be 3 - 10 lowercase alphanumeric and hyphen characters.
* `project_key` - (Optional) Project key for assigning this repository to. Must be 2 - 20 lowercase alphanumeric and hyphen characters.
When assigning repository to a project, repository key must be prefixed with project key, separated by a dash.
We don't recommend using this attribute to assign the repository to the project. Use the `repos` attribute in Project provider
to manage the list of repositories.
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module github.com/jfrog/terraform-provider-artifactory/v6

// if you need to do local dev, literally just uncomment the line below
//replace github.com/jfrog/terraform-provider-shared => ../terraform-provider-shared
// replace github.com/jfrog/terraform-provider-shared => ../terraform-provider-shared

require (
github.com/go-resty/resty/v2 v2.7.0
github.com/google/go-querystring v1.1.0
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-log v0.4.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.16.0
github.com/jfrog/terraform-provider-shared v1.10.0
github.com/jfrog/terraform-provider-shared v1.11.0
github.com/sethvargo/go-password v0.2.0
github.com/stretchr/testify v1.7.0
golang.org/x/exp v0.0.0-20220407100705-7b9b53b0aca4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
github.com/jfrog/terraform-provider-shared v1.10.0 h1:cVFtwiplKG+cVqpKWShMK2RzcM37qlu18JpX0bIKVnk=
github.com/jfrog/terraform-provider-shared v1.10.0/go.mod h1:oIzDjD2mOlfXymkzwp5kbFG3Bqy3ymVGYX50CrCxiIE=
github.com/jfrog/terraform-provider-shared v1.11.0 h1:6VryswiIz5jf+psS3fQLxlPgAZA5WsMREMFkE6woYuI=
github.com/jfrog/terraform-provider-shared v1.11.0/go.mod h1:n6855hIUDhypnXsJl8UrstVFkcnL2uW4FLLr3cKGXjU=
github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE=
github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74=
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func TestAccFederatedRepositoryWithInvalidProjectKeyGH318(t *testing.T) {
federatedRepositoryConfig := util.ExecuteTemplate("TestAccFederatedRepositoryConfig", `
resource "artifactory_federated_generic_repository" "{{ .name }}" {
key = "{{ .name }}"
project_key = "invalid-project-key"
project_key = "invalid-project-key-too-long"

member {
url = "{{ .memberUrl }}"
Expand All @@ -243,7 +243,7 @@ func TestAccFederatedRepositoryWithInvalidProjectKeyGH318(t *testing.T) {
Steps: []resource.TestStep{
{
Config: federatedRepositoryConfig,
ExpectError: regexp.MustCompile(".*project_key must be 2 - 10 lowercase alphanumeric and hyphen characters"),
ExpectError: regexp.MustCompile(".*project_key must be 2 - 20 lowercase alphanumeric and hyphen characters"),
},
},
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/artifactory/resource/repository/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var BaseLocalRepoSchema = map[string]*schema.Schema{
Type: schema.TypeString,
Optional: true,
ValidateDiagFunc: validator.ProjectKey,
Description: "Project key for assigning this repository to. Must be 2 - 10 lowercase alphanumeric and hyphen characters. When assigning repository to a project, repository key must be prefixed with project key, separated by a dash.",
Description: "Project key for assigning this repository to. Must be 2 - 20 lowercase alphanumeric and hyphen characters. When assigning repository to a project, repository key must be prefixed with project key, separated by a dash.",
},
"project_environments": {
Type: schema.TypeSet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ func TestAccLocalGenericRepositoryWithInvalidProjectKeyGH318(t *testing.T) {
localRepositoryBasic := util.ExecuteTemplate("TestAccLocalGenericRepository", `
resource "artifactory_local_generic_repository" "{{ .name }}" {
key = "{{ .name }}"
project_key = "invalid-project-key"
project_key = "invalid-project-key-too-long"
}
`, params)

Expand All @@ -809,7 +809,7 @@ func TestAccLocalGenericRepositoryWithInvalidProjectKeyGH318(t *testing.T) {
Steps: []resource.TestStep{
{
Config: localRepositoryBasic,
ExpectError: regexp.MustCompile(".*project_key must be 2 - 10 lowercase alphanumeric and hyphen characters"),
ExpectError: regexp.MustCompile(".*project_key must be 2 - 20 lowercase alphanumeric and hyphen characters"),
},
},
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/artifactory/resource/repository/remote/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ var baseRemoteRepoSchema = map[string]*schema.Schema{
Type: schema.TypeString,
Optional: true,
ValidateDiagFunc: validator.ProjectKey,
Description: "Project key for assigning this repository to. Must be 2 - 10 lowercase alphanumeric and hyphen characters. When assigning repository to a project, repository key must be prefixed with project key, separated by a dash.",
Description: "Project key for assigning this repository to. Must be 2 - 20 lowercase alphanumeric and hyphen characters. When assigning repository to a project, repository key must be prefixed with project key, separated by a dash.",
},
"project_environments": {
Type: schema.TypeSet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ func TestAccRemoteRepositoryWithInvalidProjectKeyGH318(t *testing.T) {
remoteRepositoryBasic := util.ExecuteTemplate("TestAccRemotePyPiRepository", `
resource "artifactory_remote_pypi_repository" "{{ .name }}" {
key = "{{ .name }}"
project_key = "invalid-project-key"
project_key = "invalid-project-key-too-long"
url = "http://tempurl.org"
}
`, params)
Expand All @@ -1281,7 +1281,7 @@ func TestAccRemoteRepositoryWithInvalidProjectKeyGH318(t *testing.T) {
Steps: []resource.TestStep{
{
Config: remoteRepositoryBasic,
ExpectError: regexp.MustCompile(".*project_key must be 2 - 10 lowercase alphanumeric and hyphen characters"),
ExpectError: regexp.MustCompile(".*project_key must be 2 - 20 lowercase alphanumeric and hyphen characters"),
},
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ func TestAccVirtualRepositoryWithInvalidProjectKeyGH318(t *testing.T) {
virualRepositoryBasic := util.ExecuteTemplate("TestAccVirtualGenericRepository", `
resource "artifactory_virtual_generic_repository" "{{ .name }}" {
key = "{{ .name }}"
project_key = "invalid-project-key"
project_key = "invalid-project-key-too-long"
}
`, params)

Expand All @@ -646,7 +646,7 @@ func TestAccVirtualRepositoryWithInvalidProjectKeyGH318(t *testing.T) {
Steps: []resource.TestStep{
{
Config: virualRepositoryBasic,
ExpectError: regexp.MustCompile(".*project_key must be 2 - 10 lowercase alphanumeric and hyphen characters"),
ExpectError: regexp.MustCompile(".*project_key must be 2 - 20 lowercase alphanumeric and hyphen characters"),
},
},
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/artifactory/resource/repository/virtual/virtual.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var BaseVirtualRepoSchema = map[string]*schema.Schema{
Type: schema.TypeString,
Optional: true,
ValidateDiagFunc: validator.ProjectKey,
Description: "Project key for assigning this repository to. Must be 2 - 10 lowercase alphanumeric and hyphen characters. When assigning repository to a project, repository key must be prefixed with project key, separated by a dash.",
Description: "Project key for assigning this repository to. Must be 2 - 20 lowercase alphanumeric and hyphen characters. When assigning repository to a project, repository key must be prefixed with project key, separated by a dash.",
},
"project_environments": {
Type: schema.TypeSet,
Expand Down