Skip to content

Commit

Permalink
PR review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
daxsorbito committed Nov 18, 2020
1 parent 0740b10 commit f2ce6f2
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 192 deletions.
12 changes: 8 additions & 4 deletions azurerm/internal/services/web/app_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1342,10 +1342,10 @@ func flattenAppServiceLogs(input *web.SiteLogsConfigProperties) []interface{} {
}
result["http_logs"] = httpLogs

if input.DetailedErrorMessages.Enabled != nil {
if input.DetailedErrorMessages != nil && input.DetailedErrorMessages.Enabled != nil {
result["detailed_error_messages_enabled"] = *input.DetailedErrorMessages.Enabled
}
if input.FailedRequestsTracing.Enabled != nil {
if input.FailedRequestsTracing != nil && input.FailedRequestsTracing.Enabled != nil {
result["failed_request_tracing_enabled"] = *input.FailedRequestsTracing.Enabled
}

Expand Down Expand Up @@ -1431,11 +1431,15 @@ func expandAppServiceLogs(input interface{}) web.SiteLogsConfigProperties {
}

if v, ok := config["detailed_error_messages_enabled"]; ok {
logs.DetailedErrorMessages = &web.EnabledConfig{Enabled: utils.Bool(v.(bool))}
logs.DetailedErrorMessages = &web.EnabledConfig{
Enabled: utils.Bool(v.(bool)),
}
}

if v, ok := config["failed_request_tracing_enabled"]; ok {
logs.FailedRequestsTracing = &web.EnabledConfig{Enabled: utils.Bool(v.(bool))}
logs.FailedRequestsTracing = &web.EnabledConfig{
Enabled: utils.Bool(v.(bool)),
}
}

return logs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1358,17 +1358,16 @@ func TestAccAzureRMAppServiceSlot_detailedErrorMessagesLogs(t *testing.T) {
CheckDestroy: testCheckAzureRMAppServiceDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMAppServiceSlot_detailedErrorMessagesEnabled(data),
Config: testAccAzureRMAppServiceSlot_detailedErrorMessages(data, true),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAppServiceExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "logs.0.detailed_error_messages_enabled", "true"),
),
},
data.ImportStep(),
{
Config: testAccAzureRMAppServiceSlot_detailedErrorMessagesDisabled(data),
Config: testAccAzureRMAppServiceSlot_detailedErrorMessages(data, false),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAppServiceExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "logs.0.detailed_error_messages_enabled", "false"),
),
},
data.ImportStep(),
Expand All @@ -1384,17 +1383,16 @@ func TestAccAzureRMAppServiceSlot_failedRequestTracingLogs(t *testing.T) {
CheckDestroy: testCheckAzureRMAppServiceDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMAppServiceSlot_failedRequestTracingEnabled(data),
Config: testAccAzureRMAppServiceSlot_failedRequestTracing(data, true),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAppServiceExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "logs.0.failed_request_tracing_enabled", "true"),
),
},
data.ImportStep(),
{
Config: testAccAzureRMAppServiceSlot_failedRequestTracingDisabled(data),
Config: testAccAzureRMAppServiceSlot_failedRequestTracing(data, false),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAppServiceExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "logs.0.failed_request_tracing_enabled", "false"),
),
},
data.ImportStep(),
Expand Down Expand Up @@ -3826,50 +3824,7 @@ resource "azurerm_app_service_slot" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger)
}

func testAccAzureRMAppServiceSlot_detailedErrorMessagesEnabled(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_app_service_plan" "test" {
name = "acctestASP-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku {
tier = "Standard"
size = "S1"
}
}
resource "azurerm_app_service" "test" {
name = "acctestAS-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
app_service_plan_id = azurerm_app_service_plan.test.id
}
resource "azurerm_app_service_slot" "test" {
name = "acctestASSlot-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
app_service_plan_id = azurerm_app_service_plan.test.id
app_service_name = azurerm_app_service.test.name
logs {
detailed_error_messages_enabled = true
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger)
}

func testAccAzureRMAppServiceSlot_detailedErrorMessagesDisabled(data acceptance.TestData) string {
func testAccAzureRMAppServiceSlot_detailedErrorMessages(data acceptance.TestData, detailedErrorEnabled bool) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
Expand Down Expand Up @@ -3906,13 +3861,13 @@ resource "azurerm_app_service_slot" "test" {
app_service_name = azurerm_app_service.test.name
logs {
detailed_error_messages_enabled = false
detailed_error_messages_enabled = %t
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger)
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger, detailedErrorEnabled)
}

func testAccAzureRMAppServiceSlot_failedRequestTracingEnabled(data acceptance.TestData) string {
func testAccAzureRMAppServiceSlot_failedRequestTracing(data acceptance.TestData, failedRequestEnabled bool) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
Expand Down Expand Up @@ -3949,53 +3904,10 @@ resource "azurerm_app_service_slot" "test" {
app_service_name = azurerm_app_service.test.name
logs {
failed_request_tracing_enabled = true
failed_request_tracing_enabled = %t
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger)
}

func testAccAzureRMAppServiceSlot_failedRequestTracingDisabled(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_app_service_plan" "test" {
name = "acctestASP-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku {
tier = "Standard"
size = "S1"
}
}
resource "azurerm_app_service" "test" {
name = "acctestAS-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
app_service_plan_id = azurerm_app_service_plan.test.id
}
resource "azurerm_app_service_slot" "test" {
name = "acctestASSlot-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
app_service_plan_id = azurerm_app_service_plan.test.id
app_service_name = azurerm_app_service.test.name
logs {
failed_request_tracing_enabled = false
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger)
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger, failedRequestEnabled)
}

