Skip to content

Commit

Permalink
Merge pull request #4779 from aczelandi/support-java-minor-version
Browse files Browse the repository at this point in the history
support minor version of java in azurerm_app_service settings
  • Loading branch information
tombuildsstuff authored Nov 17, 2019
2 parents 66b73e7 + 71ca7ed commit 02db1c8
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 7 deletions.
9 changes: 4 additions & 5 deletions azurerm/helpers/azure/app_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log"
"net"
"regexp"
"strings"

"github.com/Azure/azure-sdk-for-go/services/web/mgmt/2018-02-01/web"
Expand Down Expand Up @@ -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": {
Expand Down
46 changes: 46 additions & 0 deletions azurerm/resource_arm_app_service_slot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,52 @@ 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_windowsPHP7(t *testing.T) {
resourceName := "azurerm_app_service_slot.test"
ri := tf.AccRandTimeInt()
Expand Down
56 changes: 56 additions & 0 deletions azurerm/resource_arm_app_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,62 @@ 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_windowsPHP7(t *testing.T) {
resourceName := "azurerm_app_service.test"
ri := tf.AccRandTimeInt()
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/app_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,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 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 `JAVA`, `JETTY`, and `TOMCAT`.

Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/app_service_slot.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,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 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.

Expand Down

0 comments on commit 02db1c8

Please sign in to comment.