Skip to content

Commit

Permalink
provider: enable whitespace linting (#4368)
Browse files Browse the repository at this point in the history
  • Loading branch information
katbyte authored Sep 25, 2019
1 parent 1a6b660 commit 784c232
Show file tree
Hide file tree
Showing 183 changed files with 7 additions and 262 deletions.
1 change: 1 addition & 0 deletions .golangci-travisrest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ linters:
- varcheck
- vet
- vetshadow
- whitespace

linters-settings:
errcheck:
Expand Down
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ linters:
- varcheck
- vet
- vetshadow
- whitespace

linters-settings:
errcheck:
Expand Down
6 changes: 5 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fmt:
# This logic should match the search logic in scripts/gofmtcheck.sh
find . -name '*.go' | grep -v vendor | xargs gofmt -s -w

# Currently required by tf-deploy compile
# Currently required by tf-deploy compile, duplicated by linters
fmtcheck:
@sh "$(CURDIR)/scripts/gofmtcheck.sh"

Expand Down Expand Up @@ -57,6 +57,10 @@ tflint:
-S001 -S002 -S003 -S004 -S005 -S006 -S007 -S008 -S009 -S010 -S011 -S012 -S013 -S014 -S015 -S016 -S017 -S018 -S019\
./$(PKG_NAME)

whitespace:
@echo "==> Fixing source code with whitespace linter..."
golangci-lint run ./... --no-config --disable-all --enable=whitespace --fix

test-docker:
docker run --rm -v $$(pwd):/go/src/github.com/terraform-providers/terraform-provider-azurerm -w /go/src/github.com/terraform-providers/terraform-provider-azurerm golang:1.13 make test

Expand Down
2 changes: 0 additions & 2 deletions azurerm/data_source_azuread_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ func dataSourceArmAzureADApplicationRead(d *schema.ResourceData, meta interface{
var application graphrbac.Application

if oId, ok := d.GetOk("object_id"); ok {

// use the object_id to find the Azure AD application
objectId := oId.(string)
resp, err := client.Get(ctx, objectId)
Expand All @@ -94,7 +93,6 @@ func dataSourceArmAzureADApplicationRead(d *schema.ResourceData, meta interface{

application = resp
} else {

// use the name to find the Azure AD application
name := d.Get("name").(string)
filter := fmt.Sprintf("displayName eq '%s'", name)
Expand Down
6 changes: 0 additions & 6 deletions azurerm/data_source_azuread_service_principal.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ func dataSourceArmActiveDirectoryServicePrincipalRead(d *schema.ResourceData, me
var servicePrincipal *graphrbac.ServicePrincipal

if v, ok := d.GetOk("object_id"); ok {

//use the object_id to find the Azure AD service principal
objectId := v.(string)
app, err := client.Get(ctx, objectId)
Expand All @@ -64,9 +63,7 @@ func dataSourceArmActiveDirectoryServicePrincipalRead(d *schema.ResourceData, me
}

servicePrincipal = &app

} else if _, ok := d.GetOk("display_name"); ok {

// use the display_name to find the Azure AD service principal
displayName := d.Get("display_name").(string)
filter := fmt.Sprintf("displayName eq '%s'", displayName)
Expand All @@ -91,9 +88,7 @@ func dataSourceArmActiveDirectoryServicePrincipalRead(d *schema.ResourceData, me
if servicePrincipal == nil {
return fmt.Errorf("A Service Principal with the Display Name %q was not found", displayName)
}

} else {

// use the application_id to find the Azure AD service principal
applicationId := d.Get("application_id").(string)
filter := fmt.Sprintf("appId eq '%s'", applicationId)
Expand All @@ -118,7 +113,6 @@ func dataSourceArmActiveDirectoryServicePrincipalRead(d *schema.ResourceData, me
if servicePrincipal == nil {
return fmt.Errorf("A Service Principal for Application ID %q was not found", applicationId)
}

}

d.SetId(*servicePrincipal.ObjectID)
Expand Down
1 change: 0 additions & 1 deletion azurerm/data_source_express_route_circuit.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ func dataSourceArmExpressRouteCircuitRead(d *schema.ResourceData, meta interface
return fmt.Errorf("Error setting `service_provider_properties`: %+v", err)
}
}

}

if resp.Sku != nil {
Expand Down
1 change: 0 additions & 1 deletion azurerm/data_source_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ func dataSourceArmImageRead(d *schema.ResourceData, meta interface{}) error {
})
}
img = list[0]

}

d.SetId(*img.ID)
Expand Down
1 change: 0 additions & 1 deletion azurerm/data_source_log_analytics_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func dataSourceLogAnalyticsWorkspace() *schema.Resource {
"tags": tags.SchemaDataSource(),
},
}

}

func dataSourceLogAnalyticsWorkspaceRead(d *schema.ResourceData, meta interface{}) error {
Expand Down
1 change: 0 additions & 1 deletion azurerm/data_source_management_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ func dataSourceArmManagementGroupRead(d *schema.ResourceData, meta interface{})
}
}
d.Set("parent_management_group_id", parentId)

}

return nil
Expand Down
1 change: 0 additions & 1 deletion azurerm/data_source_redis_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,5 +267,4 @@ func dataSourceArmRedisCacheRead(d *schema.ResourceData, meta interface{}) error
d.Set("secondary_access_key", keys.SecondaryKey)

return tags.FlattenAndSet(d, resp.Tags)

}
1 change: 0 additions & 1 deletion azurerm/data_source_redis_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func TestAccDataSourceAzureRMRedisCache_standard(t *testing.T) {
},
},
})

}

