Skip to content

Commit

Permalink
Merge branch 'master' into 012/early4
Browse files Browse the repository at this point in the history
  • Loading branch information
katbyte committed Feb 28, 2019
2 parents 8a0e651 + 0f4cad9 commit 8d0a4da
Show file tree
Hide file tree
Showing 47 changed files with 850 additions and 238 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ FEATURES:
* **New Data Source:** `azurerm_api_management_user` [GH-2954]
* **New Data Source:** `azurerm_availability_set` [GH-2850]
* **New Data Source:** `azurerm_network_watcher` [GH-2791]
* **New Data Source:** `azurerm_recovery_services_protection_policy_vm` [GH-2974]
* **New Resource:** `azurerm_api_management_group` [GH-2809]
* **New Resource:** `azurerm_api_management_product` [GH-2953]
* **New Resource:** `azurerm_api_management_user` [GH-2954]
Expand All @@ -19,10 +20,12 @@ IMPROVEMENTS:

* dependencies: upgrading to v25.1.0 of `github.com/Azure/azure-sdk-for-go` [GH-2886]
* dependencies: upgrading to v11.4.0 of `github.com/Azure/go-autorest` [GH-2886]
* `azurerm_application_gateway` - support for `path` within the `backend_http_settings` block [GH-2879]
* `azurerm_application_gateway` - support for setting `path` within the `backend_http_settings` block [GH-2879]
* `azurerm_application_gateway` - support for setting `connection_draining` to the `backend_http_settings` [GH-2778]
* `azurerm_iothub` - support for the `fallback_route` property [GH-2764]
* `azurerm_redis_cache` - support for configuring the `maxfragmentationmemory_reserved` in the `redis_configuration` block [GH-2887]
* `azurerm_service_fabric_cluster` - support for setting `capacities` and `placement_properties` [GH-2936]
* `azurerm_storage_account` - exposing primary/secondary `_host` attributes [GH-2792]

BUG FIXES:

Expand Down
2 changes: 1 addition & 1 deletion azurerm/data_source_api_management_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestAccDataSourceAzureRMApiManagementUser_basic(t *testing.T) {
resource.TestCheckResourceAttr(dataSourceName, "user_id", "test-user"),
resource.TestCheckResourceAttr(dataSourceName, "first_name", "Acceptance"),
resource.TestCheckResourceAttr(dataSourceName, "last_name", "Test"),
resource.TestCheckResourceAttr(dataSourceName, "email", fmt.Sprintf("azure-acctest%d@hashicorptest.com", rInt)),
resource.TestCheckResourceAttr(dataSourceName, "email", fmt.Sprintf("azure-acctest%d@example.com", rInt)),
resource.TestCheckResourceAttr(dataSourceName, "state", "active"),
resource.TestCheckResourceAttr(dataSourceName, "note", "Used for testing in dimension C-137."),
),
Expand Down
9 changes: 7 additions & 2 deletions azurerm/data_source_availability_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package azurerm

import (
"fmt"
"strconv"
"strings"

"github.com/hashicorp/terraform/helper/schema"
Expand Down Expand Up @@ -70,8 +71,12 @@ func dataSourceArmAvailabilitySetRead(d *schema.ResourceData, meta interface{})
d.Set("managed", strings.EqualFold(*resp.Sku.Name, "Aligned"))
}
if props := resp.AvailabilitySetProperties; props != nil {
d.Set("platform_update_domain_count", props.PlatformUpdateDomainCount)
d.Set("platform_fault_domain_count", props.PlatformFaultDomainCount)
if v := props.PlatformUpdateDomainCount; v != nil {
d.Set("platform_update_domain_count", strconv.Itoa(int(*v)))
}
if v := props.PlatformFaultDomainCount; v != nil {
d.Set("platform_fault_domain_count", strconv.Itoa(int(*v)))
}
}
flattenAndSetTags(d, resp.Tags)

