From ca6bc8823c8fbe4a35aadb51b60f135ccc927f40 Mon Sep 17 00:00:00 2001 From: Brandon Tosch Date: Fri, 3 Mar 2017 14:46:33 -0800 Subject: [PATCH] renamed arm_disk to arm_managed_disk --- ...est.go => import_arm_managed_disk_test.go} | 12 +++---- builtin/providers/azurerm/provider.go | 4 +-- ...m_disk.go => resource_arm_managed_disk.go} | 34 +++++++++---------- ...t.go => resource_arm_managed_disk_test.go} | 22 ++++++------ 4 files changed, 36 insertions(+), 36 deletions(-) rename builtin/providers/azurerm/{import_arm_disk_test.go => import_arm_managed_disk_test.go} (55%) rename builtin/providers/azurerm/{resource_arm_disk.go => resource_arm_managed_disk.go} (80%) rename builtin/providers/azurerm/{resource_arm_disk_test.go => resource_arm_managed_disk_test.go} (73%) diff --git a/builtin/providers/azurerm/import_arm_disk_test.go b/builtin/providers/azurerm/import_arm_managed_disk_test.go similarity index 55% rename from builtin/providers/azurerm/import_arm_disk_test.go rename to builtin/providers/azurerm/import_arm_managed_disk_test.go index 9887cffda..2dcf72441 100644 --- a/builtin/providers/azurerm/import_arm_disk_test.go +++ b/builtin/providers/azurerm/import_arm_managed_disk_test.go @@ -8,22 +8,22 @@ import ( "github.com/hashicorp/terraform/helper/resource" ) -func TestAccAzureRMDisk_importEmpty(t *testing.T) { - runTestAzureRMDisk_import(t, "azurerm_disk.test", testAccAzureRMDisk_empty) +func TestAccAzureRMManagedDisk_importEmpty(t *testing.T) { + runTestAzureRMManagedDisk_import(t, "azurerm_disk.test", testAccAzureRMManagedDisk_empty) } -/*func TestAccAzureRMDisk_importBlob(t *testing.T) { - runTestAzureRMDisk_import(t, "azurerm_disk.test", testAccAzureRMDisk_blob) +/*func TestAccAzureRMManagedDisk_importBlob(t *testing.T) { + runTestAzureRMManagedDisk_import(t, "azurerm_disk.test", testAccAzureRMManagedDisk_blob) }*/ -func runTestAzureRMDisk_import(t *testing.T, resourceName string, configSource string) { +func runTestAzureRMManagedDisk_import(t *testing.T, resourceName string, configSource string) { ri := acctest.RandInt() config := fmt.Sprintf(configSource, ri, ri) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, - CheckDestroy: testCheckAzureRMDiskDestroy, + CheckDestroy: testCheckAzureRMManagedDiskDestroy, Steps: []resource.TestStep{ resource.TestStep{ Config: config, diff --git a/builtin/providers/azurerm/provider.go b/builtin/providers/azurerm/provider.go index a5c37e12a..5f9e91581 100644 --- a/builtin/providers/azurerm/provider.go +++ b/builtin/providers/azurerm/provider.go @@ -70,8 +70,6 @@ func Provider() terraform.ResourceProvider { "azurerm_container_registry": resourceArmContainerRegistry(), "azurerm_container_service": resourceArmContainerService(), - "azurerm_disk": resourceArmDisk(), - "azurerm_eventhub": resourceArmEventHub(), "azurerm_eventhub_authorization_rule": resourceArmEventHubAuthorizationRule(), "azurerm_eventhub_consumer_group": resourceArmEventHubConsumerGroup(), @@ -84,6 +82,8 @@ func Provider() terraform.ResourceProvider { "azurerm_lb_probe": resourceArmLoadBalancerProbe(), "azurerm_lb_rule": resourceArmLoadBalancerRule(), + "azurerm_managed_disk": resourceArmManagedDisk(), + "azurerm_key_vault": resourceArmKeyVault(), "azurerm_local_network_gateway": resourceArmLocalNetworkGateway(), "azurerm_network_interface": resourceArmNetworkInterface(), diff --git a/builtin/providers/azurerm/resource_arm_disk.go b/builtin/providers/azurerm/resource_arm_managed_disk.go similarity index 80% rename from builtin/providers/azurerm/resource_arm_disk.go rename to builtin/providers/azurerm/resource_arm_managed_disk.go index dd1065eda..01fc42782 100644 --- a/builtin/providers/azurerm/resource_arm_disk.go +++ b/builtin/providers/azurerm/resource_arm_managed_disk.go @@ -10,12 +10,12 @@ import ( "strings" ) -func resourceArmDisk() *schema.Resource { +func resourceArmManagedDisk() *schema.Resource { return &schema.Resource{ - Create: resourceArmDiskCreate, - Read: resourceArmDiskRead, - Update: resourceArmDiskCreate, - Delete: resourceArmDiskDelete, + Create: resourceArmManagedDiskCreate, + Read: resourceArmManagedDiskRead, + Update: resourceArmManagedDiskCreate, + Delete: resourceArmManagedDiskDelete, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, @@ -88,11 +88,11 @@ func validateDiskSizeGB(v interface{}, k string) (ws []string, errors []error) { return } -func resourceArmDiskCreate(d *schema.ResourceData, meta interface{}) error { +func resourceArmManagedDiskCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*ArmClient) diskClient := client.diskClient - log.Printf("[INFO] preparing arguments for Azure ARM Disk creation.") + log.Printf("[INFO] preparing arguments for Azure ARM Managed Disk creation.") name := d.Get("name").(string) location := d.Get("location").(string) @@ -144,15 +144,15 @@ func resourceArmDiskCreate(d *schema.ResourceData, meta interface{}) error { return err } if read.ID == nil { - return fmt.Errorf("[ERROR] Cannot read Disk %s (resource group %s) ID", name, resGroup) + return fmt.Errorf("[ERROR] Cannot read Managed Disk %s (resource group %s) ID", name, resGroup) } d.SetId(*read.ID) - return resourceArmDiskRead(d, meta) + return resourceArmManagedDiskRead(d, meta) } -func resourceArmDiskRead(d *schema.ResourceData, meta interface{}) error { +func resourceArmManagedDiskRead(d *schema.ResourceData, meta interface{}) error { diskClient := meta.(*ArmClient).diskClient id, err := parseAzureResourceID(d.Id()) @@ -168,7 +168,7 @@ func resourceArmDiskRead(d *schema.ResourceData, meta interface{}) error { d.SetId("") return nil } - return fmt.Errorf("[ERROR] Error making Read request on Azure Disk %s (resource group %s): %s", name, resGroup, err) + return fmt.Errorf("[ERROR] Error making Read request on Azure Managed Disk %s (resource group %s): %s", name, resGroup, err) } d.Set("name", resp.Name) @@ -176,7 +176,7 @@ func resourceArmDiskRead(d *schema.ResourceData, meta interface{}) error { d.Set("location", resp.Location) if resp.Properties != nil { - if m, err := flattenAzureRmDiskProperties(resp.Properties); err != nil { + if m, err := flattenAzureRmManagedDiskProperties(resp.Properties); err != nil { return fmt.Errorf("[DEBUG] Error setting disk properties: %#v", err) } else { d.Set("storage_account_type", m["storage_account_type"]) @@ -189,8 +189,8 @@ func resourceArmDiskRead(d *schema.ResourceData, meta interface{}) error { } if resp.CreationData != nil { - if m, err := flattenAzureRmDiskCreationData(resp.CreationData); err != nil { - return fmt.Errorf("[DEBUG] Error setting disk creation data: %#v", err) + if m, err := flattenAzureRmManagedDiskCreationData(resp.CreationData); err != nil { + return fmt.Errorf("[DEBUG] Error setting managed disk creation data: %#v", err) } else { d.Set("create_option", m["create_option"]) if m["vhd_uri"] != nil { @@ -204,7 +204,7 @@ func resourceArmDiskRead(d *schema.ResourceData, meta interface{}) error { return nil } -func resourceArmDiskDelete(d *schema.ResourceData, meta interface{}) error { +func resourceArmManagedDiskDelete(d *schema.ResourceData, meta interface{}) error { diskClient := meta.(*ArmClient).diskClient id, err := parseAzureResourceID(d.Id()) @@ -221,7 +221,7 @@ func resourceArmDiskDelete(d *schema.ResourceData, meta interface{}) error { return nil } -func flattenAzureRmDiskProperties(properties *disk.Properties) (map[string]interface{}, error) { +func flattenAzureRmManagedDiskProperties(properties *disk.Properties) (map[string]interface{}, error) { result := make(map[string]interface{}) result["storage_account_type"] = string(properties.AccountType) result["disk_size_gb"] = *properties.DiskSizeGB @@ -232,7 +232,7 @@ func flattenAzureRmDiskProperties(properties *disk.Properties) (map[string]inter return result, nil } -func flattenAzureRmDiskCreationData(creationData *disk.CreationData) (map[string]interface{}, error) { +func flattenAzureRmManagedDiskCreationData(creationData *disk.CreationData) (map[string]interface{}, error) { result := make(map[string]interface{}) result["create_option"] = string(creationData.CreateOption) if creationData.SourceURI != nil { diff --git a/builtin/providers/azurerm/resource_arm_disk_test.go b/builtin/providers/azurerm/resource_arm_managed_disk_test.go similarity index 73% rename from builtin/providers/azurerm/resource_arm_disk_test.go rename to builtin/providers/azurerm/resource_arm_managed_disk_test.go index 12060ddaf..69472bfae 100644 --- a/builtin/providers/azurerm/resource_arm_disk_test.go +++ b/builtin/providers/azurerm/resource_arm_managed_disk_test.go @@ -11,26 +11,26 @@ import ( "github.com/hashicorp/terraform/terraform" ) -func TestAccAzureRMDisk_empty(t *testing.T) { +func TestAccAzureRMManagedDisk_empty(t *testing.T) { var d disk.Model ri := acctest.RandInt() - config := fmt.Sprintf(testAccAzureRMDisk_empty, ri, ri) + config := fmt.Sprintf(testAccAzureRMManagedDisk_empty, ri, ri) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, - CheckDestroy: testCheckAzureRMDiskDestroy, + CheckDestroy: testCheckAzureRMManagedDiskDestroy, Steps: []resource.TestStep{ { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMDiskExists("azurerm_disk.test", &d), + testCheckAzureRMManagedDiskExists("azurerm_managed_disk.test", &d), ), }, }, }) } -func testCheckAzureRMDiskExists(name string, d *disk.Model) resource.TestCheckFunc { +func testCheckAzureRMManagedDiskExists(name string, d *disk.Model) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[name] if !ok { @@ -51,7 +51,7 @@ func testCheckAzureRMDiskExists(name string, d *disk.Model) resource.TestCheckFu } if resp.StatusCode == http.StatusNotFound { - return fmt.Errorf("Bad: VirtualMachine %q (resource group %q) does not exist", dName, resourceGroup) + return fmt.Errorf("Bad: ManagedDisk %q (resource group %q) does not exist", dName, resourceGroup) } *d = resp @@ -60,11 +60,11 @@ func testCheckAzureRMDiskExists(name string, d *disk.Model) resource.TestCheckFu } } -func testCheckAzureRMDiskDestroy(s *terraform.State) error { +func testCheckAzureRMManagedDiskDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*ArmClient).diskClient for _, rs := range s.RootModule().Resources { - if rs.Type != "azurerm_disk" { + if rs.Type != "azurerm_managed_disk" { continue } @@ -78,20 +78,20 @@ func testCheckAzureRMDiskDestroy(s *terraform.State) error { } if resp.StatusCode != http.StatusNotFound { - return fmt.Errorf("Disk still exists: \n%#v", resp.Properties) + return fmt.Errorf("Managed Disk still exists: \n%#v", resp.Properties) } } return nil } -var testAccAzureRMDisk_empty = ` +var testAccAzureRMManagedDisk_empty = ` resource "azurerm_resource_group" "test" { name = "acctestRG-%d" location = "West US 2" } -resource "azurerm_disk" "test" { +resource "azurerm_managed_disk" "test" { name = "acctestd-%d" location = "West US 2" resource_group_name = "${azurerm_resource_group.test.name}"