func testAccDataSourceAzureRMRedisCache_standardWithDataSource(rInt int, location string) string {
Expand Down
1 change: 0 additions & 1 deletion azurerm/data_source_sql_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ func dataSourceArmSqlDatabaseRead(d *schema.ResourceData, meta interface{}) erro
}

if props := resp.DatabaseProperties; props != nil {

d.Set("collation", props.Collation)

d.Set("default_secondary_location", props.DefaultSecondaryLocation)
Expand Down
1 change: 0 additions & 1 deletion azurerm/data_source_storage_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ func dataSourceArmStorageAccount() *schema.Resource {
"tags": tags.SchemaDataSource(),
},
}

}

func dataSourceArmStorageAccountRead(d *schema.ResourceData, meta interface{}) error {
Expand Down
2 changes: 0 additions & 2 deletions azurerm/data_source_storage_account_blob_container_sas.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,9 @@ func dataSourceArmStorageAccountBlobContainerSharedAccessSignature() *schema.Res
},
},
}

}

func dataSourceArmStorageContainerSasRead(d *schema.ResourceData, _ interface{}) error {

connString := d.Get("connection_string").(string)
containerName := d.Get("container_name").(string)
httpsOnly := d.Get("https_only").(bool)
Expand Down
2 changes: 0 additions & 2 deletions azurerm/data_source_storage_account_sas.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,9 @@ func dataSourceArmStorageAccountSharedAccessSignature() *schema.Resource {
},
},
}

}

func dataSourceArmStorageAccountSasRead(d *schema.ResourceData, _ interface{}) error {

connString := d.Get("connection_string").(string)
httpsOnly := d.Get("https_only").(bool)
resourceTypesIface := d.Get("resource_types").([]interface{})
Expand Down
1 change: 0 additions & 1 deletion azurerm/data_source_storage_account_sas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ func TestAccDataSourceArmStorageAccountSas_servicesString(t *testing.T) {
t.Fatalf("Failed to build resource type string: expected: %s, result: %s", test.expected, result)
}
}

}

