Skip to content

Commit

Permalink
Merge pull request #1095 from jfrog/GH-1088-add-disable-proxy-attribu…
Browse files Browse the repository at this point in the history
…te-to-replication

Add 'disable_proxy' attribute to artifactory_local_repository_multi_replication to support not using proxy
  • Loading branch information
alexhung authored Oct 14, 2024
2 parents 86eb867 + 3adfec6 commit 8e1e80d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 12.2.0 (October 14, 2024). Tested on Artifactory 7.90.14 with Terraform 1.9.7 and OpenTofu 1.8.3

IMPROVEMENTS:

* resource/artifactory_local_repository_multi_replication: Add `disable_proxy` attribute to `replication` to support not using proxy. Issue: [#1088](https://github.com/jfrog/terraform-provider-artifactory/issues/1088) PR: [#1095](https://github.com/jfrog/terraform-provider-artifactory/pull/1095)

## 12.1.1 (October 2, 2024). Tested on Artifactory 7.90.13 with Terraform 1.9.6 and OpenTofu 1.8.2

IMPROVEMENTS:
Expand Down
16 changes: 9 additions & 7 deletions docs/resources/local_repository_multi_replication.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ See the [Official Documentation](https://www.jfrog.com/confluence/display/JFROG/

This resource replaces `artifactory_push_replication` and used to create a replication of one local repository to multiple repositories on the remote server.

~> This resource requires Artifactory Enterprise license. Use `artifactory_local_repository_single_replication` with other licenses.
~>This resource requires Artifactory Enterprise license. Use `artifactory_local_repository_single_replication` with other licenses.

## Example Usage

Expand Down Expand Up @@ -55,12 +55,13 @@ resource "artifactory_local_repository_multi_replication" "foo-rep" {
password = "$var.artifactory_password"
enabled = true
}
replication {
url = "${var.artifactory_url}/artifactory/${artifactory_local_maven_repository.provider_test_dest1.key}"
username = "$var.artifactory_username"
password = "$var.artifactory_password"
enabled = true
}
replication {
url = "${var.artifactory_url}/artifactory/${artifactory_local_maven_repository.provider_test_dest1.key}"
username = "$var.artifactory_username"
password = "$var.artifactory_password"
enabled = true
}
}
```

Expand All @@ -83,6 +84,7 @@ The following arguments are supported:
* `include_path_prefix_pattern` - (Optional) List of artifact patterns to include when evaluating artifact requests in the form of `x/y/**/z/*`. When used, only artifacts matching one of the include patterns are served. By default, all artifacts are included `(**/*)`.
* `exclude_path_prefix_pattern` - (Optional) List of artifact patterns to exclude when evaluating artifact requests, in the form of `x/y/**/z/*`. By default, no artifacts are excluded.
* `proxy` - (Optional) Proxy key from Artifactory Proxies settings. The proxy configuration will be used when communicating with the remote instance.
* `disable_proxy` - (Optional) When set to `true`, the `proxy` attribute will be ignored (from version 7.41.7). The default value is `false`.
* `replication_key` - (Computed) Replication ID, the value is unknown until the resource is created. Can't be set or updated.
* `check_binary_existence_in_filestore` - (Optional) Enabling the `check_binary_existence_in_filestore` flag requires an Enterprise Plus 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 @@ -69,7 +69,8 @@ func (m LocalRepositoryMultiReplicationResourceModel) toAPIModel(_ context.Conte
ExcludePathPrefixPattern: attrs["exclude_path_prefix_pattern"].(types.String).ValueString(),
CheckBinaryExistenceInFilestore: attrs["check_binary_existence_in_filestore"].(types.Bool).ValueBool(),
},
Proxy: attrs["proxy"].(types.String).ValueString(),
Proxy: attrs["proxy"].(types.String).ValueString(),
DisableProxy: attrs["disable_proxy"].(types.Bool).ValueBool(),
}
},
)
Expand All @@ -96,6 +97,7 @@ var replicationResourceModelAttributeTypes map[string]attr.Type = map[string]att
"exclude_path_prefix_pattern": types.StringType,
"check_binary_existence_in_filestore": types.BoolType,
"proxy": types.StringType,
"disable_proxy": types.BoolType,
"replication_key": types.StringType,
}

Expand Down Expand Up @@ -143,6 +145,7 @@ func (m *LocalRepositoryMultiReplicationResourceModel) fromAPIModel(_ context.Co
"exclude_path_prefix_pattern": types.StringValue(replication.ExcludePathPrefixPattern),
"check_binary_existence_in_filestore": types.BoolValue(replication.CheckBinaryExistenceInFilestore),
"proxy": types.StringValue(replication.ProxyRef),
"disable_proxy": types.BoolValue(replication.DisableProxy),
"replication_key": types.StringValue(replication.ReplicationKey),
},
)
Expand Down Expand Up @@ -189,11 +192,13 @@ type ReplicationGetAPIModel struct {
ReplicationAPIModel
ProxyRef string `json:"proxyRef"`
ReplicationKey string `json:"replicationKey"`
DisableProxy bool `json:"disableProxy"`
}

type ReplicationUpdateAPIModel struct {
ReplicationAPIModel
Proxy string `json:"proxy"`
Proxy string `json:"proxy"`
DisableProxy bool `json:"disableProxy"`
}

type LocalMultiReplicationUpdateAPIModel struct {
Expand All @@ -208,6 +213,7 @@ func (r *LocalRepositoryMultiReplicationResource) Metadata(ctx context.Context,

func (r *LocalRepositoryMultiReplicationResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
resp.Schema = schema.Schema{
Version: 0,
Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{
Computed: true,
Expand Down Expand Up @@ -325,6 +331,12 @@ func (r *LocalRepositoryMultiReplicationResource) Schema(ctx context.Context, re
},
Description: "A proxy configuration to use when communicating with the remote instance.",
},
"disable_proxy": schema.BoolAttribute{
Optional: true,
Computed: true,
Default: booldefault.StaticBool(false),
MarkdownDescription: "When set to `true`, the `proxy` attribute will be ignored (from version 7.41.7). The default value is `false`.",
},
"replication_key": schema.StringAttribute{
Computed: true,
Description: "Replication ID. The ID is known only after the replication is created, for this reason it's `Computed` and can not be set by the user in HCL.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func TestAccLocalMultiReplication_full(t *testing.T) {
url = "https://dummyurl.com/"
username = "{{ .username }}"
password = "Passw0rd!"
proxy = artifactory_proxy.{{ .proxy }}.key
disable_proxy = true
enabled = false
socket_timeout_millis = 16000
sync_deletes = true
Expand Down Expand Up @@ -312,7 +312,7 @@ func TestAccLocalMultiReplication_full(t *testing.T) {
resource.TestCheckResourceAttr(fqrn, "replication.0.check_binary_existence_in_filestore", "true"),
resource.TestCheckResourceAttr(fqrn, "replication.1.username", acctest.RtDefaultUser),
resource.TestCheckResourceAttr(fqrn, "replication.1.password", "Passw0rd!"),
resource.TestCheckResourceAttr(fqrn, "replication.1.proxy", testProxy),
resource.TestCheckResourceAttr(fqrn, "replication.1.disable_proxy", "true"),
resource.TestCheckResourceAttr(fqrn, "replication.1.enabled", "false"),
resource.TestCheckResourceAttr(fqrn, "replication.1.check_binary_existence_in_filestore", "true"),
resource.TestCheckTypeSetElemAttr(fqrn, "replication.*.*", acctest.GetArtifactoryUrl(t)),
Expand Down

0 comments on commit 8e1e80d

Please sign in to comment.