func testAccAzureRMAppServiceSlot_autoSwap(data acceptance.TestData) string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -972,17 +972,16 @@ func TestAccAzureRMAppService_detailedErrorMessagesLogs(t *testing.T) {
CheckDestroy: testCheckAzureRMAppServiceDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMAppService_detailedErrorMessagesEnabled(data),
Config: testAccAzureRMAppService_detailedErrorMessages(data, true),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAppServiceExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "logs.0.detailed_error_messages_enabled", "true"),
),
},
data.ImportStep(),
{
Config: testAccAzureRMAppService_detailedErrorMessagesDisabled(data),
Config: testAccAzureRMAppService_detailedErrorMessages(data, true),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAppServiceExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "logs.0.detailed_error_messages_enabled", "false"),
),
},
data.ImportStep(),
Expand All @@ -998,17 +997,16 @@ func TestAccAzureRMAppService_failedRequestTracingLogs(t *testing.T) {
CheckDestroy: testCheckAzureRMAppServiceDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMAppService_failedRequestTracingEnabled(data),
Config: testAccAzureRMAppService_failedRequestTracing(data, true),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAppServiceExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "logs.0.failed_request_tracing_enabled", "true"),
),
},
data.ImportStep(),
{
Config: testAccAzureRMAppService_failedRequestTracingDisabled(data),
Config: testAccAzureRMAppService_failedRequestTracing(data, false),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAppServiceExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "logs.0.failed_request_tracing_enabled", "false"),
),
},
data.ImportStep(),
Expand Down Expand Up @@ -3776,42 +3774,7 @@ resource "azurerm_app_service" "test" {
`, template, data.RandomInteger)
}

func testAccAzureRMAppService_detailedErrorMessagesEnabled(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_app_service_plan" "test" {
name = "acctestASP-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku {
tier = "Standard"
size = "S1"
}
}
resource "azurerm_app_service" "test" {
name = "acctestAS-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
app_service_plan_id = azurerm_app_service_plan.test.id
logs {
detailed_error_messages_enabled = true
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger)
}

func testAccAzureRMAppService_detailedErrorMessagesDisabled(data acceptance.TestData) string {
func testAccAzureRMAppService_detailedErrorMessages(data acceptance.TestData, detailedErrorEnabled bool) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
Expand Down Expand Up @@ -3840,13 +3803,13 @@ resource "azurerm_app_service" "test" {
app_service_plan_id = azurerm_app_service_plan.test.id
logs {
detailed_error_messages_enabled = false
detailed_error_messages_enabled = %t
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger)
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, detailedErrorEnabled)
}

func testAccAzureRMAppService_failedRequestTracingEnabled(data acceptance.TestData) string {
func testAccAzureRMAppService_failedRequestTracing(data acceptance.TestData, failedRequestEnabled bool) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
Expand Down Expand Up @@ -3875,45 +3838,10 @@ resource "azurerm_app_service" "test" {
app_service_plan_id = azurerm_app_service_plan.test.id
logs {
failed_request_tracing_enabled = true
failed_request_tracing_enabled = %t
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger)
}

func testAccAzureRMAppService_failedRequestTracingDisabled(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_app_service_plan" "test" {
name = "acctestASP-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku {
tier = "Standard"
size = "S1"
}
}
resource "azurerm_app_service" "test" {
name = "acctestAS-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
app_service_plan_id = azurerm_app_service_plan.test.id
logs {
failed_request_tracing_enabled = false
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger)
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, failedRequestEnabled)
}

func testAccAzureRMAppService_managedPipelineMode(data acceptance.TestData) string {
Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/app_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ A `logs` block supports the following:

* `http_logs` - (Optional) An `http_logs` block as defined below.

* `detailed_error_messages_enabled` - (Optional) Is `Detailed error messages` enabled on this App Service? Defaults to false.
* `detailed_error_messages_enabled` - (Optional) Are `Detailed error messages` enabled on this App Service? Defaults to false.

* `failed_request_tracing_enabled` - (Optional) Is `Failed request tracing` enabled on this App Service? Defaults to false.
* `failed_request_tracing_enabled` - (Optional) Are `Failed request tracing` enabled on this App Service? Defaults to false.

---

Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/app_service_slot.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,9 @@ A `logs` block supports the following:

* `http_logs` - (Optional) An `http_logs` block as defined below.

* `detailed_error_messages_enabled` - (Optional) Is `Detailed error messages` enabled on this App Service slot? Defaults to false.
* `detailed_error_messages_enabled` - (Optional) Are `Detailed error messages` enabled on this App Service slot? Defaults to false.

* `failed_request_tracing_enabled` - (Optional) Is `Failed request tracing` enabled on this App Service slot? Defaults to false.
* `failed_request_tracing_enabled` - (Optional) Are `Failed request tracing` enabled on this App Service slot? Defaults to false.

---

Expand Down

0 comments on commit f2ce6f2

Please sign in to comment.