Skip to content

Commit

Permalink
Merge branch 'master' into api-management
Browse files Browse the repository at this point in the history
* master:
  Updating to include hashicorp#1565
  resource/servicebus_subscription_rule: Fix the correlation_filter optional values (hashicorp#1565)
  Updating to include hashicorp#1563
  resouce/app_insights: Allow different application_type deployments (hashicorp#1563)
  VMSS: changed sku property from a set to list
  • Loading branch information
torresdal committed Jul 13, 2018
2 parents 040aa91 + ba9e3f5 commit 5d58d0d
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 64 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ FEATURES:

BUG FIXES:

* `azurerm_application_insights` - fixing a bug where `application_type` was set to `other` [GH-1563]
* `azurerm_servicebus_subscription` - only sending `correlation_filter` values if they're set [GH-1565]
* `azurerm_traffic_manager_endpoint` - working around a bug in the API by setting `target` to nil when a `target_resource_id` is specified [GH-1546]

## 1.9.0 (July 11, 2018)
Expand Down
4 changes: 2 additions & 2 deletions azurerm/import_arm_application_insights_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func TestAccAzureRMApplicationInsights_importBasicWeb(t *testing.T) {
resourceName := "azurerm_application_insights.test"

ri := acctest.RandInt()
config := testAccAzureRMApplicationInsights_basicWeb(ri, testLocation())
config := testAccAzureRMApplicationInsights_basic(ri, testLocation(), "web")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -35,7 +35,7 @@ func TestAccAzureRMApplicationInsights_importBasicOther(t *testing.T) {
resourceName := "azurerm_application_insights.test"

ri := acctest.RandInt()
config := testAccAzureRMApplicationInsights_basicWeb(ri, testLocation())
config := testAccAzureRMApplicationInsights_basic(ri, testLocation(), "web")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down
8 changes: 6 additions & 2 deletions azurerm/resource_arm_application_insights.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ func resourceArmApplicationInsights() *schema.Resource {
ForceNew: true,
DiffSuppressFunc: ignoreCaseDiffSuppressFunc,
ValidateFunc: validation.StringInSlice([]string{
string(insights.Web),
string(insights.Other),
"web",
"other",
"java",
"phone",
"store",
"ios",
}, true),
},

Expand Down
112 changes: 91 additions & 21 deletions azurerm/resource_arm_application_insights_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func TestAccAzureRMApplicationInsights_basicWeb(t *testing.T) {

ri := acctest.RandInt()
config := testAccAzureRMApplicationInsights_basicWeb(ri, testLocation())
config := testAccAzureRMApplicationInsights_basic(ri, testLocation(), "web")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -24,6 +24,28 @@ func TestAccAzureRMApplicationInsights_basicWeb(t *testing.T) {
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMApplicationInsightsExists("azurerm_application_insights.test"),
resource.TestCheckResourceAttr("azurerm_application_insights.test", "application_type", "web"),
),
},
},
})
}

func TestAccAzureRMApplicationInsights_basicJava(t *testing.T) {

ri := acctest.RandInt()
config := testAccAzureRMApplicationInsights_basic(ri, testLocation(), "java")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMApplicationInsightsDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMApplicationInsightsExists("azurerm_application_insights.test"),
resource.TestCheckResourceAttr("azurerm_application_insights.test", "application_type", "java"),
),
},
},
Expand All @@ -33,7 +55,7 @@ func TestAccAzureRMApplicationInsights_basicWeb(t *testing.T) {
func TestAccAzureRMApplicationInsights_basicOther(t *testing.T) {

ri := acctest.RandInt()
config := testAccAzureRMApplicationInsights_basicOther(ri, testLocation())
config := testAccAzureRMApplicationInsights_basic(ri, testLocation(), "other")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -44,6 +66,70 @@ func TestAccAzureRMApplicationInsights_basicOther(t *testing.T) {
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMApplicationInsightsExists("azurerm_application_insights.test"),
resource.TestCheckResourceAttr("azurerm_application_insights.test", "application_type", "other"),
),
},
},
})
}

func TestAccAzureRMApplicationInsights_basicPhone(t *testing.T) {

ri := acctest.RandInt()
config := testAccAzureRMApplicationInsights_basic(ri, testLocation(), "phone")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMApplicationInsightsDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMApplicationInsightsExists("azurerm_application_insights.test"),
resource.TestCheckResourceAttr("azurerm_application_insights.test", "application_type", "phone"),
),
},
},
})
}

func TestAccAzureRMApplicationInsights_basicStore(t *testing.T) {

ri := acctest.RandInt()
config := testAccAzureRMApplicationInsights_basic(ri, testLocation(), "store")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMApplicationInsightsDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMApplicationInsightsExists("azurerm_application_insights.test"),
resource.TestCheckResourceAttr("azurerm_application_insights.test", "application_type", "store"),
),
},
},
})
}

