Skip to content

Commit

Permalink
run code through gofumpt and add makefile step (hashicorp#9275)
Browse files Browse the repository at this point in the history
  • Loading branch information
katbyte authored Nov 16, 2020
1 parent fa15ee9 commit 6193b92
Show file tree
Hide file tree
Showing 359 changed files with 303 additions and 435 deletions.
6 changes: 6 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ tools:
GO111MODULE=off go get -u github.com/bflad/tfproviderlint/cmd/tfproviderlint
GO111MODULE=off go get -u github.com/bflad/tfproviderdocs
GO111MODULE=off go get -u github.com/katbyte/terrafmt
GO111MODULE=off go get -u mvdan.cc/gofumpt
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH || $$GOPATH)/bin v1.32.0

build: fmtcheck generate
Expand All @@ -31,6 +32,11 @@ fmt:
# This logic should match the search logic in scripts/gofmtcheck.sh
find . -name '*.go' | grep -v vendor | xargs gofmt -s -w

fumpt:
@echo "==> Fixing source code with gofmt..."
# This logic should match the search logic in scripts/gofmtcheck.sh
find . -name '*.go' | grep -v vendor | xargs gofumpt -s -w

# Currently required by tf-deploy compile, duplicated by linters
fmtcheck:
@sh "$(CURDIR)/scripts/gofmtcheck.sh"
Expand Down
2 changes: 1 addition & 1 deletion azurerm/helpers/azure/eventhub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestValidateEventHubName(t *testing.T) {
valid: false,
},
}
var validationFunction = ValidateEventHubName()
validationFunction := ValidateEventHubName()
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := validationFunction(tt.input, "")
Expand Down
2 changes: 1 addition & 1 deletion azurerm/helpers/azure/servicebus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestValidateServiceBusTopicName(t *testing.T) {
},
}

var validationFunction = ValidateServiceBusTopicName()
validationFunction := ValidateServiceBusTopicName()
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := validationFunction(tt.input, "name")
Expand Down
2 changes: 0 additions & 2 deletions azurerm/helpers/azure/sku.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ func SplitSku(sku string) (string, int32, error) {
}

capacity, err := strconv.Atoi(skuParts[1])

if err != nil {
return "", -1, fmt.Errorf("%s in sku_name is not a valid value.", skuParts[1])
}
Expand All @@ -37,7 +36,6 @@ func MinCapacitySkuNameInSlice(valid []string, minCapacity int32, ignoreCase boo
}

name, capacity, err := SplitSku(v)

if err != nil {
es = append(es, err)
return
Expand Down
3 changes: 2 additions & 1 deletion azurerm/helpers/azure/storage_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ func SchemaStorageAccountCorsRule(patchEnabled bool) *schema.Schema {
"MERGE",
"POST",
"OPTIONS",
"PUT"}
"PUT",
}

if patchEnabled {
allowedMethods = append(allowedMethods, "PATCH")
Expand Down
1 change: 1 addition & 0 deletions azurerm/helpers/validate/time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ func TestRFC3339DateInFutureBy(t *testing.T) {
})
}
}

