Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
katbyte committed Dec 8, 2022
1 parent 1f279be commit 088d015
Show file tree
Hide file tree
Showing 783 changed files with 1,197 additions and 1,707 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ run:
skip-dirs:
- /sdk/ # Excluding sdk folders as these are externally generated
skip-files:
- ".*\\*_gen.go$"
- "internal/services/.*/.*_gen.go$"

issues:
max-per-linter: 0
Expand Down
2 changes: 1 addition & 1 deletion contributing/topics/guide-new-data-source.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The Client for the Service Package can be found in `./internal/services/{name}/c
package client

import (
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-06-01/resources"
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-06-01/resources" // nolint: staticcheck
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
)

Expand Down
4 changes: 2 additions & 2 deletions contributing/topics/guide-new-resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The Client for the Service Package can be found in `./internal/services/{name}/c
package client

import (
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-06-01/resources"
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-06-01/resources" // nolint: staticcheck
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
)

Expand Down Expand Up @@ -357,7 +357,7 @@ import (
"fmt"
"time"

"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-06-01/resources"
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-06-01/resources" // nolint: staticcheck
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
Expand Down
4 changes: 2 additions & 2 deletions internal/acceptance/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func Environment() (*azure.Environment, error) {
}

func GetAuthConfig(t *testing.T) *authentication.Config {
if os.Getenv(resource.TestEnvVar) == "" {
t.Skip(fmt.Sprintf("Integration test skipped unless env '%s' set", resource.TestEnvVar))
if os.Getenv(resource.EnvTfAcc) == "" {
t.Skipf("Integration test skipped unless env '%s' set", resource.EnvTfAcc)
return nil
}

Expand Down
5 changes: 1 addition & 4 deletions internal/clients/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package clients

import (
"context"
"fmt"

"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/validation"
Expand Down Expand Up @@ -244,9 +243,7 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error
// Disable the Azure SDK for Go's validation since it's unhelpful for our use-case
validation.Disabled = true

if err := buildAutoClients(&client.autoClient, o); err != nil {
return fmt.Errorf("building auto-sdk clients: %+v", err)
}
buildAutoClients(&client.autoClient, o)

client.Features = o.Features
client.StopContext = ctx
Expand Down
3 changes: 1 addition & 2 deletions internal/clients/client_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ type autoClient struct {
ManagedIdentity *managedidentity_v2022_01_31_preview.Client
}

func buildAutoClients(client *autoClient, o *common.ClientOptions) error {
func buildAutoClients(client *autoClient, o *common.ClientOptions) {
client.ContainerService = containers.NewClient(o)
client.LoadTestService = loadtestservice.NewClient(o)
client.ManagedIdentity = managedidentity.NewClient(o)
return nil
}
2 changes: 1 addition & 1 deletion internal/sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"fmt"
"time"
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-06-01/resources"
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-06-01/resources" // nolint: staticcheck
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
Expand Down
4 changes: 2 additions & 2 deletions internal/sdk/logger_console.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type ConsoleLogger struct{}

// Info prints out a message prefixed with `[INFO]` verbatim
func (ConsoleLogger) Info(message string) {
log.Print(fmt.Sprintf("[INFO] %s", message))
log.Printf("[INFO] %s", message)
}

// Infof prints out a message prefixed with `[INFO]` formatted
Expand All @@ -24,7 +24,7 @@ func (l ConsoleLogger) Infof(format string, args ...interface{}) {

// Warn prints out a message prefixed with `[WARN]` formatted verbatim
func (l ConsoleLogger) Warn(message string) {
log.Print(fmt.Sprintf("[WARN] %s", message))
log.Printf("[WARN] %s", message)
}

// Warnf prints out a message prefixed with `[WARN]` formatted
Expand Down
30 changes: 15 additions & 15 deletions internal/sdk/plugin_sdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestAccPluginSDKAndDecoder(t *testing.T) {
},
}

//lintignore:AT001
// lintignore:AT001
resource.ParallelTest(t, resource.TestCase{
ProviderFactories: map[string]func() (*schema.Provider, error){
"validator": func() (*schema.Provider, error) { //nolint:unparam
Expand Down Expand Up @@ -150,7 +150,7 @@ func TestAccPluginSDKAndDecoder(t *testing.T) {
},
},
},
Create: func(d *schema.ResourceData, i interface{}) error { //nolint:SA1019
Create: func(d *schema.ResourceData, i interface{}) error {
d.SetId("some-id")
d.Set("hello", "world")
d.Set("random_number", 42)
Expand Down Expand Up @@ -178,7 +178,7 @@ func TestAccPluginSDKAndDecoder(t *testing.T) {
})
return nil
},
Read: func(d *schema.ResourceData, _ interface{}) error { //nolint:SA1019
Read: func(d *schema.ResourceData, _ interface{}) error { //nolint:staticcheck
wrapper := ResourceMetaData{
ResourceData: d,
Logger: ConsoleLogger{},
Expand All @@ -196,7 +196,7 @@ func TestAccPluginSDKAndDecoder(t *testing.T) {

return nil
},
Delete: func(_ *schema.ResourceData, _ interface{}) error { //nolint:SA1019
Delete: func(_ *schema.ResourceData, _ interface{}) error { //nolint:staticcheck
return nil
},
},
Expand Down Expand Up @@ -260,7 +260,7 @@ func TestAccPluginSDKAndDecoderOptionalComputed(t *testing.T) {
}
}

//lintignore:AT001
// lintignore:AT001
resource.ParallelTest(t, resource.TestCase{
ProviderFactories: map[string]func() (*schema.Provider, error){
"validator": func() (*schema.Provider, error) { //nolint:unparam
Expand All @@ -269,7 +269,7 @@ func TestAccPluginSDKAndDecoderOptionalComputed(t *testing.T) {
ResourcesMap: map[string]*schema.Resource{
"validator_decoder_specified": {
Schema: commonSchema,
Create: func(d *schema.ResourceData, i interface{}) error { //nolint:SA1019
Create: func(d *schema.ResourceData, i interface{}) error { //nolint:staticcheck
d.SetId("some-id")
return nil
},
Expand All @@ -285,7 +285,7 @@ func TestAccPluginSDKAndDecoderOptionalComputed(t *testing.T) {

"validator_decoder_unspecified": {
Schema: commonSchema,
Create: func(d *schema.ResourceData, i interface{}) error { //nolint:SA1019
Create: func(d *schema.ResourceData, i interface{}) error { //nolint:staticcheck
d.SetId("some-id")
d.Set("hello", "value-from-create")
d.Set("number", 42)
Expand Down Expand Up @@ -346,7 +346,7 @@ func TestAccPluginSDKAndDecoderOptionalComputedOverride(t *testing.T) {
// TODO: do we need other field types, or is this sufficient?
}

//lintignore:AT001
// lintignore:AT001
resource.ParallelTest(t, resource.TestCase{
ProviderFactories: map[string]func() (*schema.Provider, error){
"validator": func() (*schema.Provider, error) { //nolint:unparam
Expand All @@ -371,7 +371,7 @@ func TestAccPluginSDKAndDecoderOptionalComputedOverride(t *testing.T) {
Computed: true,
},
},
Create: func(d *schema.ResourceData, i interface{}) error { //nolint:SA1019
Create: func(d *schema.ResourceData, i interface{}) error { //nolint:staticcheck
d.SetId("some-id")
d.Set("hello", "value-from-create")
d.Set("number", 42)
Expand Down Expand Up @@ -452,7 +452,7 @@ func TestAccPluginSDKAndDecoderSets(t *testing.T) {
// so we should be covered via this test alone
}

//lintignore:AT001
// lintignore:AT001
resource.ParallelTest(t, resource.TestCase{
ProviderFactories: map[string]func() (*schema.Provider, error){
"validator": func() (*schema.Provider, error) { //nolint:unparam
Expand Down Expand Up @@ -490,7 +490,7 @@ func TestAccPluginSDKAndDecoderSets(t *testing.T) {
},
},
},
Create: func(d *schema.ResourceData, i interface{}) error { //nolint:SA1019
Create: func(d *schema.ResourceData, i interface{}) error { //nolint:staticcheck
d.SetId("some-id")
d.Set("set_of_strings", []string{
"some",
Expand Down Expand Up @@ -645,7 +645,7 @@ func TestAccPluginSDKAndEncoder(t *testing.T) {
SetOfFloats []float64 `tfschema:"set_of_floats"`
}

//lintignore:AT001
// lintignore:AT001
resource.ParallelTest(t, resource.TestCase{
ProviderFactories: map[string]func() (*schema.Provider, error){
"validator": func() (*schema.Provider, error) { //nolint:unparam
Expand Down Expand Up @@ -763,7 +763,7 @@ func TestAccPluginSDKAndEncoder(t *testing.T) {
},
},
},
Create: func(d *schema.ResourceData, i interface{}) error { //nolint:SA1019
Create: func(d *schema.ResourceData, i interface{}) error { //nolint:staticcheck
wrapper := ResourceMetaData{
ResourceData: d,
Logger: ConsoleLogger{},
Expand Down Expand Up @@ -863,7 +863,7 @@ func TestAccPluginSDKReturnsComputedFields(t *testing.T) {
os.Setenv("TF_ACC", "1")

resourceName := "validator_computed.test"
//lintignore:AT001
// lintignore:AT001
resource.ParallelTest(t, resource.TestCase{
ProviderFactories: map[string]func() (*schema.Provider, error){
"validator": func() (*schema.Provider, error) { //nolint:unparam
Expand Down Expand Up @@ -980,7 +980,7 @@ func computedFieldsResource() *schema.Resource {
},
},
},
Create: func(d *schema.ResourceData, meta interface{}) error { //nolint:SA1019
Create: func(d *schema.ResourceData, meta interface{}) error { //nolint:staticcheck
d.SetId("does-not-matter")
return readFunc(d, meta)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor"
"github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor" // nolint: staticcheck
"github.com/gofrs/uuid"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down
2 changes: 1 addition & 1 deletion internal/services/advisor/client/client.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package client

import (
"github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor"
"github.com/Azure/azure-sdk-for-go/services/advisor/mgmt/2020-01-01/advisor" // nolint: staticcheck
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func TestAccAzureRMAnalysisServicesServer_adminUsers(t *testing.T) {
const ArmAccAdminEmail2 = "ARM_ACCTEST_ADMIN_EMAIL2"

if os.Getenv(ArmAccAdminEmail1) == "" || os.Getenv(ArmAccAdminEmail2) == "" {
t.Skip(fmt.Sprintf("Acceptance test skipped unless env '%s' and '%s' set", ArmAccAdminEmail1, ArmAccAdminEmail2))
t.Skipf("Acceptance test skipped unless env '%s' and '%s' set", ArmAccAdminEmail1, ArmAccAdminEmail2)
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"time"

"github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2021-08-01/apimanagement"
"github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2021-08-01/apimanagement" // nolint: staticcheck
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/apimanagement/parse"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"time"

"github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2021-08-01/apimanagement"
"github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2021-08-01/apimanagement" // nolint: staticcheck
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down Expand Up @@ -124,7 +124,7 @@ func resourceApiManagementApiDiagnostic() *pluginsdk.Resource {
}

func resourceApiManagementApiDiagnosticAdditionalContentSchema() *pluginsdk.Schema {
//lintignore:XS003
// lintignore:XS003
return &pluginsdk.Schema{
Type: pluginsdk.TypeList,
MaxItems: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"log"
"time"

"github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2021-08-01/apimanagement"
"github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2021-08-01/apimanagement" // nolint: staticcheck
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"testing"

"github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2021-08-01/apimanagement"
"github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2021-08-01/apimanagement" // nolint: staticcheck
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"time"

"github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2021-08-01/apimanagement"
"github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2021-08-01/apimanagement" // nolint: staticcheck
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"time"

"github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2021-08-01/apimanagement"
"github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2021-08-01/apimanagement" // nolint: staticcheck
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/apimanagement/parse"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"log"
"time"

"github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2021-08-01/apimanagement"
"github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2021-08-01/apimanagement" // nolint: staticcheck
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"testing"

"github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2021-08-01/apimanagement"
"github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2021-08-01/apimanagement" // nolint: staticcheck
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"time"

"github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2021-08-01/apimanagement"
"github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2021-08-01/apimanagement" // nolint: staticcheck
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/apimanagement/parse"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2021-08-01/apimanagement"
"github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2021-08-01/apimanagement" // nolint: staticcheck
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"log"
"time"

"github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2021-08-01/apimanagement"
"github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2021-08-01/apimanagement" // nolint: staticcheck
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,3 @@ resource "azurerm_api_management_api_schema" "test" {
}
`, r.template(data), data.RandomInteger)
}
func (r ApiManagementApiSchemaResource) definitionsYaml(data acceptance.TestData) string {
return fmt.Sprintf(`
%s
resource "azurerm_api_management_api_schema" "test" {
api_name = azurerm_api_management_api.test.name
api_management_name = azurerm_api_management_api.test.api_management_name
resource_group_name = azurerm_api_management_api.test.resource_group_name
schema_id = "acctestSchema%d"
content_type = "application/vnd.ms-azure-apim.swagger.definitions+json"
definitions = file("testdata/api_management_api_swagger_definitions.yaml")
}
`, r.template(data), data.RandomInteger)
}
Loading

0 comments on commit 088d015

Please sign in to comment.