func TestAccDataSourceArmStorageAccountSas_permissionsString(t *testing.T) {
Expand Down
3 changes: 0 additions & 3 deletions azurerm/helpers/azure/app_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,6 @@ func FlattenAppServiceLogs(input *web.SiteLogsConfigProperties) []interface{} {

appLogs := make([]interface{}, 0)
if input.ApplicationLogs != nil {

appLogsItem := make(map[string]interface{})

blobStorage := make([]interface{}, 0)
Expand Down Expand Up @@ -1197,7 +1196,6 @@ func FlattenAppServiceLogs(input *web.SiteLogsConfigProperties) []interface{} {

fileSystem := make([]interface{}, 0)
if fileSystemInput := input.HTTPLogs.FileSystem; fileSystemInput != nil {

fileSystemItem := make(map[string]interface{})

if fileSystemInput.RetentionInDays != nil {
Expand Down Expand Up @@ -1464,7 +1462,6 @@ func ExpandAppServiceSiteConfig(input interface{}) (*web.SiteConfig, error) {
}

restrictions = append(restrictions, ipSecurityRestriction)

}
siteConfig.IPSecurityRestrictions = &restrictions
}
Expand Down
1 change: 0 additions & 1 deletion azurerm/helpers/azure/batch_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ func ExpandBatchPoolStartTask(list []interface{}) (*batch.StartTask, error) {
ElevationLevel: batch.ElevationLevel(autoUserMap["elevation_level"].(string)),
Scope: batch.AutoUserScope(autoUserMap["scope"].(string)),
}

}
} else if userNameValue, ok := userIdentityValue["username"]; ok {
userName := userNameValue.(string)
Expand Down
3 changes: 0 additions & 3 deletions azurerm/helpers/azure/elasticpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ var getTierFromName = map[string]string{
}

func MSSQLElasticPoolValidateSKU(diff *schema.ResourceDiff) error {

name := diff.Get("sku.0.name")
tier := diff.Get("sku.0.tier")
capacity := diff.Get("sku.0.capacity")
Expand Down Expand Up @@ -324,7 +323,6 @@ func buildErrorString(stub string, m map[int]float64) string {
}

func doDTUSKUValidation(s sku) error {

if s.MaxAllowedGB == 0 {
return fmt.Errorf(getDTUCapacityErrorMsg(s))
}
Expand Down Expand Up @@ -363,7 +361,6 @@ func doDTUSKUValidation(s sku) error {
}

func doVCoreSKUValidation(s sku) error {

if s.MaxAllowedGB == 0 {
return fmt.Errorf(getVCoreCapacityErrorMsg(s))
}
Expand Down
1 change: 0 additions & 1 deletion azurerm/helpers/azure/eventhub.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ func FlattenEventHubAuthorizationRuleRights(rights *[]eventhub.AccessRights) (li
}

func EventHubAuthorizationRuleSchemaFrom(s map[string]*schema.Schema) map[string]*schema.Schema {

authSchema := map[string]*schema.Schema{
"listen": {
Type: schema.TypeBool,
Expand Down
2 changes: 0 additions & 2 deletions azurerm/helpers/azure/key_vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
)

func GetKeyVaultBaseUrlFromID(ctx context.Context, client *keyvault.VaultsClient, keyVaultId string) (string, error) {

if keyVaultId == "" {
return "", fmt.Errorf("keyVaultId is empty")
}
Expand Down Expand Up @@ -90,7 +89,6 @@ func GetKeyVaultIDFromBaseUrl(ctx context.Context, client *keyvault.VaultsClient
}

func KeyVaultExists(ctx context.Context, client *keyvault.VaultsClient, keyVaultId string) (bool, error) {

if keyVaultId == "" {
return false, fmt.Errorf("keyVaultId is empty")
}
Expand Down
1 change: 0 additions & 1 deletion azurerm/helpers/azure/servicebus.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ func MergeSchema(a map[string]*schema.Schema, b map[string]*schema.Schema) map[s
}

func ServiceBusAuthorizationRuleSchemaFrom(s map[string]*schema.Schema) map[string]*schema.Schema {

authSchema := map[string]*schema.Schema{
"listen": {
Type: schema.TypeBool,
Expand Down
1 change: 0 additions & 1 deletion azurerm/helpers/tf/acctest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ func TestAccRandTimeInt(t *testing.T) {
if ri > 999999999999999999 {
t.Fatalf("AccRandTimeInt returned a value (%d) longer then expected", ri)
}

})
}
2 changes: 0 additions & 2 deletions azurerm/helpers/validate/int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ func TestIntDivisibleBy(t *testing.T) {
}

func TestIntInSlice(t *testing.T) {

cases := []struct {
Input []int
Value int
Expand Down Expand Up @@ -140,5 +139,4 @@ func TestIntInSlice(t *testing.T) {
t.Fatalf("Expected the validateIntInSlice trigger a validation error for input: %+v looking for %+v", tc.Input, tc.Value)
}
}

}
1 change: 0 additions & 1 deletion azurerm/helpers/validate/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func validateIpv6Address(i interface{}, k string, allowEmpty bool) (warnings []s
}

return warnings, errors

}

func CIDR(i interface{}, k string) (warnings []string, errors []error) {
Expand Down
1 change: 0 additions & 1 deletion azurerm/helpers/validate/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ func TestIPv6Address(t *testing.T) {
}
})
}

}

func TestIPv4Address(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion azurerm/internal/services/analysisservices/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ type Client struct {
}

func BuildClient(o *common.ClientOptions) *Client {

ServerClient := analysisservices.NewServersClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&ServerClient.Client, o.ResourceManagerAuthorizer)

Expand Down
1 change: 0 additions & 1 deletion azurerm/internal/services/apimanagement/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ type Client struct {
}

func BuildClient(o *common.ClientOptions) *Client {

ApiClient := apimanagement.NewAPIClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&ApiClient.Client, o.ResourceManagerAuthorizer)

Expand Down
1 change: 0 additions & 1 deletion azurerm/internal/services/applicationinsights/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ type Client struct {
}

func BuildClient(o *common.ClientOptions) *Client {

APIKeyClient := insights.NewAPIKeysClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&APIKeyClient.Client, o.ResourceManagerAuthorizer)

Expand Down
1 change: 0 additions & 1 deletion azurerm/internal/services/authorization/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ type Client struct {
}

func BuildClient(o *common.ClientOptions) *Client {

RoleAssignmentsClient := authorization.NewRoleAssignmentsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&RoleAssignmentsClient.Client, o.ResourceManagerAuthorizer)

Expand Down
1 change: 0 additions & 1 deletion azurerm/internal/services/automation/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ type Client struct {
}

func BuildClient(o *common.ClientOptions) *Client {

AccountClient := automation.NewAccountClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&AccountClient.Client, o.ResourceManagerAuthorizer)

Expand Down
1 change: 0 additions & 1 deletion azurerm/internal/services/batch/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ type Client struct {
}

func BuildClient(o *common.ClientOptions) *Client {

AccountClient := batch.NewAccountClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&AccountClient.Client, o.ResourceManagerAuthorizer)

Expand Down
1 change: 0 additions & 1 deletion azurerm/internal/services/bot/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ type Client struct {
}

func BuildClient(o *common.ClientOptions) *Client {

botClient := botservice.NewBotsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&botClient.Client, o.ResourceManagerAuthorizer)

Expand Down
1 change: 0 additions & 1 deletion azurerm/internal/services/cdn/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ type Client struct {
}

func BuildClient(o *common.ClientOptions) *Client {

CustomDomainsClient := cdn.NewCustomDomainsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&CustomDomainsClient.Client, o.ResourceManagerAuthorizer)

Expand Down
1 change: 0 additions & 1 deletion azurerm/internal/services/cognitive/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ type Client struct {
}

func BuildClient(o *common.ClientOptions) *Client {

AccountsClient := cognitiveservices.NewAccountsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&AccountsClient.Client, o.ResourceManagerAuthorizer)

Expand Down
1 change: 0 additions & 1 deletion azurerm/internal/services/containers/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ type Client struct {
}

func BuildClient(o *common.ClientOptions) *Client {

RegistriesClient := containerregistry.NewRegistriesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&RegistriesClient.Client, o.ResourceManagerAuthorizer)

Expand Down
1 change: 0 additions & 1 deletion azurerm/internal/services/cosmos/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ type Client struct {
}

func BuildClient(o *common.ClientOptions) *Client {

DatabaseClient := documentdb.NewDatabaseAccountsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&DatabaseClient.Client, o.ResourceManagerAuthorizer)

Expand Down
Loading

0 comments on commit 784c232

Please sign in to comment.