Skip to content

Commit

Permalink
Made lint even more happy by adjusting naming conventions and having …
Browse files Browse the repository at this point in the history
…VSCode not complain at all
  • Loading branch information
nfx committed Jun 14, 2020
1 parent fdb9b3d commit f57c17d
Show file tree
Hide file tree
Showing 12 changed files with 133 additions and 133 deletions.
4 changes: 2 additions & 2 deletions databricks/azure_auth.go
Expand Up @@ -87,10 +87,10 @@ func (a *AzureAuth) getWorkspaceID(config *service.DBApiClientConfig) error {
"Authorization": "Bearer " + a.ManagementToken,
}
type apiVersion struct {
ApiVersion string `url:"api-version"`
APIVersion string `url:"api-version"`
}
uriPayload := apiVersion{
ApiVersion: "2018-04-01",
APIVersion: "2018-04-01",
}
var responseMap map[string]interface{}
resp, err := service.PerformQuery(config, http.MethodGet, url, "2.0", headers, false, true, uriPayload, nil)
Expand Down
10 changes: 5 additions & 5 deletions databricks/resource_databricks_azure_adls_gen2_mount_test.go
Expand Up @@ -14,7 +14,7 @@ import (
)

func TestAccAzureAdlsGen2Mount_correctly_mounts(t *testing.T) {
terraformToApply := testAccAzureAdlsGen2Mount_correctly_mounts()
terraformToApply := testAccAzureAdlsGen2MountCorrectlyMounts()

resource.Test(t, resource.TestCase{
Providers: testAccProviders,
Expand All @@ -27,7 +27,7 @@ func TestAccAzureAdlsGen2Mount_correctly_mounts(t *testing.T) {
}

func TestAccAzureAdlsGen2Mount_cluster_deleted_correctly_mounts(t *testing.T) {
terraformToApply := testAccAzureAdlsGen2Mount_correctly_mounts()
terraformToApply := testAccAzureAdlsGen2MountCorrectlyMounts()
var cluster model.ClusterInfo

resource.Test(t, resource.TestCase{
Expand All @@ -50,7 +50,7 @@ func TestAccAzureAdlsGen2Mount_cluster_deleted_correctly_mounts(t *testing.T) {
}

func TestAccAzureAdlsGen2Mount_capture_error(t *testing.T) {
terraformToApply := testAccAzureAdlsGen2Mount_capture_error()
terraformToApply := testAccAzureAdlsGen2MountCaptureError()

resource.Test(t, resource.TestCase{
Providers: testAccProviders,
Expand All @@ -65,7 +65,7 @@ func TestAccAzureAdlsGen2Mount_capture_error(t *testing.T) {
})
}

func testAccAzureAdlsGen2Mount_correctly_mounts() string {
func testAccAzureAdlsGen2MountCorrectlyMounts() string {
clientID := os.Getenv("ARM_CLIENT_ID")
clientSecret := os.Getenv("ARM_CLIENT_SECRET")
tenantID := os.Getenv("ARM_TENANT_ID")
Expand Down Expand Up @@ -129,7 +129,7 @@ func testAccAzureAdlsGen2Mount_correctly_mounts() string {
return definition
}

func testAccAzureAdlsGen2Mount_capture_error() string {
func testAccAzureAdlsGen2MountCaptureError() string {
clientID := os.Getenv("ARM_CLIENT_ID")
clientSecret := os.Getenv("ARM_CLIENT_SECRET")
tenantID := os.Getenv("ARM_TENANT_ID")
Expand Down
26 changes: 13 additions & 13 deletions databricks/resource_databricks_azure_blob_mount_test.go
Expand Up @@ -13,7 +13,7 @@ import (
)

func TestAccAzureBlobMount_correctly_mounts(t *testing.T) {
terraformToApply := testAccAzureBlobMount_correctly_mounts()
terraformToApply := testAccAzureBlobMountCorrectlyMounts()
var clusterInfo model.ClusterInfo
var azureBlobMount AzureBlobMount

Expand All @@ -23,8 +23,8 @@ func TestAccAzureBlobMount_correctly_mounts(t *testing.T) {
{
Config: terraformToApply,
Check: resource.ComposeTestCheckFunc(
testAccAzureBlobMount_cluster_exists("databricks_cluster.cluster", &clusterInfo),
testAccAzureBlobMount_mount_exists("databricks_azure_blob_mount.mount", &azureBlobMount, &clusterInfo),
testAccAzureBlobMountClusterExists("databricks_cluster.cluster", &clusterInfo),
testAccAzureBlobMountMountExists("databricks_azure_blob_mount.mount", &azureBlobMount, &clusterInfo),
),
},
{
Expand All @@ -35,15 +35,15 @@ func TestAccAzureBlobMount_correctly_mounts(t *testing.T) {
},
Config: terraformToApply,
Check: resource.ComposeTestCheckFunc(
testAccAzureBlobMount_mount_exists("databricks_azure_blob_mount.mount", &azureBlobMount, &clusterInfo),
testAccAzureBlobMountMountExists("databricks_azure_blob_mount.mount", &azureBlobMount, &clusterInfo),
),
},
},
})
}

func TestAccAzureBlobMount_cluster_deleted_correctly_mounts(t *testing.T) {
terraformToApply := testAccAzureBlobMount_correctly_mounts()
terraformToApply := testAccAzureBlobMountCorrectlyMounts()
var clusterInfo model.ClusterInfo
var azureBlobMount AzureBlobMount

Expand All @@ -53,8 +53,8 @@ func TestAccAzureBlobMount_cluster_deleted_correctly_mounts(t *testing.T) {
{
Config: terraformToApply,
Check: resource.ComposeTestCheckFunc(
testAccAzureBlobMount_cluster_exists("databricks_cluster.cluster", &clusterInfo),
testAccAzureBlobMount_mount_exists("databricks_azure_blob_mount.mount", &azureBlobMount, &clusterInfo),
testAccAzureBlobMountClusterExists("databricks_cluster.cluster", &clusterInfo),
testAccAzureBlobMountMountExists("databricks_azure_blob_mount.mount", &azureBlobMount, &clusterInfo),
),
},
{
Expand All @@ -65,14 +65,14 @@ func TestAccAzureBlobMount_cluster_deleted_correctly_mounts(t *testing.T) {
},
Config: terraformToApply,
Check: resource.ComposeTestCheckFunc(
testAccAzureBlobMount_mount_exists("databricks_azure_blob_mount.mount", &azureBlobMount, &clusterInfo),
testAccAzureBlobMountMountExists("databricks_azure_blob_mount.mount", &azureBlobMount, &clusterInfo),
),
},
},
})
}

func testAccAzureBlobMount_cluster_exists(n string, clusterInfo *model.ClusterInfo) resource.TestCheckFunc {
func testAccAzureBlobMountClusterExists(n string, clusterInfo *model.ClusterInfo) resource.TestCheckFunc {
return func(s *terraform.State) error {
// find the corresponding state object
rs, ok := s.RootModule().Resources[n]
Expand All @@ -93,7 +93,7 @@ func testAccAzureBlobMount_cluster_exists(n string, clusterInfo *model.ClusterIn
}
}

func testAccAzureBlobMount_mount_exists(n string, azureBlobMount *AzureBlobMount, clusterInfo *model.ClusterInfo) resource.TestCheckFunc {
func testAccAzureBlobMountMountExists(n string, azureBlobMount *AzureBlobMount, clusterInfo *model.ClusterInfo) resource.TestCheckFunc {
return func(s *terraform.State) error {
// find the corresponding state object
rs, ok := s.RootModule().Resources[n]
Expand All @@ -113,9 +113,9 @@ func testAccAzureBlobMount_mount_exists(n string, azureBlobMount *AzureBlobMount
tokenSecretScope, tokenSecretKey)

client := testAccProvider.Meta().(*service.DBApiClient)
cluster_id := clusterInfo.ClusterID
clusterID := clusterInfo.ClusterID

message, err := blobMount.Read(client, cluster_id)
message, err := blobMount.Read(client, clusterID)
if err != nil {
return fmt.Errorf("Error reading the mount %s: error %s", message, err)
}
Expand All @@ -126,7 +126,7 @@ func testAccAzureBlobMount_mount_exists(n string, azureBlobMount *AzureBlobMount
}
}

func testAccAzureBlobMount_correctly_mounts() string {
func testAccAzureBlobMountCorrectlyMounts() string {
clientID := os.Getenv("ARM_CLIENT_ID")
clientSecret := os.Getenv("ARM_CLIENT_SECRET")
tenantID := os.Getenv("ARM_TENANT_ID")
Expand Down
22 changes: 11 additions & 11 deletions databricks/resource_databricks_mws_credentials.go
Expand Up @@ -51,30 +51,30 @@ func resourceMWSCredentialsCreate(d *schema.ResourceData, m interface{}) error {
client := m.(*service.DBApiClient)
credentialsName := d.Get("credentials_name").(string)
roleArn := d.Get("role_arn").(string)
mwsAcctId := d.Get("account_id").(string)
credentials, err := client.MWSCredentials().Create(mwsAcctId, credentialsName, roleArn)
mwsAcctID := d.Get("account_id").(string)
credentials, err := client.MWSCredentials().Create(mwsAcctID, credentialsName, roleArn)
if err != nil {
return err
}
credentialsResourceId := PackagedMWSIds{
MwsAcctId: mwsAcctId,
ResourceId: credentials.CredentialsID,
credentialsResourceID := PackagedMWSIds{
MwsAcctID: mwsAcctID,
ResourceID: credentials.CredentialsID,
}
d.SetId(packMWSAccountId(credentialsResourceId))
d.SetId(packMWSAccountID(credentialsResourceID))
return resourceMWSCredentialsRead(d, m)
}

func resourceMWSCredentialsRead(d *schema.ResourceData, m interface{}) error {
id := d.Id()
client := m.(*service.DBApiClient)
packagedMwsId, err := unpackMWSAccountId(id)
packagedMwsID, err := unpackMWSAccountID(id)
if err != nil {
return err
}
credentials, err := client.MWSCredentials().Read(packagedMwsId.MwsAcctId, packagedMwsId.ResourceId)
credentials, err := client.MWSCredentials().Read(packagedMwsID.MwsAcctID, packagedMwsID.ResourceID)
if err != nil {
if isMWSCredentialsMissing(err.Error()) {
log.Printf("Missing e2 credentials with id: %s.", packagedMwsId.ResourceId)
log.Printf("Missing e2 credentials with id: %s.", packagedMwsID.ResourceID)
d.SetId("")
return nil
}
Expand Down Expand Up @@ -106,11 +106,11 @@ func resourceMWSCredentialsRead(d *schema.ResourceData, m interface{}) error {
func resourceMWSCredentialsDelete(d *schema.ResourceData, m interface{}) error {
id := d.Id()
client := m.(*service.DBApiClient)
packagedMwsId, err := unpackMWSAccountId(id)
packagedMwsID, err := unpackMWSAccountID(id)
if err != nil {
return err
}
err = client.MWSCredentials().Delete(packagedMwsId.MwsAcctId, packagedMwsId.ResourceId)
err = client.MWSCredentials().Delete(packagedMwsID.MwsAcctID, packagedMwsID.ResourceID)
return err
}

Expand Down
28 changes: 14 additions & 14 deletions databricks/resource_databricks_mws_credentials_mws_test.go
Expand Up @@ -17,9 +17,9 @@ func TestAccMWSCredentials(t *testing.T) {
// the acctest package includes many helpers such as RandStringFromCharSet
// See https://godoc.org/github.com/hashicorp/terraform-plugin-sdk/helper/acctest
//scope := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
mwsAcctId := os.Getenv("DATABRICKS_MWS_ACCT_ID")
mwsAcctID := os.Getenv("DATABRICKS_MWS_ACCT_ID")
mwsHost := os.Getenv("DATABRICKS_MWS_HOST")
awsAcctId := "999999999999"
awsAcctID := "999999999999"
credentialsName := "test-mws-credentials-tf"
roleName := "terraform-creds-role"

Expand All @@ -29,26 +29,26 @@ func TestAccMWSCredentials(t *testing.T) {
Steps: []resource.TestStep{
{
// use a dynamic configuration with the random name from above
Config: testMWSCredentialsCreate(mwsAcctId, mwsHost, awsAcctId, roleName, credentialsName),
Config: testMWSCredentialsCreate(mwsAcctID, mwsHost, awsAcctID, roleName, credentialsName),
// compose a basic test, checking both remote and local values
Check: resource.ComposeTestCheckFunc(
// query the API to retrieve the tokenInfo object
testMWSCredentialsResourceExists("databricks_mws_credentials.my_e2_credentials", &MWSCredentials, t),
// verify local values
resource.TestCheckResourceAttr("databricks_mws_credentials.my_e2_credentials", "account_id", mwsAcctId),
resource.TestCheckResourceAttr("databricks_mws_credentials.my_e2_credentials", "account_id", mwsAcctID),
resource.TestCheckResourceAttr("databricks_mws_credentials.my_e2_credentials", "credentials_name", credentialsName),
),
Destroy: false,
},
{
// use a dynamic configuration with the random name from above
Config: testMWSCredentialsCreate(mwsAcctId, mwsHost, awsAcctId, roleName, credentialsName),
Config: testMWSCredentialsCreate(mwsAcctID, mwsHost, awsAcctID, roleName, credentialsName),
// compose a basic test, checking both remote and local values
Check: resource.ComposeTestCheckFunc(
// query the API to retrieve the tokenInfo object
testMWSCredentialsResourceExists("databricks_mws_credentials.my_e2_credentials", &MWSCredentials, t),
// verify local values
resource.TestCheckResourceAttr("databricks_mws_credentials.my_e2_credentials", "account_id", mwsAcctId),
resource.TestCheckResourceAttr("databricks_mws_credentials.my_e2_credentials", "account_id", mwsAcctID),
resource.TestCheckResourceAttr("databricks_mws_credentials.my_e2_credentials", "credentials_name", credentialsName),
),
ExpectNonEmptyPlan: false,
Expand All @@ -63,11 +63,11 @@ func TestAccMWSCredentials(t *testing.T) {
}
},
// use a dynamic configuration with the random name from above
Config: testMWSCredentialsCreate(mwsAcctId, mwsHost, awsAcctId, roleName, credentialsName),
Config: testMWSCredentialsCreate(mwsAcctID, mwsHost, awsAcctID, roleName, credentialsName),
// compose a basic test, checking both remote and local values
Check: resource.ComposeTestCheckFunc(
// verify local values
resource.TestCheckResourceAttr("databricks_mws_credentials.my_e2_credentials", "account_id", mwsAcctId),
resource.TestCheckResourceAttr("databricks_mws_credentials.my_e2_credentials", "account_id", mwsAcctID),
resource.TestCheckResourceAttr("databricks_mws_credentials.my_e2_credentials", "credentials_name", credentialsName),
),
Destroy: false,
Expand All @@ -83,11 +83,11 @@ func testMWSCredentialsResourceDestroy(s *terraform.State) error {
if rs.Type != "databricks_mws_credentials" {
continue
}
packagedMWSIds, err := unpackMWSAccountId(rs.Primary.ID)
packagedMWSIds, err := unpackMWSAccountID(rs.Primary.ID)
if err != nil {
return err
}
_, err = client.MWSCredentials().Read(packagedMWSIds.MwsAcctId, packagedMWSIds.ResourceId)
_, err = client.MWSCredentials().Read(packagedMWSIds.MwsAcctID, packagedMWSIds.ResourceID)
if err != nil {
return nil
}
Expand All @@ -107,11 +107,11 @@ func testMWSCredentialsResourceExists(n string, mwsCreds *model.MWSCredentials,

// retrieve the configured client from the test setup
conn := getMWSClient()
packagedMWSIds, err := unpackMWSAccountId(rs.Primary.ID)
packagedMWSIds, err := unpackMWSAccountID(rs.Primary.ID)
if err != nil {
return err
}
resp, err := conn.MWSCredentials().Read(packagedMWSIds.MwsAcctId, packagedMWSIds.ResourceId)
resp, err := conn.MWSCredentials().Read(packagedMWSIds.MwsAcctID, packagedMWSIds.ResourceID)
if err != nil {
return err
}
Expand All @@ -122,7 +122,7 @@ func testMWSCredentialsResourceExists(n string, mwsCreds *model.MWSCredentials,
}
}

func testMWSCredentialsCreate(mwsAcctId, mwsHost, awsAcctId, roleName, credentialsName string) string {
func testMWSCredentialsCreate(mwsAcctID, mwsHost, awsAcctID, roleName, credentialsName string) string {
return fmt.Sprintf(`
provider "databricks" {
host = "%s"
Expand All @@ -133,5 +133,5 @@ func testMWSCredentialsCreate(mwsAcctId, mwsHost, awsAcctId, roleName, credentia
credentials_name = "%s"
role_arn = "arn:aws:iam::%s:role/%s"
}
`, mwsHost, mwsAcctId, credentialsName, awsAcctId, roleName)
`, mwsHost, mwsAcctID, credentialsName, awsAcctID, roleName)
}
20 changes: 10 additions & 10 deletions databricks/resource_databricks_mws_networks.go
Expand Up @@ -89,31 +89,31 @@ func resourceMWSNetworks() *schema.Resource {
func resourceMWSNetworkCreate(d *schema.ResourceData, m interface{}) error {
client := m.(*service.DBApiClient)
networkName := d.Get("network_name").(string)
mwsAcctId := d.Get("account_id").(string)
mwsAcctID := d.Get("account_id").(string)
VPCID := d.Get("vpc_id").(string)
subnetIds := convertListInterfaceToString(d.Get("subnet_ids").(*schema.Set).List())
securityGroupIds := convertListInterfaceToString(d.Get("security_group_ids").(*schema.Set).List())

network, err := client.MWSNetworks().Create(mwsAcctId, networkName, VPCID, subnetIds, securityGroupIds)
network, err := client.MWSNetworks().Create(mwsAcctID, networkName, VPCID, subnetIds, securityGroupIds)
if err != nil {
return err
}
networksResourceId := PackagedMWSIds{
MwsAcctId: mwsAcctId,
ResourceId: network.NetworkID,
networksResourceID := PackagedMWSIds{
MwsAcctID: mwsAcctID,
ResourceID: network.NetworkID,
}
d.SetId(packMWSAccountId(networksResourceId))
d.SetId(packMWSAccountID(networksResourceID))
return resourceMWSNetworkRead(d, m)
}

func resourceMWSNetworkRead(d *schema.ResourceData, m interface{}) error {
id := d.Id()
client := m.(*service.DBApiClient)
packagedMwsId, err := unpackMWSAccountId(id)
packagedMwsID, err := unpackMWSAccountID(id)
if err != nil {
return err
}
network, err := client.MWSNetworks().Read(packagedMwsId.MwsAcctId, packagedMwsId.ResourceId)
network, err := client.MWSNetworks().Read(packagedMwsID.MwsAcctID, packagedMwsID.ResourceID)
if err != nil {
if isMWSNetworkMissing(err.Error()) {
log.Printf("Missing e2 network with id: %s.", id)
Expand Down Expand Up @@ -173,11 +173,11 @@ func resourceMWSNetworkRead(d *schema.ResourceData, m interface{}) error {
func resourceMWSNetworkDelete(d *schema.ResourceData, m interface{}) error {
id := d.Id()
client := m.(*service.DBApiClient)
packagedMwsId, err := unpackMWSAccountId(id)
packagedMwsID, err := unpackMWSAccountID(id)
if err != nil {
return err
}
err = client.MWSNetworks().Delete(packagedMwsId.MwsAcctId, packagedMwsId.ResourceId)
err = client.MWSNetworks().Delete(packagedMwsID.MwsAcctID, packagedMwsID.ResourceID)
return err
}

Expand Down

0 comments on commit f57c17d

Please sign in to comment.