func TestISO8601Duration(t *testing.T) {
cases := []struct {
Value string
Expand Down
6 changes: 4 additions & 2 deletions azurerm/internal/acceptance/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

var AzureProvider *schema.Provider
var SupportedProviders map[string]terraform.ResourceProvider
var (
AzureProvider *schema.Provider
SupportedProviders map[string]terraform.ResourceProvider
)

func PreCheck(t *testing.T) {
variables := []string{
Expand Down
94 changes: 48 additions & 46 deletions azurerm/internal/location/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,49 +176,51 @@ func TestEnhancedValidationEnabled(t *testing.T) {
}
}

var chinaLocations = []string{"chinaeast", "chinanorth", "chinanorth2", "chinaeast2"}
var publicLocations = []string{
"westus",
"westus2",
"eastus",
"centralus",
"southcentralus",
"northcentralus",
"westcentralus",
"eastus2",
"brazilsouth",
"brazilus",
"northeurope",
"westeurope",
"eastasia",
"southeastasia",
"japanwest",
"japaneast",
"koreacentral",
"koreasouth",
"indiasouth",
"indiawest",
"indiacentral",
"australiaeast",
"australiasoutheast",
"canadacentral",
"canadaeast",
"uknorth",
"uksouth2",
"uksouth",
"ukwest",
"francecentral",
"francesouth",
"australiacentral",
"australiacentral2",
"uaecentral",
"uaenorth",
"southafricanorth",
"southafricawest",
"switzerlandnorth",
"switzerlandwest",
"germanynorth",
"germanywestcentral",
"norwayeast",
"norwaywest",
}
var (
chinaLocations = []string{"chinaeast", "chinanorth", "chinanorth2", "chinaeast2"}
publicLocations = []string{
"westus",
"westus2",
"eastus",
"centralus",
"southcentralus",
"northcentralus",
"westcentralus",
"eastus2",
"brazilsouth",
"brazilus",
"northeurope",
"westeurope",
"eastasia",
"southeastasia",
"japanwest",
"japaneast",
"koreacentral",
"koreasouth",
"indiasouth",
"indiawest",
"indiacentral",
"australiaeast",
"australiasoutheast",
"canadacentral",
"canadaeast",
"uknorth",
"uksouth2",
"uksouth",
"ukwest",
"francecentral",
"francesouth",
"australiacentral",
"australiacentral2",
"uaecentral",
"uaenorth",
"southafricanorth",
"southafricawest",
"switzerlandnorth",
"switzerlandwest",
"germanynorth",
"germanywestcentral",
"norwayeast",
"norwaywest",
}
)
2 changes: 1 addition & 1 deletion azurerm/internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestAzureProvider() terraform.ResourceProvider {

func azureProvider(supportLegacyTestSuite bool) terraform.ResourceProvider {
// avoids this showing up in test output
var debugLog = func(f string, v ...interface{}) {
debugLog := func(f string, v ...interface{}) {
if os.Getenv("TF_LOG") == "" {
return
}
Expand Down
2 changes: 1 addition & 1 deletion azurerm/internal/provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,5 @@ func TestResourcesSupportCustomTimeouts(t *testing.T) {
}

func TestProvider_impl(t *testing.T) {
var _ = AzureProvider()
_ = AzureProvider()
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ func flattenApiManagementApiDataSourceProtocols(input *[]apimanagement.Protocol)

return results
}

func flattenApiManagementApiDataSourceSubscriptionKeyParamNames(paramNames *apimanagement.SubscriptionKeyParameterNamesContract) []interface{} {
if paramNames == nil {
return make([]interface{}, 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func dataSourceApiManagementProduct() *schema.Resource {
},
}
}

func dataSourceApiManagementProductRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).ApiManagement.ProductsClient
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d)
Expand Down
18 changes: 10 additions & 8 deletions azurerm/internal/services/apimanagement/api_management_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ import (
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

var apimBackendProtocolSsl3 = "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30"
var apimBackendProtocolTls10 = "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10"
var apimBackendProtocolTls11 = "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11"
var apimFrontendProtocolSsl3 = "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30"
var apimFrontendProtocolTls10 = "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10"
var apimFrontendProtocolTls11 = "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11"
var apimTripleDesCiphers = "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168"
var apimHttp2Protocol = "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2"
var (
apimBackendProtocolSsl3 = "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30"
apimBackendProtocolTls10 = "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10"
apimBackendProtocolTls11 = "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11"
apimFrontendProtocolSsl3 = "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30"
apimFrontendProtocolTls10 = "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10"
apimFrontendProtocolTls11 = "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11"
apimTripleDesCiphers = "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168"
apimHttp2Protocol = "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2"
)

func resourceArmApiManagementService() *schema.Resource {
return &schema.Resource{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ func testCheckAzureRMApiManagementApiDiagnosticDestroy(s *terraform.State) error
return err
}
resp, err := client.Get(ctx, diagnosticId.ResourceGroup, diagnosticId.ServiceName, diagnosticId.ApiName, diagnosticId.Name)

if err != nil {
if !utils.ResponseWasNotFound(resp.Response) {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ func testCheckAzureRMAPIManagementAuthorizationServerDestroy(s *terraform.State)
serviceName := rs.Primary.Attributes["api_management_name"]

resp, err := client.Get(ctx, resourceGroup, serviceName, name)

if err != nil {
if !utils.ResponseWasNotFound(resp.Response) {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ func testCheckAzureRMAPIManagementCertificateDestroy(s *terraform.State) error {
serviceName := rs.Primary.Attributes["api_management_name"]

resp, err := client.Get(ctx, resourceGroup, serviceName, name)

if err != nil {
if !utils.ResponseWasNotFound(resp.Response) {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ data "azurerm_api_management" "test" {
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
}

func testAccDataSourceApiManagement_identitySystemAssigned(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ func testCheckAzureRMApiManagementDiagnosticDestroy(s *terraform.State) error {
return err
}
resp, err := client.Get(ctx, diagnosticId.ResourceGroup, diagnosticId.ServiceName, diagnosticId.Name)

if err != nil {
if !utils.ResponseWasNotFound(resp.Response) {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ func testCheckAzureRMAPIManagementGroupDestroy(s *terraform.State) error {
serviceName := rs.Primary.Attributes["api_management_name"]

resp, err := client.Get(ctx, resourceGroup, serviceName, name)

if err != nil {
if !utils.ResponseWasNotFound(resp.Response) {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ func testCheckAzureRMApiManagementIdentityProviderAADDestroy(s *terraform.State)
serviceName := rs.Primary.Attributes["api_management_name"]

resp, err := client.Get(ctx, resourceGroup, serviceName, apimanagement.Aad)

if err != nil {
if !utils.ResponseWasNotFound(resp.Response) {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ func testCheckAzureRMApiManagementIdentityProviderFacebookDestroy(s *terraform.S

ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext
resp, err := client.Get(ctx, resourceGroup, serviceName, apimanagement.Facebook)

if err != nil {
if !utils.ResponseWasNotFound(resp.Response) {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ func testCheckAzureRMApiManagementIdentityProviderGoogleDestroy(s *terraform.Sta
serviceName := rs.Primary.Attributes["api_management_name"]

resp, err := client.Get(ctx, resourceGroup, serviceName, apimanagement.Google)

if err != nil {
if !utils.ResponseWasNotFound(resp.Response) {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ func testCheckAzureRMApiManagementIdentityProviderMicrosoftDestroy(s *terraform.

ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext
resp, err := client.Get(ctx, resourceGroup, serviceName, apimanagement.Microsoft)

if err != nil {
if !utils.ResponseWasNotFound(resp.Response) {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ func testCheckAzureRMApiManagementIdentityProviderTwitterDestroy(s *terraform.St

ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext
resp, err := client.Get(ctx, resourceGroup, serviceName, apimanagement.Twitter)

if err != nil {
if !utils.ResponseWasNotFound(resp.Response) {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ func testCheckAzureRMAPIManagementNamedValueDestroy(s *terraform.State) error {
serviceName := rs.Primary.Attributes["api_management_name"]

resp, err := client.Get(ctx, resourceGroup, serviceName, name)

if err != nil {
if !utils.ResponseWasNotFound(resp.Response) {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ func testCheckAzureRMAPIManagementPropertyDestroy(s *terraform.State) error {
serviceName := rs.Primary.Attributes["api_management_name"]

resp, err := client.Get(ctx, resourceGroup, serviceName, name)

if err != nil {
if !utils.ResponseWasNotFound(resp.Response) {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ func testCheckAzureRMApiManagementDestroy(s *terraform.State) error {
name := rs.Primary.Attributes["name"]
resourceGroup := rs.Primary.Attributes["resource_group_name"]
resp, err := conn.Get(ctx, resourceGroup, name)

if err != nil {
if utils.ResponseWasNotFound(resp.Response) {
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ func testCheckAzureRMAPIManagementSubscriptionDestroy(s *terraform.State) error
serviceName := rs.Primary.Attributes["api_management_name"]

resp, err := client.Get(ctx, resourceGroup, serviceName, subscriptionId)

if err != nil {
if !utils.ResponseWasNotFound(resp.Response) {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@ func resourceArmApplicationInsightsAnalyticsItem() *schema.Resource {
func resourceArmApplicationInsightsAnalyticsItemCreate(d *schema.ResourceData, meta interface{}) error {
return resourceArmApplicationInsightsAnalyticsItemCreateUpdate(d, meta, false)
}

func resourceArmApplicationInsightsAnalyticsItemUpdate(d *schema.ResourceData, meta interface{}) error {
return resourceArmApplicationInsightsAnalyticsItemCreateUpdate(d, meta, true)
}

func resourceArmApplicationInsightsAnalyticsItemCreateUpdate(d *schema.ResourceData, meta interface{}, overwrite bool) error {
client := meta.(*clients.Client).AppInsights.AnalyticsItemsClient
ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ func testCheckAzureRMApplicationInsightsAPIKeyDestroy(s *terraform.State) error
appInsightsName := id.Path["components"]

resp, err := conn.Get(ctx, resGroup, appInsightsName, name)

if err != nil {
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ func testCheckAzureRMApplicationInsightsDestroy(s *terraform.State) error {
resourceGroup := rs.Primary.Attributes["resource_group_name"]

resp, err := conn.Get(ctx, resourceGroup, name)

if err != nil {
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ func testCheckAzureRMApplicationInsightsWebTestsDestroy(s *terraform.State) erro
resGroup := rs.Primary.Attributes["resource_group_name"]

resp, err := conn.Get(ctx, resGroup, name)

if err != nil {
return nil
}
Expand Down
Loading

0 comments on commit 6193b92

Please sign in to comment.