Skip to content

Commit

Permalink
Merge pull request #188 from jfrog/GH-186-fix-reverse-proxy-attribute…
Browse files Browse the repository at this point in the history
…s-not-parameterizable

Fix reverse_proxy attributes not parameterizable
  • Loading branch information
alexhung authored Jan 7, 2025
2 parents e520a9a + 6a58883 commit d4048b8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2.2.1 (January 8, 2025). Tested on Artifactory 7.98.13 with Terraform 1.10.3 and OpenTofu 1.8.8

BUG FIXES:

* resource/platform_reverse_proxy: Fix validation for optional attributes not working for variables. Issue: [#186](https://github.com/jfrog/terraform-provider-platform/issues/186) PR: [#188](https://github.com/jfrog/terraform-provider-platform/pull/188)

## 2.2.0 (January 3, 2025). Tested on Artifactory 7.98.12 with Terraform 1.10.3 and OpenTofu 1.8.8

FEATURES:
Expand Down
12 changes: 8 additions & 4 deletions pkg/platform/resource_reverse_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,17 +350,21 @@ func (r reverseProxyResource) ValidateConfig(ctx context.Context, req resource.V
return
}

if config.InternalHostname.IsUnknown() || config.PublicServerName.IsUnknown() || config.SslKeyPath.IsUnknown() || config.SslCertificatePath.IsUnknown() {
return
}

switch serverProvider := config.ServerProvider.ValueString(); serverProvider {
case "NGINX", "APACHE":
if config.InternalHostname.IsNull() || config.InternalHostname.IsUnknown() {
if config.InternalHostname.IsNull() {
resp.Diagnostics.AddAttributeError(
path.Root("internal_hostname"),
"Missing Attribute Configuration",
fmt.Sprintf("internal_hostname must be configured when server_provider is set to '%s'.", serverProvider),
)
}

if config.PublicServerName.IsNull() || config.PublicServerName.IsUnknown() {
if config.PublicServerName.IsNull() {
resp.Diagnostics.AddAttributeError(
path.Root("public_server_name"),
"Missing Attribute Configuration",
Expand All @@ -370,15 +374,15 @@ func (r reverseProxyResource) ValidateConfig(ctx context.Context, req resource.V
}

if config.UseHttps.ValueBool() {
if config.SslKeyPath.IsNull() || config.SslKeyPath.IsUnknown() {
if config.SslKeyPath.IsNull() {
resp.Diagnostics.AddAttributeError(
path.Root("ssl_key_path"),
"Missing Attribute Configuration",
"ssl_key_path must be configured when use_https is set to 'true'.",
)
}

if config.SslCertificatePath.IsNull() || config.SslCertificatePath.IsUnknown() {
if config.SslCertificatePath.IsNull() {
resp.Diagnostics.AddAttributeError(
path.Root("ssl_certificate_path"),
"Missing Attribute Configuration",
Expand Down
5 changes: 0 additions & 5 deletions pkg/platform/resource_reverse_proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func TestAccReverseProxy_full(t *testing.T) {
updatedConfig := util.ExecuteTemplate(reverseProxyName, updatedTemp, updatedTestData)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProviders(),
Steps: []resource.TestStep{
{
Expand Down Expand Up @@ -128,7 +127,6 @@ func testAccReverseProxy_missing_internal_hostname(t *testing.T, serverProvider
config := util.ExecuteTemplate(reverseProxyName, temp, testData)

return t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProviders(),
Steps: []resource.TestStep{
{
Expand Down Expand Up @@ -158,7 +156,6 @@ func testAccReverseProxy_missing_public_server_name(t *testing.T, serverProvider
config := util.ExecuteTemplate(reverseProxyName, temp, testData)

return t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProviders(),
Steps: []resource.TestStep{
{
Expand Down Expand Up @@ -201,7 +198,6 @@ func testAccReverseProxy_missing_ssl_key_path(t *testing.T, serverProvider strin
config := util.ExecuteTemplate(reverseProxyName, temp, testData)

return t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProviders(),
Steps: []resource.TestStep{
{
Expand Down Expand Up @@ -235,7 +231,6 @@ func testAccReverseProxy_missing_ssl_certificate_path(t *testing.T, serverProvid
config := util.ExecuteTemplate(reverseProxyName, temp, testData)

return t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProviders(),
Steps: []resource.TestStep{
{
Expand Down

0 comments on commit d4048b8

Please sign in to comment.