Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add HDInsight resource support #924

Closed
wants to merge 11 commits into from
14 changes: 14 additions & 0 deletions azurerm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/Azure/azure-sdk-for-go/services/eventgrid/mgmt/2017-09-15-preview/eventgrid"
"github.com/Azure/azure-sdk-for-go/services/eventhub/mgmt/2017-04-01/eventhub"
"github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac"
"github.com/Azure/azure-sdk-for-go/services/hdinsight/mgmt/2015-03-01-preview/hdinsight"
keyVault "github.com/Azure/azure-sdk-for-go/services/keyvault/2016-10-01/keyvault"
"github.com/Azure/azure-sdk-for-go/services/keyvault/mgmt/2016-10-01/keyvault"
"github.com/Azure/azure-sdk-for-go/services/monitor/mgmt/2017-05-01-preview/insights"
Expand Down Expand Up @@ -125,6 +126,9 @@ type ArmClient struct {
sqlFirewallRulesClient sql.FirewallRulesClient
sqlServersClient sql.ServersClient

// HDInsight
hdInsightClustersClient hdinsight.ClustersClient

// KeyVault
keyVaultClient keyvault.VaultsClient
keyVaultManagementClient keyVault.BaseClient
Expand Down Expand Up @@ -343,6 +347,7 @@ func getArmClient(c *authentication.Config) (*ArmClient, error) {
client.registerDNSClients(endpoint, c.SubscriptionID, auth, sender)
client.registerEventGridClients(endpoint, c.SubscriptionID, auth, sender)
client.registerEventHubClients(endpoint, c.SubscriptionID, auth, sender)
client.registerHDInsightClustersClients(endpoint, c.SubscriptionID, auth, sender)
client.registerKeyVaultClients(endpoint, c.SubscriptionID, auth, keyVaultAuth, sender)
client.registerMonitorClients(endpoint, c.SubscriptionID, auth, sender)
client.registerNetworkingClients(endpoint, c.SubscriptionID, auth, sender)
Expand Down Expand Up @@ -627,6 +632,15 @@ func (c *ArmClient) registerEventHubClients(endpoint, subscriptionId string, aut
c.eventHubNamespacesClient = ehnc
}

func (c *ArmClient) registerHDInsightClustersClients(endpoint, subscriptionId string, auth autorest.Authorizer, sender autorest.Sender) {
hdInsightClustersClient := hdinsight.NewClustersClientWithBaseURI(endpoint, subscriptionId)
setUserAgent(&hdInsightClustersClient.Client)
hdInsightClustersClient.Authorizer = auth
hdInsightClustersClient.Sender = sender
hdInsightClustersClient.SkipResourceProviderRegistration = c.skipProviderRegistration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor could we switch over to using the new registration format? c.configureClient(&hdInsightClustersClient.Client, auth) (we're doing this gradually for all new resources)

c.hdInsightClustersClient = hdInsightClustersClient
}

func (c *ArmClient) registerKeyVaultClients(endpoint, subscriptionId string, auth autorest.Authorizer, keyVaultAuth autorest.Authorizer, sender autorest.Sender) {
keyVaultClient := keyvault.NewVaultsClientWithBaseURI(endpoint, subscriptionId)
setUserAgent(&keyVaultClient.Client)
Expand Down
31 changes: 31 additions & 0 deletions azurerm/import_arm_hdinsight_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package azurerm

import (
"testing"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)

func TestAccAzureRMHDInsightCluster_importBasic(t *testing.T) {
resourceName := "azurerm_hdinsight_cluster.test"

ri := acctest.RandInt()
config := testAccAzureRMHDInsightCluster_basic(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMHDInsightClusterDestroy,
Steps: []resource.TestStep{
{
Config: config,
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
2 changes: 2 additions & 0 deletions azurerm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func Provider() terraform.ResourceProvider {
"azurerm_eventhub_namespace": resourceArmEventHubNamespace(),
"azurerm_express_route_circuit": resourceArmExpressRouteCircuit(),
"azurerm_function_app": resourceArmFunctionApp(),
"azurerm_hdinsight_cluster": resourceArmHDInsightCluster(),
"azurerm_image": resourceArmImage(),
"azurerm_key_vault": resourceArmKeyVault(),
"azurerm_key_vault_certificate": resourceArmKeyVaultCertificate(),
Expand Down Expand Up @@ -281,6 +282,7 @@ func determineAzureResourceProvidersToRegister(providerList []resources.Provider
"Microsoft.DocumentDB": {},
"Microsoft.EventGrid": {},
"Microsoft.EventHub": {},
"Microsoft.HDInsight": {},
"Microsoft.KeyVault": {},
"microsoft.insights": {},
"Microsoft.Network": {},
Expand Down
Loading