Expand Down
2 changes: 1 addition & 1 deletion azurerm/data_source_policy_definition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestAccDataSourceAzureRMPolicyDefinition_builtIn(t *testing.T) {
testAzureRMClientConfigAttr(dataSourceName, "name", "a08ec900-254a-4555-9bf5-e42af04b5c5c"),
testAzureRMClientConfigAttr(dataSourceName, "display_name", "Allowed resource types"),
testAzureRMClientConfigAttr(dataSourceName, "type", "Microsoft.Authorization/policyDefinitions"),
testAzureRMClientConfigAttr(dataSourceName, "description", "This policy enables you to specify the resource types that your organization can deploy."),
testAzureRMClientConfigAttr(dataSourceName, "description", "This policy enables you to specify the resource types that your organization can deploy. Only resource types that support 'tags' and 'location' will be affected by this policy. To restrict all resources please duplicate this policy and change the 'mode' to 'All'."),
),
},
},
Expand Down
58 changes: 58 additions & 0 deletions azurerm/data_source_recovery_services_protection_policy_vm.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package azurerm

import (
"fmt"
"log"

"github.com/hashicorp/terraform/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

func dataSourceArmRecoveryServicesProtectionPolicyVm() *schema.Resource {
return &schema.Resource{
Read: dataSourceArmRecoveryServicesProtectionPolicyVmRead,

Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},

"recovery_vault_name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},

"resource_group_name": resourceGroupNameForDataSourceSchema(),

"tags": tagsForDataSourceSchema(),
},
}
}

func dataSourceArmRecoveryServicesProtectionPolicyVmRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*ArmClient).recoveryServicesProtectionPoliciesClient
ctx := meta.(*ArmClient).StopContext

name := d.Get("name").(string)
resourceGroup := d.Get("resource_group_name").(string)
vaultName := d.Get("recovery_vault_name").(string)

log.Printf("[DEBUG] Reading Recovery Service Protection Policy %q (resource group %q)", name, resourceGroup)

protectionPolicy, err := client.Get(ctx, vaultName, resourceGroup, name)
if err != nil {
if utils.ResponseWasNotFound(protectionPolicy.Response) {
return fmt.Errorf("Error: Recovery Services Protection Policy %q (Resource Group %q) was not found", name, resourceGroup)
}

return fmt.Errorf("Error making Read request on Recovery Service Protection Policy %q (Resource Group %q): %+v", name, resourceGroup, err)
}

d.SetId(*protectionPolicy.ID)

flattenAndSetTags(d, protectionPolicy.Tags)
return nil
}
43 changes: 43 additions & 0 deletions azurerm/data_source_recovery_services_protection_policy_vm_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package azurerm

import (
"fmt"
"testing"

"github.com/hashicorp/terraform/helper/resource"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
)

func TestAccDataSourceAzureRMRecoveryServicesProtectionPolicyVm_basic(t *testing.T) {
dataSourceName := "data.azurerm_recovery_services_protection_policy_vm.test"
ri := tf.AccRandTimeInt()

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccDataSourceRecoveryServicesProtectionPolicyVm_basic(ri, testLocation()),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMRecoveryServicesProtectionPolicyVmExists(dataSourceName),
resource.TestCheckResourceAttrSet(dataSourceName, "name"),
resource.TestCheckResourceAttrSet(dataSourceName, "recovery_vault_name"),
resource.TestCheckResourceAttrSet(dataSourceName, "resource_group_name"),
resource.TestCheckResourceAttr(dataSourceName, "tags.%", "0"),
),
},
},
})
}

func testAccDataSourceRecoveryServicesProtectionPolicyVm_basic(rInt int, location string) string {
return fmt.Sprintf(`
%s
data "azurerm_recovery_services_protection_policy_vm" "test" {
name = "${azurerm_recovery_services_protection_policy_vm.test.name}"
recovery_vault_name = "${azurerm_recovery_services_vault.test.name}"
resource_group_name = "${azurerm_resource_group.test.name}"
}
`, testAccAzureRMRecoveryServicesProtectionPolicyVm_basicDaily(rInt, location))
}
78 changes: 49 additions & 29 deletions azurerm/data_source_storage_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,37 +91,72 @@ func dataSourceArmStorageAccount() *schema.Resource {
Computed: true,
},

