diff --git a/CHANGELOG.md b/CHANGELOG.md index e79a2fa..3c05fcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: diff --git a/pkg/platform/resource_reverse_proxy.go b/pkg/platform/resource_reverse_proxy.go index a7c5a6c..d936094 100644 --- a/pkg/platform/resource_reverse_proxy.go +++ b/pkg/platform/resource_reverse_proxy.go @@ -350,9 +350,13 @@ 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", @@ -360,7 +364,7 @@ func (r reverseProxyResource) ValidateConfig(ctx context.Context, req resource.V ) } - if config.PublicServerName.IsNull() || config.PublicServerName.IsUnknown() { + if config.PublicServerName.IsNull() { resp.Diagnostics.AddAttributeError( path.Root("public_server_name"), "Missing Attribute Configuration", @@ -370,7 +374,7 @@ 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", @@ -378,7 +382,7 @@ func (r reverseProxyResource) ValidateConfig(ctx context.Context, req resource.V ) } - if config.SslCertificatePath.IsNull() || config.SslCertificatePath.IsUnknown() { + if config.SslCertificatePath.IsNull() { resp.Diagnostics.AddAttributeError( path.Root("ssl_certificate_path"), "Missing Attribute Configuration", diff --git a/pkg/platform/resource_reverse_proxy_test.go b/pkg/platform/resource_reverse_proxy_test.go index aa909ff..0e26fc8 100644 --- a/pkg/platform/resource_reverse_proxy_test.go +++ b/pkg/platform/resource_reverse_proxy_test.go @@ -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{ { @@ -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{ { @@ -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{ { @@ -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{ { @@ -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{ {