Skip to content

Commit

Permalink
Merge pull request #15943 from hashicorp/t-cleanup-imports2
Browse files Browse the repository at this point in the history
linter: Clean up imports and add import linter
  • Loading branch information
YakDriver authored Nov 4, 2020
2 parents 78b3139 + 8cec1d5 commit 81da040
Show file tree
Hide file tree
Showing 169 changed files with 186 additions and 331 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/terraform_provider.yml
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,32 @@ jobs:
- run: golangci-lint run ./aws/...
- run: cd awsproviderlint && golangci-lint run ./...

importlint:
needs: [go_build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: go env
run: |
echo "::set-env name=GOCACHE::$(go env GOCACHE)"
- uses: actions/cache@v2
continue-on-error: true
timeout-minutes: 2
with:
path: ${{ env.GOCACHE }}
key: ${{ runner.os }}-GOCACHE-${{ hashFiles('go.sum') }}-${{ hashFiles('aws/**') }}
- uses: actions/cache@v2
continue-on-error: true
timeout-minutes: 2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-pkg-mod-${{ hashFiles('go.sum') }}
- run: cd tools && go install github.com/pavius/impi/cmd/impi
- run: impi --local . --scheme stdThirdPartyLocal ./...

goreleaser:
needs: [go_mod_download]
runs-on: ubuntu-latest
Expand Down
6 changes: 5 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ docscheck:
-require-resource-subcategory
@misspell -error -source text CHANGELOG.md

lint: golangci-lint awsproviderlint
lint: golangci-lint awsproviderlint importlint

golangci-lint:
@golangci-lint run ./$(PKG_NAME)/...
Expand Down Expand Up @@ -161,13 +161,17 @@ awsproviderlint:
-V008 \
./$(PKG_NAME)

importlint:
@impi --local . --scheme stdThirdPartyLocal ./$(PKG_NAME)/...

tools:
cd awsproviderlint && GO111MODULE=on go install .
cd tools && GO111MODULE=on go install github.com/bflad/tfproviderdocs
cd tools && GO111MODULE=on go install github.com/client9/misspell/cmd/misspell
cd tools && GO111MODULE=on go install github.com/golangci/golangci-lint/cmd/golangci-lint
cd tools && GO111MODULE=on go install github.com/katbyte/terrafmt
cd tools && GO111MODULE=on go install github.com/terraform-linters/tflint
cd tools && GO111MODULE=on go install github.com/pavius/impi/cmd/impi

test-compile:
@if [ "$(TEST)" = "./..." ]; then \
Expand Down
5 changes: 2 additions & 3 deletions aws/data_source_aws_directory_service_directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import (
"fmt"
"log"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/directoryservice"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags"
)

func dataSourceAwsDirectoryServiceDirectory() *schema.Resource {
Expand Down
1 change: 0 additions & 1 deletion aws/data_source_aws_ebs_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags"
)

Expand Down
3 changes: 1 addition & 2 deletions aws/data_source_aws_iam_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import (
"net/url"
"time"

"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/iam"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags"
)

func dataSourceAwsIAMRole() *schema.Resource {
Expand Down
1 change: 0 additions & 1 deletion aws/data_source_aws_kms_secrets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/kms"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)
Expand Down
3 changes: 1 addition & 2 deletions aws/data_source_aws_pricing_product.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package aws

import (
"log"

"encoding/json"
"fmt"
"log"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/pricing"
Expand Down
8 changes: 3 additions & 5 deletions aws/data_source_aws_qldb_ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ package aws

import (
"fmt"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/qldb"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"

"log"
"regexp"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/qldb"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)

func dataSourceAwsQLDBLedger() *schema.Resource {
Expand Down
1 change: 0 additions & 1 deletion aws/data_source_aws_qldb_ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"testing"

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

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

Expand Down
3 changes: 1 addition & 2 deletions aws/data_source_aws_security_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ package aws

import (
"fmt"
"testing"

"strings"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
Expand Down
1 change: 0 additions & 1 deletion aws/data_source_aws_wafregional_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/waf"

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

Expand Down
1 change: 0 additions & 1 deletion aws/data_source_aws_workspaces_directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/aws/aws-sdk-go/service/workspaces"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/service/workspaces/waiter"
)
Expand Down
1 change: 0 additions & 1 deletion aws/ec2_filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags"
tfec2 "github.com/terraform-providers/terraform-provider-aws/aws/internal/service/ec2"
Expand Down
1 change: 0 additions & 1 deletion aws/ec2_filters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"

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

Expand Down
2 changes: 1 addition & 1 deletion aws/internal/keyvaluetags/service_tags_gen_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package keyvaluetags

import (
"github.com/aws/aws-sdk-go/service/quicksight"
"testing"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/appmesh"
"github.com/aws/aws-sdk-go/service/athena"
"github.com/aws/aws-sdk-go/service/datasync"
"github.com/aws/aws-sdk-go/service/kms"
"github.com/aws/aws-sdk-go/service/quicksight"
)

// map[string]*string handling
Expand Down
2 changes: 1 addition & 1 deletion aws/internal/service/glue/waiter/waiter.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package waiter

import (
"github.com/aws/aws-sdk-go/service/glue"
"time"

"github.com/aws/aws-sdk-go/service/glue"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

Expand Down
1 change: 0 additions & 1 deletion aws/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"log"

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

"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/mutexkv"
)
Expand Down
5 changes: 2 additions & 3 deletions aws/resource_aws_acm_certificate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ package aws
import (
"fmt"
"log"
"os"
"regexp"
"strconv"
"strings"
"testing"

"os"
"regexp"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/acm"
"github.com/hashicorp/go-multierror"
Expand Down
1 change: 0 additions & 1 deletion aws/resource_aws_ami.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/arn"
"github.com/aws/aws-sdk-go/service/ec2"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
Expand Down
1 change: 0 additions & 1 deletion aws/resource_aws_app_cookie_stickiness_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/elb"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
Expand Down
3 changes: 1 addition & 2 deletions aws/resource_aws_appautoscaling_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import (
"fmt"
"log"
"strconv"
"time"

"strings"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/applicationautoscaling"
Expand Down
1 change: 0 additions & 1 deletion aws/resource_aws_appsync_function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/appsync"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
Expand Down
3 changes: 1 addition & 2 deletions aws/resource_aws_athena_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import (
"strings"
"time"

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

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/athena"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)

func resourceAwsAthenaDatabase() *schema.Resource {
Expand Down
1 change: 0 additions & 1 deletion aws/resource_aws_athena_workgroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/athena"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
Expand Down
3 changes: 1 addition & 2 deletions aws/resource_aws_batch_job_definition.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package aws

import (
"fmt"

"encoding/json"
"fmt"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/private/protocol/json/jsonutil"
Expand Down
3 changes: 1 addition & 2 deletions aws/resource_aws_cloudhsm2_hsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import (
"log"
"time"

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

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/cloudhsmv2"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func resourceAwsCloudHsmV2Hsm() *schema.Resource {
Expand Down
3 changes: 1 addition & 2 deletions aws/resource_aws_cloudtrail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package aws
import (
"fmt"
"log"
"testing"

"regexp"
"testing"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/cloudtrail"
Expand Down
1 change: 0 additions & 1 deletion aws/resource_aws_cloudwatch_event_permission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/aws/aws-sdk-go/aws"
events "github.com/aws/aws-sdk-go/service/cloudwatchevents"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
Expand Down
5 changes: 2 additions & 3 deletions aws/resource_aws_cloudwatch_event_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import (
"regexp"
"strings"

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

"github.com/aws/aws-sdk-go/aws"
events "github.com/aws/aws-sdk-go/service/cloudwatchevents"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/service/cloudwatchevents/lister"
)
Expand Down
5 changes: 2 additions & 3 deletions aws/resource_aws_cloudwatch_log_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import (
"log"
"strings"

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

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/cloudwatchlogs"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags"
)

Expand Down
7 changes: 3 additions & 4 deletions aws/resource_aws_cloudwatch_log_metric_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import (
"log"
"strings"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/cloudwatchlogs"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)

func resourceAwsCloudWatchLogMetricFilter() *schema.Resource {
Expand Down
1 change: 0 additions & 1 deletion aws/resource_aws_cloudwatch_log_resource_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/cloudwatchlogs"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
Expand Down
1 change: 0 additions & 1 deletion aws/resource_aws_codebuild_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"

"github.com/terraform-providers/terraform-provider-aws/aws/internal/tfawsresource"
)

Expand Down
Loading

0 comments on commit 81da040

Please sign in to comment.