func TestAccAzureRMApplicationInsights_basiciOS(t *testing.T) {

ri := acctest.RandInt()
config := testAccAzureRMApplicationInsights_basic(ri, testLocation(), "ios")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMApplicationInsightsDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMApplicationInsightsExists("azurerm_application_insights.test"),
resource.TestCheckResourceAttr("azurerm_application_insights.test", "application_type", "ios"),
),
},
},
Expand Down Expand Up @@ -106,23 +192,7 @@ func testCheckAzureRMApplicationInsightsExists(name string) resource.TestCheckFu
}
}

func testAccAzureRMApplicationInsights_basicWeb(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_application_insights" "test" {
name = "acctestappinsights-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
application_type = "web"
}
`, rInt, location, rInt)
}

func testAccAzureRMApplicationInsights_basicOther(rInt int, location string) string {
func testAccAzureRMApplicationInsights_basic(rInt int, location string, applicationType string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
Expand All @@ -133,7 +203,7 @@ resource "azurerm_application_insights" "test" {
name = "acctestappinsights-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
application_type = "other"
application_type = "%s"
}
`, rInt, location, rInt)
`, rInt, location, rInt, applicationType)
}
41 changes: 32 additions & 9 deletions azurerm/resource_arm_servicebus_subscription_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,38 @@ func expandAzureRmServiceBusCorrelationFilter(d *schema.ResourceData) (*serviceb
return nil, fmt.Errorf("At least one property must be set in the `correlation_filter` block")
}

correlationFilter := servicebus.CorrelationFilter{
CorrelationID: utils.String(correlationID),
MessageID: utils.String(messageID),
To: utils.String(to),
ReplyTo: utils.String(replyTo),
Label: utils.String(label),
SessionID: utils.String(sessionID),
ReplyToSessionID: utils.String(replyToSessionID),
ContentType: utils.String(contentType),
correlationFilter := servicebus.CorrelationFilter{}

if correlationID != "" {
correlationFilter.CorrelationID = utils.String(correlationID)
}

if messageID != "" {
correlationFilter.MessageID = utils.String(messageID)
}

if to != "" {
correlationFilter.To = utils.String(to)
}

if replyTo != "" {
correlationFilter.ReplyTo = utils.String(replyTo)
}

if label != "" {
correlationFilter.Label = utils.String(label)
}

if sessionID != "" {
correlationFilter.SessionID = utils.String(sessionID)
}

if replyToSessionID != "" {
correlationFilter.ReplyToSessionID = utils.String(replyToSessionID)
}

if contentType != "" {
correlationFilter.ContentType = utils.String(contentType)
}

return &correlationFilter, nil
Expand Down
38 changes: 9 additions & 29 deletions azurerm/resource_arm_virtual_machine_scale_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"bytes"
"fmt"
"log"
"strings"

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2017-12-01/compute"

"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/structure"
Expand Down Expand Up @@ -69,14 +69,15 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource {
},

"sku": {
Type: schema.TypeSet,
Type: schema.TypeList,
Required: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.NoZeroValues,
},

"tier": {
Expand All @@ -92,7 +93,6 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource {
},
},
},
Set: resourceArmVirtualMachineScaleSetSkuHash,
},

"license_type": {
Expand Down Expand Up @@ -1323,21 +1323,6 @@ func resourceArmVirtualMachineScaleSetStorageProfileImageReferenceHash(v interfa
return hashcode.String(buf.String())
}

func resourceArmVirtualMachineScaleSetSkuHash(v interface{}) int {
var buf bytes.Buffer

if m, ok := v.(map[string]interface{}); ok {
buf.WriteString(fmt.Sprintf("%s-", m["name"].(string)))
buf.WriteString(fmt.Sprintf("%d-", m["capacity"].(int)))

if v, ok := m["tier"]; ok {
buf.WriteString(fmt.Sprintf("%s-", strings.ToLower(v.(string))))
}
}

return hashcode.String(buf.String())
}

func resourceArmVirtualMachineScaleSetStorageProfileOsDiskHash(v interface{}) int {
var buf bytes.Buffer

Expand Down Expand Up @@ -1418,20 +1403,15 @@ func resourceArmVirtualMachineScaleSetExtensionHash(v interface{}) int {
}

func expandVirtualMachineScaleSetSku(d *schema.ResourceData) (*compute.Sku, error) {
skuConfig := d.Get("sku").(*schema.Set).List()

skuConfig := d.Get("sku").([]interface{})
config := skuConfig[0].(map[string]interface{})

name := config["name"].(string)
tier := config["tier"].(string)
capacity := int64(config["capacity"].(int))

sku := &compute.Sku{
Name: &name,
Capacity: &capacity,
Name: utils.String(config["name"].(string)),
Capacity: utils.Int64(int64(config["capacity"].(int))),
}

if tier != "" {
if tier, ok := config["tier"].(string); ok && tier != "" {
sku.Tier = &tier
}

Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/application_insights.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The following arguments are supported:

* `location` - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.

* `application_type` - (Required) Specifies the type of Application Insights to create. Valid values are `Web` and `Other`.
* `application_type` - (Required) Specifies the type of Application Insights to create. Valid values are `Web`, `Java`, `Phone`, `Store`, `iOS` and `Other`.

* `tags` - (Optional) A mapping of tags to assign to the resource.

Expand Down

0 comments on commit 5d58d0d

Please sign in to comment.