Skip to content

Commit

Permalink
Add linter to standardize golang import order (#175)
Browse files Browse the repository at this point in the history
The gci linter is added to the default linter list. The make fix command
if run manually can fix the import problems in the project.
  • Loading branch information
tevesz authored Nov 6, 2024
1 parent 6362328 commit b299e93
Show file tree
Hide file tree
Showing 63 changed files with 207 additions and 125 deletions.
34 changes: 34 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
run:
tests: true

linters:
disable-all: true
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
- gci

linters-settings:
gci:
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(github.com/cloudera/terraform-provider-cdp) # Custom section: groups all imports with the specified Prefix.
- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
# Skip generated files.
# Default: true
skip-generated: true

output:
format: colored-line-number
print-issued-lines: false

issues:
max-issues-per-linter: 0
max-same-issues: 0
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ build: generate fmt vet
lint:
golangci-lint run

# See https://golangci-lint.run/
fix:
golangci-lint run --fix

install: main
go install .

Expand Down
3 changes: 2 additions & 1 deletion cdp-sdk-go/cdp/retryable_transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ package cdp
import (
"bytes"
"fmt"
"github.com/jarcoal/httpmock"
"io"
"net/http"
"os"
"testing"

"github.com/jarcoal/httpmock"
)

const (
Expand Down
7 changes: 4 additions & 3 deletions cdp-sdk-go/cdp/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ package cdp

import (
"context"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
"net/http"
"regexp"
"testing"

"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
)

var (
Expand Down
5 changes: 3 additions & 2 deletions cdpacctest/acctest.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ import (
"sync"
"testing"

"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/cdp"
"github.com/cloudera/terraform-provider-cdp/provider"
"github.com/hashicorp/terraform-plugin-framework/providerserver"
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/pkg/errors"

"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/cdp"
"github.com/cloudera/terraform-provider-cdp/provider"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import (
"flag"
"log"

"github.com/cloudera/terraform-provider-cdp/provider"
"github.com/hashicorp/terraform-plugin-framework/providerserver"

"github.com/cloudera/terraform-provider-cdp/provider"
)

var (
Expand Down
6 changes: 4 additions & 2 deletions resources/datahub/constants_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@

package datahub

import "reflect"
import "testing"
import (
"reflect"
"testing"
)

func TestFailedStatusKeywords(t *testing.T) {
expected := [2]string{"FAILED", "DELETED"}
Expand Down
3 changes: 2 additions & 1 deletion resources/datahub/converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import (
"context"
"testing"

"github.com/cloudera/terraform-provider-cdp/utils/test"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/types"

"github.com/cloudera/terraform-provider-cdp/utils/test"
)

func TestFromModelToRequestBasicFields(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion resources/datahub/model_datahub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
package datahub

import (
"github.com/hashicorp/terraform-plugin-framework/types"
"testing"

"github.com/hashicorp/terraform-plugin-framework/types"
)

func TestForceDeleteRequestedForAws(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion resources/datahub/model_gcp_datahub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
package datahub

import (
"github.com/hashicorp/terraform-plugin-framework/types"
"testing"

"github.com/hashicorp/terraform-plugin-framework/types"
)

func TestForceDeleteRequestedForGcp(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions resources/datahub/polling.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"context"
"errors"
"fmt"

"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"

Expand Down
3 changes: 2 additions & 1 deletion resources/datahub/schema_aws_datahub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ package datahub

import (
"context"
"testing"

"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"testing"
)

func TestAwsSchemaContainsCommonElements(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion resources/datahub/schema_azure_datahub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ package datahub

import (
"context"
"testing"

"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"testing"
)

func TestAzureSchemaContainsCommonElements(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion resources/datahub/schema_gcp_datahub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ package datahub

import (
"context"

"testing"

"github.com/hashicorp/terraform-plugin-framework/resource"
Expand Down
3 changes: 1 addition & 2 deletions resources/datalake/converter_gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ import (
"context"

"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"

"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"

datalakemodels "github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/datalake/models"
"github.com/cloudera/terraform-provider-cdp/utils"
Expand Down
3 changes: 2 additions & 1 deletion resources/datalake/converter_gcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
package datalake

import (
"github.com/go-openapi/strfmt"
"testing"

"github.com/go-openapi/strfmt"

datalakemodels "github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/datalake/models"
)

Expand Down
7 changes: 4 additions & 3 deletions resources/datalake/resource_aws_datalake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ import (
"sync"
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"

"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/cdp"
"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/datalake/client/operations"
"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/datalake/models"
"github.com/cloudera/terraform-provider-cdp/cdpacctest"
"github.com/cloudera/terraform-provider-cdp/utils"
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion resources/datalake/resource_azure_datalake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import (
"context"
"testing"

"github.com/cloudera/terraform-provider-cdp/utils/test"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/types"

"github.com/cloudera/terraform-provider-cdp/utils/test"
)

func TestFromModelToAzureRequestBasicFields(t *testing.T) {
Expand Down
12 changes: 6 additions & 6 deletions resources/de/resource_data_engineering_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ import (
"context"
"errors"

"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/cdp"
"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/de/client/operations"
"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/de/models"
"github.com/cloudera/terraform-provider-cdp/utils"
"github.com/hashicorp/terraform-plugin-framework/types"

"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
"github.com/hashicorp/terraform-plugin-log/tflog"

"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/cdp"
"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/de/client/operations"
"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/de/models"
"github.com/cloudera/terraform-provider-cdp/utils"
)

var _ resource.Resource = (*serviceResource)(nil)
Expand Down
3 changes: 1 addition & 2 deletions resources/de/schema_data_engineering_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
package de

import (
"github.com/hashicorp/terraform-plugin-framework/types"

"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
)

var serviceSchema = schema.Schema{
Expand Down
8 changes: 5 additions & 3 deletions resources/dw/cluster/aws/model_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ package aws

import (
"context"
models2 "github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/dw/models"
"testing"
"time"

"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/stretchr/testify/suite"
"testing"
"time"

models2 "github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/dw/models"
)

type DwClusterModelTestSuite struct {
Expand Down
14 changes: 8 additions & 6 deletions resources/dw/cluster/aws/resource_cluster_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ package aws_test
import (
"context"
"fmt"
"os"
"strings"
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"

"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/dw/client/operations"
"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/dw/models"
"github.com/cloudera/terraform-provider-cdp/cdpacctest"
"github.com/cloudera/terraform-provider-cdp/utils"
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"
"os"
"strings"
"testing"
)

const (
Expand Down
5 changes: 3 additions & 2 deletions resources/dw/databasecatalog/model_catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ package databasecatalog

import (
"context"
"testing"
"time"

"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/stretchr/testify/suite"
"testing"
"time"
)

type DwDatabaseCatalogModelTestSuite struct {
Expand Down
5 changes: 3 additions & 2 deletions resources/environments/converter_freeipa.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ package environments
import (
"context"

environmentsmodels "github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/environments/models"
"github.com/cloudera/terraform-provider-cdp/utils"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"

environmentsmodels "github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/environments/models"
"github.com/cloudera/terraform-provider-cdp/utils"
)

func FreeIpaResponseToModel(ipaResp *environmentsmodels.FreeipaDetails, model *types.Object, ctx context.Context) *diag.Diagnostics {
Expand Down
1 change: 1 addition & 0 deletions resources/environments/data_source_keytab.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package environments

import (
"context"

"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
Expand Down
5 changes: 3 additions & 2 deletions resources/environments/data_source_keytab_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ package environments
import (
"context"
"errors"
"strings"
"testing"

"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-go/tftypes"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"strings"
"testing"

"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/cdp"
"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/environments/client/operations"
Expand Down
1 change: 0 additions & 1 deletion resources/environments/polling.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"time"

"github.com/hashicorp/terraform-plugin-log/tflog"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"

"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/environments/client"
Expand Down
Loading

0 comments on commit b299e93

Please sign in to comment.