-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 012/early4
- Loading branch information
Showing
47 changed files
with
850 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
azurerm/data_source_recovery_services_protection_policy_vm.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
43
azurerm/data_source_recovery_services_protection_policy_vm_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.