Skip to content

Commit

Permalink
Merge pull request #1046 from jfrog/GH-1041-add-resource-for-reposito…
Browse files Browse the repository at this point in the history
…ry-properties

Add resource for repository properties
  • Loading branch information
alexhung authored Aug 6, 2024
2 parents b211556 + 81c3612 commit c80f97c
Show file tree
Hide file tree
Showing 11 changed files with 748 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ jobs:
update-changelog:
runs-on: ubuntu-latest
needs: acceptance-tests-matrix
if: ${{ github.event_name == 'pull_request' }} && ${{ needs.acceptance-tests-matrix.result == 'success' }}
if: |
always() &&
(github.event_name == 'pull_request' && needs.acceptance-tests-matrix.result == 'success')
permissions:
contents: write
steps:
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
## 11.5.0 (August 2, 2024). Tested on Artifactory 7.90.5 with Terraform 1.9.3 and OpenTofu 1.8.0
## 11.5.0 (August 6, 2024). Tested on Artifactory 7.90.6 with Terraform 1.9.3 and OpenTofu 1.8.0

FEATURES:

**New Resource:** `artifactory_item_properties` Issue: [#1041](https://github.com/jfrog/terraform-provider-artifactory/issues/1041) PR: [#1046](https://github.com/jfrog/terraform-provider-artifactory/pull/1046)

IMPROVEMENTS:

Expand Down
2 changes: 1 addition & 1 deletion docs/resources/artifact.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "artifactory_artifact Resource - terraform-provider-artifactory"
subcategory: ""
subcategory: "Artifact"
description: |-
Provides a resource for deploying artifact to Artifactory repository. Support deploying a single artifact only. Changes to repository or path attributes will trigger a recreation of the resource (i.e. delete then create). See JFrog documentation https://jfrog.com/help/r/jfrog-artifactory-documentation/deploy-a-single-artifact for more details.
---
Expand Down
61 changes: 61 additions & 0 deletions docs/resources/item_properties.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "artifactory_item_properties Resource - terraform-provider-artifactory"
subcategory: "Artifact"
description: |-
Provides a resource for managaing item (file, folder, or repository) properties. When a folder is used property attachment is recursive by default. See JFrog documentation https://jfrog.com/help/r/jfrog-artifactory-documentation/working-with-jfrog-properties for more details.
---

# artifactory_item_properties (Resource)

Provides a resource for managaing item (file, folder, or repository) properties. When a folder is used property attachment is recursive by default. See [JFrog documentation](https://jfrog.com/help/r/jfrog-artifactory-documentation/working-with-jfrog-properties) for more details.

## Example Usage

```terraform
resource "artifactory_item_properties" "my-repo-properties" {
repo_key = "my-generic-local"
properties = {
"key1": ["value1"],
"key2": ["value2", "value3"]
}
is_recursive = true
}
resource "artifactory_item_properties" "my-folder-properties" {
repo_key = "my-generic-local"
item_path = "folder/subfolder"
properties = {
"key1": ["value1"],
"key2": ["value2", "value3"]
}
is_recursive = true
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `properties` (Map of Set of String) Map of key and list of values.

~>Keys are limited up to 255 characters and values are limited up to 2,400 characters. Using properties with values over this limit might cause backend issues.

~>The following special characters are forbidden in the key field: `)(}{][*+^$/~``!@#%&<>;=,±§` and the space character.
- `repo_key` (String) Respository key.

### Optional

- `is_recursive` (Boolean) Add this property to the selected folder and to all of artifacts and folders under this folder. Default to `false`
- `item_path` (String) The relative path of the item (file/folder/repository). Leave unset for repository.

## Import

Import is supported using the following syntax:

```shell
terraform import artifactory_item_properties.my-repo-properties repo_key

terraform import artifactory_item_properties.my-folder-properties repo_key:folder/subfolder
```
3 changes: 3 additions & 0 deletions examples/resources/artifactory_item_properties/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
terraform import artifactory_item_properties.my-repo-properties repo_key

terraform import artifactory_item_properties.my-folder-properties repo_key:folder/subfolder
18 changes: 18 additions & 0 deletions examples/resources/artifactory_item_properties/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
resource "artifactory_item_properties" "my-repo-properties" {
repo_key = "my-generic-local"
properties = {
"key1": ["value1"],
"key2": ["value2", "value3"]
}
is_recursive = true
}

resource "artifactory_item_properties" "my-folder-properties" {
repo_key = "my-generic-local"
item_path = "folder/subfolder"
properties = {
"key1": ["value1"],
"key2": ["value2", "value3"]
}
is_recursive = true
}
5 changes: 3 additions & 2 deletions pkg/artifactory/provider/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
datasource_artifact "github.com/jfrog/terraform-provider-artifactory/v11/pkg/artifactory/datasource/artifact"
datasource_repository "github.com/jfrog/terraform-provider-artifactory/v11/pkg/artifactory/datasource/repository"
rs "github.com/jfrog/terraform-provider-artifactory/v11/pkg/artifactory/resource"
"github.com/jfrog/terraform-provider-artifactory/v11/pkg/artifactory/resource/artifact"
"github.com/jfrog/terraform-provider-artifactory/v11/pkg/artifactory/resource/configuration"
"github.com/jfrog/terraform-provider-artifactory/v11/pkg/artifactory/resource/lifecycle"
"github.com/jfrog/terraform-provider-artifactory/v11/pkg/artifactory/resource/security"
Expand Down Expand Up @@ -197,7 +197,8 @@ func (p *ArtifactoryProvider) Configure(ctx context.Context, req provider.Config
// Resources satisfies the provider.Provider interface for ArtifactoryProvider.
func (p *ArtifactoryProvider) Resources(ctx context.Context) []func() resource.Resource {
return []func() resource.Resource{
rs.NewArtifactResource,
artifact.NewArtifactResource,
artifact.NewItemPropertiesResource,
user.NewAnonymousUserResource,
user.NewManagedUserResource,
user.NewUnmanagedUserResource,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package resource
package artifact

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package resource_test
package artifact_test

import (
"fmt"
Expand Down Expand Up @@ -33,7 +33,7 @@ func TestAccArtifact_full(t *testing.T) {
"name": name,
"repoName": repoName,
"path": "/foo/bar/multi1-3.7-20220310.233748-1.jar",
"filePath": "../../../samples/multi1-3.7-20220310.233748-1.jar",
"filePath": "../../../../samples/multi1-3.7-20220310.233748-1.jar",
}
config := util.ExecuteTemplate(name, temp, testData)

Expand Down Expand Up @@ -74,7 +74,7 @@ func TestAccArtifact_invalid_path(t *testing.T) {
testData := map[string]string{
"name": name,
"path": "foo/bar/multi1-3.7-20220310.233748-1.jar",
"filePath": "../../../samples/multi1-3.7-20220310.233748-1.jar",
"filePath": "../../../../samples/multi1-3.7-20220310.233748-1.jar",
}

config := util.ExecuteTemplate(name, temp, testData)
Expand Down
Loading

0 comments on commit c80f97c

Please sign in to comment.