From 08d94552f47bcacba9b2c9bbe32788e02a55b84b Mon Sep 17 00:00:00 2001 From: Andrea Aczel Date: Thu, 31 Oct 2019 16:29:55 +0100 Subject: [PATCH 1/4] support minor version of java in azurerm_app_service settings --- azurerm/helpers/azure/app_service.go | 9 ++- azurerm/resource_arm_app_service_test.go | 84 ++++++++++++++++++++++++ website/docs/r/app_service.html.markdown | 2 +- 3 files changed, 89 insertions(+), 6 deletions(-) diff --git a/azurerm/helpers/azure/app_service.go b/azurerm/helpers/azure/app_service.go index e18ca77bb6e5..313a208ca0cb 100644 --- a/azurerm/helpers/azure/app_service.go +++ b/azurerm/helpers/azure/app_service.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "net" + "regexp" "strings" "github.com/Azure/azure-sdk-for-go/services/web/mgmt/2018-02-01/web" @@ -328,11 +329,9 @@ func SchemaAppServiceSiteConfig() *schema.Schema { "java_version": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringInSlice([]string{ - "1.7", - "1.8", - "11", - }, false), + ValidateFunc: validation.StringMatch( + regexp.MustCompile(`^(1\.7|1\.8|11)`), + `Invalid Java version provided`), }, "java_container": { diff --git a/azurerm/resource_arm_app_service_test.go b/azurerm/resource_arm_app_service_test.go index b1e9f671ae4e..7394d4c8d053 100644 --- a/azurerm/resource_arm_app_service_test.go +++ b/azurerm/resource_arm_app_service_test.go @@ -1420,6 +1420,90 @@ func TestAccAzureRMAppService_windowsJava11Tomcat(t *testing.T) { }) } +func TestAccAzureRMAppService_windowsJava7Minor(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := tf.AccRandTimeInt() + config := testAccAzureRMAppService_windowsJava(ri, testLocation(), "1.7.0_80", "TOMCAT", "9.0") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_version", "1.7.0_80"), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_container", "TOMCAT"), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_container_version", "9.0"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMAppService_windowsJava8Minor(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := tf.AccRandTimeInt() + config := testAccAzureRMAppService_windowsJava(ri, testLocation(), "1.8.0_181", "TOMCAT", "9.0") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_version", "1.8.0_181"), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_container", "TOMCAT"), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_container_version", "9.0"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMAppService_windowsJava11Minor(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := tf.AccRandTimeInt() + config := testAccAzureRMAppService_windowsJava(ri, testLocation(), "11.0.1", "TOMCAT", "9.0") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_version", "11.0.1"), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_container", "TOMCAT"), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_container_version", "9.0"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func TestAccAzureRMAppService_windowsPHP7(t *testing.T) { resourceName := "azurerm_app_service.test" ri := tf.AccRandTimeInt() diff --git a/website/docs/r/app_service.html.markdown b/website/docs/r/app_service.html.markdown index 7316ef3f2b8d..0ca73f117cf5 100644 --- a/website/docs/r/app_service.html.markdown +++ b/website/docs/r/app_service.html.markdown @@ -189,7 +189,7 @@ A `site_config` block supports the following: * `ip_restriction` - (Optional) A [List of objects](/docs/configuration/attr-as-blocks.html) representing ip restrictions as defined below. -* `java_version` - (Optional) The version of Java to use. If specified `java_container` and `java_container_version` must also be specified. Possible values are `1.7`, `1.8` and `11`. +* `java_version` - (Optional) The version of Java to use. If specified `java_container` and `java_container_version` must also be specified. Possible values are `1.7`, `1.8` and `11` and their minor/patch versions. * `java_container` - (Optional) The Java Container to use. If specified `java_version` and `java_container_version` must also be specified. Possible values are `JETTY` and `TOMCAT`. From 6f8b1bb54337b970fd82b98580ab9af6afa460d2 Mon Sep 17 00:00:00 2001 From: Andrea Aczel Date: Thu, 31 Oct 2019 21:04:25 +0100 Subject: [PATCH 2/4] update readme with java version examples --- website/docs/r/app_service.html.markdown | 2 +- website/docs/r/app_service_slot.html.markdown | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/r/app_service.html.markdown b/website/docs/r/app_service.html.markdown index 0ca73f117cf5..241b3e74846c 100644 --- a/website/docs/r/app_service.html.markdown +++ b/website/docs/r/app_service.html.markdown @@ -189,7 +189,7 @@ A `site_config` block supports the following: * `ip_restriction` - (Optional) A [List of objects](/docs/configuration/attr-as-blocks.html) representing ip restrictions as defined below. -* `java_version` - (Optional) The version of Java to use. If specified `java_container` and `java_container_version` must also be specified. Possible values are `1.7`, `1.8` and `11` and their minor/patch versions. +* `java_version` - (Optional) The version of Java to use. If specified `java_container` and `java_container_version` must also be specified. Possible values are `1.7`, `1.8` and `11` and their minor/patch versions (e.g. `1.7.0_80`, `1.8.0_181`, `11.0.2`) * `java_container` - (Optional) The Java Container to use. If specified `java_version` and `java_container_version` must also be specified. Possible values are `JETTY` and `TOMCAT`. diff --git a/website/docs/r/app_service_slot.html.markdown b/website/docs/r/app_service_slot.html.markdown index 4f98f07a3170..e2acbd4464a3 100644 --- a/website/docs/r/app_service_slot.html.markdown +++ b/website/docs/r/app_service_slot.html.markdown @@ -202,7 +202,7 @@ The following arguments are supported: * `java_container_version` - (Optional) The version of the Java Container to use. If specified `java_version` and `java_container` must also be specified. -* `java_version` - (Optional) The version of Java to use. If specified `java_container` and `java_container_version` must also be specified. Possible values are `1.7`, `1.8` and `11`. +* `java_version` - (Optional) The version of Java to use. If specified `java_container` and `java_container_version` must also be specified. Possible values are `1.7`, `1.8` and `11` and their minor/patch versions (e.g. `1.7.0_80`, `1.8.0_181`, `11.0.2`) * `local_mysql_enabled` - (Optional) Is "MySQL In App" Enabled? This runs a local MySQL instance with your app and shares resources from the App Service plan. From a0ad9a8e2dc947b90eb2d6a14e99233a76fc92dc Mon Sep 17 00:00:00 2001 From: Andrea Aczel Date: Thu, 31 Oct 2019 21:07:29 +0100 Subject: [PATCH 3/4] extends tests for azurerm_app_service_slot --- azurerm/resource_arm_app_service_slot_test.go | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/azurerm/resource_arm_app_service_slot_test.go b/azurerm/resource_arm_app_service_slot_test.go index 01ff6bc3a57f..eceb2fb691f1 100644 --- a/azurerm/resource_arm_app_service_slot_test.go +++ b/azurerm/resource_arm_app_service_slot_test.go @@ -1341,6 +1341,75 @@ func TestAccAzureRMAppServiceSlot_windowsJava11Tomcat(t *testing.T) { }) } +func TestAccAzureRMAppServiceSlot_windowsJava7Minor(t *testing.T) { + resourceName := "azurerm_app_service_slot.test" + ri := tf.AccRandTimeInt() + config := testAccAzureRMAppServiceSlot_windowsJava(ri, testLocation(), "1.7.0_80", "TOMCAT", "9.0") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceSlotDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceSlotExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_version", "1.7.0_80"), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_container", "TOMCAT"), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_container_version", "9.0"), + ), + }, + }, + }) +} + +func TestAccAzureRMAppServiceSlot_windowsJava8Minor(t *testing.T) { + resourceName := "azurerm_app_service_slot.test" + ri := tf.AccRandTimeInt() + config := testAccAzureRMAppServiceSlot_windowsJava(ri, testLocation(), "1.8.0_181", "TOMCAT", "9.0") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceSlotDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceSlotExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_version", "1.8.0_181"), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_container", "TOMCAT"), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_container_version", "9.0"), + ), + }, + }, + }) +} + +func TestAccAzureRMAppServiceSlot_windowsJava11Minor(t *testing.T) { + resourceName := "azurerm_app_service_slot.test" + ri := tf.AccRandTimeInt() + config := testAccAzureRMAppServiceSlot_windowsJava(ri, testLocation(), "11.0.1", "TOMCAT", "9.0") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceSlotDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceSlotExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_version", "11.0.1"), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_container", "TOMCAT"), + resource.TestCheckResourceAttr(resourceName, "site_config.0.java_container_version", "9.0"), + ), + }, + }, + }) +} + func TestAccAzureRMAppServiceSlot_windowsPHP7(t *testing.T) { resourceName := "azurerm_app_service_slot.test" ri := tf.AccRandTimeInt() From 71ca7ed86f62b928dd340191e55c7b9ce14b4078 Mon Sep 17 00:00:00 2001 From: Andrea Aczel Date: Sun, 3 Nov 2019 21:00:19 +0100 Subject: [PATCH 4/4] azure app service does not support minors for java 11 --- azurerm/resource_arm_app_service_slot_test.go | 23 --------------- azurerm/resource_arm_app_service_test.go | 28 ------------------- website/docs/r/app_service.html.markdown | 2 +- website/docs/r/app_service_slot.html.markdown | 2 +- 4 files changed, 2 insertions(+), 53 deletions(-) diff --git a/azurerm/resource_arm_app_service_slot_test.go b/azurerm/resource_arm_app_service_slot_test.go index eceb2fb691f1..303fd26366c3 100644 --- a/azurerm/resource_arm_app_service_slot_test.go +++ b/azurerm/resource_arm_app_service_slot_test.go @@ -1387,29 +1387,6 @@ func TestAccAzureRMAppServiceSlot_windowsJava8Minor(t *testing.T) { }) } -func TestAccAzureRMAppServiceSlot_windowsJava11Minor(t *testing.T) { - resourceName := "azurerm_app_service_slot.test" - ri := tf.AccRandTimeInt() - config := testAccAzureRMAppServiceSlot_windowsJava(ri, testLocation(), "11.0.1", "TOMCAT", "9.0") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testCheckAzureRMAppServiceSlotDestroy, - Steps: []resource.TestStep{ - { - Config: config, - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMAppServiceSlotExists(resourceName), - resource.TestCheckResourceAttr(resourceName, "site_config.0.java_version", "11.0.1"), - resource.TestCheckResourceAttr(resourceName, "site_config.0.java_container", "TOMCAT"), - resource.TestCheckResourceAttr(resourceName, "site_config.0.java_container_version", "9.0"), - ), - }, - }, - }) -} - func TestAccAzureRMAppServiceSlot_windowsPHP7(t *testing.T) { resourceName := "azurerm_app_service_slot.test" ri := tf.AccRandTimeInt() diff --git a/azurerm/resource_arm_app_service_test.go b/azurerm/resource_arm_app_service_test.go index 7394d4c8d053..9ada73074816 100644 --- a/azurerm/resource_arm_app_service_test.go +++ b/azurerm/resource_arm_app_service_test.go @@ -1476,34 +1476,6 @@ func TestAccAzureRMAppService_windowsJava8Minor(t *testing.T) { }) } -func TestAccAzureRMAppService_windowsJava11Minor(t *testing.T) { - resourceName := "azurerm_app_service.test" - ri := tf.AccRandTimeInt() - config := testAccAzureRMAppService_windowsJava(ri, testLocation(), "11.0.1", "TOMCAT", "9.0") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testCheckAzureRMAppServiceDestroy, - Steps: []resource.TestStep{ - { - Config: config, - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMAppServiceExists(resourceName), - resource.TestCheckResourceAttr(resourceName, "site_config.0.java_version", "11.0.1"), - resource.TestCheckResourceAttr(resourceName, "site_config.0.java_container", "TOMCAT"), - resource.TestCheckResourceAttr(resourceName, "site_config.0.java_container_version", "9.0"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func TestAccAzureRMAppService_windowsPHP7(t *testing.T) { resourceName := "azurerm_app_service.test" ri := tf.AccRandTimeInt() diff --git a/website/docs/r/app_service.html.markdown b/website/docs/r/app_service.html.markdown index 241b3e74846c..a2a1b7416308 100644 --- a/website/docs/r/app_service.html.markdown +++ b/website/docs/r/app_service.html.markdown @@ -189,7 +189,7 @@ A `site_config` block supports the following: * `ip_restriction` - (Optional) A [List of objects](/docs/configuration/attr-as-blocks.html) representing ip restrictions as defined below. -* `java_version` - (Optional) The version of Java to use. If specified `java_container` and `java_container_version` must also be specified. Possible values are `1.7`, `1.8` and `11` and their minor/patch versions (e.g. `1.7.0_80`, `1.8.0_181`, `11.0.2`) +* `java_version` - (Optional) The version of Java to use. If specified `java_container` and `java_container_version` must also be specified. Possible values are `1.7`, `1.8` and `11` and their specific versions - except for Java 11 (e.g. `1.7.0_80`, `1.8.0_181`, `11`) * `java_container` - (Optional) The Java Container to use. If specified `java_version` and `java_container_version` must also be specified. Possible values are `JETTY` and `TOMCAT`. diff --git a/website/docs/r/app_service_slot.html.markdown b/website/docs/r/app_service_slot.html.markdown index e2acbd4464a3..ea564be7e7b4 100644 --- a/website/docs/r/app_service_slot.html.markdown +++ b/website/docs/r/app_service_slot.html.markdown @@ -202,7 +202,7 @@ The following arguments are supported: * `java_container_version` - (Optional) The version of the Java Container to use. If specified `java_version` and `java_container` must also be specified. -* `java_version` - (Optional) The version of Java to use. If specified `java_container` and `java_container_version` must also be specified. Possible values are `1.7`, `1.8` and `11` and their minor/patch versions (e.g. `1.7.0_80`, `1.8.0_181`, `11.0.2`) +* `java_version` - (Optional) The version of Java to use. If specified `java_container` and `java_container_version` must also be specified. Possible values are `1.7`, `1.8` and `11` and their specific versions - except for Java 11 (e.g. `1.7.0_80`, `1.8.0_181`, `11`) * `local_mysql_enabled` - (Optional) Is "MySQL In App" Enabled? This runs a local MySQL instance with your app and shares resources from the App Service plan.