"primary_blob_host": {
Type: schema.TypeString,
Computed: true,
},

"secondary_blob_endpoint": {
Type: schema.TypeString,
Computed: true,
},

"secondary_blob_host": {
Type: schema.TypeString,
Computed: true,
},

"primary_queue_endpoint": {
Type: schema.TypeString,
Computed: true,
},

"primary_queue_host": {
Type: schema.TypeString,
Computed: true,
},

"secondary_queue_endpoint": {
Type: schema.TypeString,
Computed: true,
},

"secondary_queue_host": {
Type: schema.TypeString,
Computed: true,
},

"primary_table_endpoint": {
Type: schema.TypeString,
Computed: true,
},

"primary_table_host": {
Type: schema.TypeString,
Computed: true,
},

"secondary_table_endpoint": {
Type: schema.TypeString,
Computed: true,
},

"secondary_table_host": {
Type: schema.TypeString,
Computed: true,
},

// NOTE: The API does not appear to expose a secondary file endpoint
"primary_file_endpoint": {
Type: schema.TypeString,
Computed: true,
},

"primary_file_host": {
Type: schema.TypeString,
Computed: true,
},

"primary_access_key": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -234,40 +269,25 @@ func dataSourceArmStorageAccountRead(d *schema.ResourceData, meta interface{}) e
d.Set("secondary_connection_string", scs)
}

if endpoints := props.PrimaryEndpoints; endpoints != nil {
d.Set("primary_blob_endpoint", endpoints.Blob)
d.Set("primary_queue_endpoint", endpoints.Queue)
d.Set("primary_table_endpoint", endpoints.Table)
d.Set("primary_file_endpoint", endpoints.File)

pscs := fmt.Sprintf("DefaultEndpointsProtocol=https;BlobEndpoint=%s;AccountName=%s;AccountKey=%s",
*endpoints.Blob, *resp.Name, *accessKeys[0].Value)
d.Set("primary_blob_connection_string", pscs)
if err := flattenAndSetAzureRmStorageAccountPrimaryEndpoints(d, props.PrimaryEndpoints); err != nil {
return fmt.Errorf("error setting primary endpoints and hosts for blob, queue, table and file: %+v", err)
}

if endpoints := props.SecondaryEndpoints; endpoints != nil {
if blob := endpoints.Blob; blob != nil {
d.Set("secondary_blob_endpoint", blob)
sscs := fmt.Sprintf("DefaultEndpointsProtocol=https;BlobEndpoint=%s;AccountName=%s;AccountKey=%s",
*blob, *resp.Name, *accessKeys[1].Value)
d.Set("secondary_blob_connection_string", sscs)
} else {
d.Set("secondary_blob_endpoint", "")
d.Set("secondary_blob_connection_string", "")
}
var primaryBlobConnectStr string
if v := props.PrimaryEndpoints; v != nil {
primaryBlobConnectStr = getBlobConnectionString(v.Blob, resp.Name, accessKeys[0].Value)
}
d.Set("primary_blob_connection_string", primaryBlobConnectStr)

if endpoints.Queue != nil {
d.Set("secondary_queue_endpoint", endpoints.Queue)
} else {
d.Set("secondary_queue_endpoint", "")
}
if err := flattenAndSetAzureRmStorageAccountSecondaryEndpoints(d, props.SecondaryEndpoints); err != nil {
return fmt.Errorf("error setting secondary endpoints and hosts for blob, queue, table: %+v", err)
}

if endpoints.Table != nil {
d.Set("secondary_table_endpoint", endpoints.Table)
} else {
d.Set("secondary_table_endpoint", "")
}
var secondaryBlobConnectStr string
if v := props.SecondaryEndpoints; v != nil {
secondaryBlobConnectStr = getBlobConnectionString(v.Blob, resp.Name, accessKeys[1].Value)
}
d.Set("secondary_blob_connection_string", secondaryBlobConnectStr)
}

d.Set("primary_access_key", accessKeys[0].Value)
Expand Down
Loading

0 comments on commit 8d0a4da

Please sign in to comment.