Skip to content

Commit

Permalink
Enforce import order with a lint (#2145)
Browse files Browse the repository at this point in the history
This PR enforces import order via a linter, just like our other
providers. The second commit is the result of running `make fix_lint`,
and does not have manual edits.
  • Loading branch information
iwahbe authored Jun 28, 2024
1 parent 8c7a579 commit 18db7c5
Show file tree
Hide file tree
Showing 165 changed files with 273 additions and 298 deletions.
12 changes: 11 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ linters:
enable:
- errcheck
- gofmt
- gci
- gosec
- govet
- ineffassign
- lll
- megacheck
- gosimple
- staticcheck
- unused
- misspell
- nakedret
- nolintlint
Expand All @@ -25,3 +28,10 @@ issues:
- pkg/tf2pulumi/internal/addrs
- pkg/tf2pulumi/internal/config
- pkg/tf2pulumi/internal/configs
linters-settings:
gci:
sections:
- standard
- default
- prefix(github.com/pulumi/pulumi-terraform-bridge)
skip-generated: true
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ build::
fmt::
@gofmt -w -s .

lint::
lint:
go run scripts/build.go lint

lint_fix:
go run scripts/build.go fix-lint

test::
@mkdir -p bin
go build -o bin ./internal/testing/pulumi-terraform-bridge-test-provider
Expand Down
2 changes: 1 addition & 1 deletion dynamic/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import (
"strings"

"github.com/opentofu/opentofu/shim/run"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin"

"github.com/pulumi/pulumi-terraform-bridge/pf/proto"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/tokens"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin"
)

func providerInfo(ctx context.Context, p run.Provider) tfbridge.ProviderInfo {
Expand Down
4 changes: 2 additions & 2 deletions dynamic/internal/shim/run/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ import (
v5shim "github.com/opentofu/opentofu/shim/protov5"
v6shim "github.com/opentofu/opentofu/shim/protov6"
tfaddr "github.com/opentofu/registry-address"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
"github.com/pulumi/pulumi/sdk/v3/go/common/workspace"

"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
)

// envPluginCache allows users to override where we cache TF providers used by
Expand Down
1 change: 0 additions & 1 deletion dynamic/internal/shim/run/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (

"github.com/hashicorp/terraform-plugin-go/tfprotov6"
"github.com/hashicorp/terraform-plugin-go/tftypes"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down
3 changes: 1 addition & 2 deletions dynamic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ import (
"github.com/pulumi/pulumi/sdk/v3/go/common/diag/colors"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin"

"github.com/pulumi/pulumi-terraform-bridge/dynamic/version"
"github.com/pulumi/pulumi-terraform-bridge/pf/proto"
pfbridge "github.com/pulumi/pulumi-terraform-bridge/pf/tfbridge"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen"

"github.com/pulumi/pulumi-terraform-bridge/dynamic/version"
)

func initialSetup() (tfbridge.ProviderInfo, pfbridge.ProviderMetadata, func() error) {
Expand Down
8 changes: 4 additions & 4 deletions dynamic/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ import (
"testing"

"github.com/hexops/autogold/v2"
helper "github.com/pulumi/pulumi-terraform-bridge/dynamic/internal/testing"
pfbridge "github.com/pulumi/pulumi-terraform-bridge/pf/tfbridge"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/structpb"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
helper "github.com/pulumi/pulumi-terraform-bridge/dynamic/internal/testing"
pfbridge "github.com/pulumi/pulumi-terraform-bridge/pf/tfbridge"
)

// globalTempDir is a temporary directory scoped to the entire test cycle.
Expand Down
3 changes: 2 additions & 1 deletion internal/testprovider_invalid_schema/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
package tpinvschema

import (
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"

"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
sdkv2 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
)

func ProviderInfo() tfbridge.ProviderInfo {
Expand Down
3 changes: 2 additions & 1 deletion internal/testprovider_sdkv2/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
package tpsdkv2

import (
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"

"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
sdkv2 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
)

func ProviderInfo() tfbridge.ProviderInfo {
Expand Down
7 changes: 3 additions & 4 deletions pf/internal/check/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
sdkschema "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/stretchr/testify/assert"

"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
sdkv2 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2"
"github.com/pulumi/pulumi/sdk/v3/go/common/diag"
"github.com/pulumi/pulumi/sdk/v3/go/common/diag/colors"
property "github.com/pulumi/pulumi/sdk/v3/go/common/resource"
"github.com/stretchr/testify/assert"

pfbridge "github.com/pulumi/pulumi-terraform-bridge/pf/tfbridge"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
sdkv2 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2"
)

func TestMissingIDProperty(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions pf/internal/check/not_supported_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ import (
"bytes"
"testing"

"github.com/pulumi/pulumi/sdk/v3/go/common/diag"
"github.com/pulumi/pulumi/sdk/v3/go/common/diag/colors"
"github.com/stretchr/testify/require"

"github.com/pulumi/pulumi/sdk/v3/go/common/diag"
)

func TestZeroRecognizer(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion pf/internal/defaults/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"strconv"

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

"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"

Expand Down
3 changes: 1 addition & 2 deletions pf/internal/defaults/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ import (
"context"
"testing"

"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/pulumi/pulumi/sdk/v3/go/common/resource"

"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/schema"
Expand Down
8 changes: 4 additions & 4 deletions pf/internal/muxer/muxer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
package muxer

import (
"context"
"fmt"
"strings"

"context"

"github.com/hashicorp/go-multierror"
"github.com/hashicorp/terraform-plugin-framework/provider"
"github.com/pulumi/pulumi/sdk/v3/go/common/tokens"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"

"github.com/pulumi/pulumi-terraform-bridge/pf"
"github.com/pulumi/pulumi-terraform-bridge/pf/internal/schemashim"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
"github.com/pulumi/pulumi-terraform-bridge/x/muxer"
"github.com/pulumi/pulumi/sdk/v3/go/common/tokens"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
)

func SchemaOnlyPluginFrameworkProvider(ctx context.Context, provider provider.Provider) shim.Provider {
Expand Down
3 changes: 2 additions & 1 deletion pf/internal/muxer/union.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ import (
"fmt"
"sort"

shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"

shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
)

type unionMap[T any] struct {
Expand Down
1 change: 0 additions & 1 deletion pf/internal/pfutils/attr.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
dschema "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
pschema "github.com/hashicorp/terraform-plugin-framework/provider/schema"
rschema "github.com/hashicorp/terraform-plugin-framework/resource/schema"

"github.com/hashicorp/terraform-plugin-go/tftypes"
)

Expand Down
3 changes: 1 addition & 2 deletions pf/internal/pfutils/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ import (
"strconv"

"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"

dschema "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
pschema "github.com/hashicorp/terraform-plugin-framework/provider/schema"
rschema "github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
)

// Block type works around not being able to link to fwschema.Block from
Expand Down
1 change: 1 addition & 0 deletions pf/internal/pfutils/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/provider"

"github.com/pulumi/pulumi-terraform-bridge/pf/internal/runtypes"
)

Expand Down
1 change: 1 addition & 0 deletions pf/internal/pfutils/datasources.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/provider"

"github.com/pulumi/pulumi-terraform-bridge/pf/internal/runtypes"
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
)
Expand Down
4 changes: 2 additions & 2 deletions pf/internal/pfutils/proposed_new.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
"context"
"fmt"

"github.com/pulumi/pulumi-terraform-bridge/pf/internal/runtypes"
"github.com/hashicorp/terraform-plugin-go/tftypes"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"

"github.com/hashicorp/terraform-plugin-go/tftypes"
"github.com/pulumi/pulumi-terraform-bridge/pf/internal/runtypes"
)

// Computes the ProposedNewState from priorState and config.
Expand Down
9 changes: 4 additions & 5 deletions pf/internal/pfutils/proposed_new_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ import (
"context"
"testing"

"github.com/pulumi/pulumi-terraform-bridge/pf/internal/runtypes"
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
"github.com/stretchr/testify/require"

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

"github.com/hashicorp/terraform-plugin-go/tftypes"
"github.com/stretchr/testify/require"

"github.com/pulumi/pulumi-terraform-bridge/pf/internal/runtypes"
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
)

type testcase struct {
Expand Down
1 change: 1 addition & 0 deletions pf/internal/pfutils/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

"github.com/hashicorp/terraform-plugin-framework/provider"
"github.com/hashicorp/terraform-plugin-framework/resource"

"github.com/pulumi/pulumi-terraform-bridge/pf/internal/runtypes"
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
)
Expand Down
3 changes: 1 addition & 2 deletions pf/internal/plugin/provider_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ import (
"context"
"io"

"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin"
p "github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin"

"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
"github.com/pulumi/pulumi/sdk/v3/go/common/tokens"
"github.com/pulumi/pulumi/sdk/v3/go/common/workspace"
)
Expand Down
5 changes: 2 additions & 3 deletions pf/internal/plugin/provider_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ import (

"github.com/blang/semver"
pbempty "github.com/golang/protobuf/ptypes/empty"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/config"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin"
pl "github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin"
"github.com/pulumi/pulumi/sdk/v3/go/common/tokens"
pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
)
Expand Down
3 changes: 1 addition & 2 deletions pf/internal/schemashim/attr_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
package schemashim

import (
bridge "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"

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

"github.com/pulumi/pulumi-terraform-bridge/pf/internal/pfutils"
bridge "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
)

Expand Down
3 changes: 1 addition & 2 deletions pf/internal/schemashim/block_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ package schemashim
import (
"fmt"

bridge "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"

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

"github.com/pulumi/pulumi-terraform-bridge/pf/internal/pfutils"
bridge "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
)

Expand Down
4 changes: 2 additions & 2 deletions pf/internal/schemashim/object_pseudoresource.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import (
"strconv"

"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
"github.com/hashicorp/terraform-plugin-go/tftypes"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"

"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
"github.com/pulumi/pulumi-terraform-bridge/pf/internal/pfutils"
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
)

// An Object type that masquerades as a Resource. This is a workaround to reusing tfgen code for generating schemas,
Expand Down
4 changes: 2 additions & 2 deletions pf/internal/schemashim/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ import (
"context"
"fmt"

shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"

pfprovider "github.com/hashicorp/terraform-plugin-framework/provider"
"github.com/hashicorp/terraform-plugin-framework/providerserver"
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
"github.com/hashicorp/terraform-plugin-go/tftypes"

"github.com/pulumi/pulumi-terraform-bridge/pf"
"github.com/pulumi/pulumi-terraform-bridge/pf/internal/pfutils"
"github.com/pulumi/pulumi-terraform-bridge/pf/internal/runtypes"
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
)

var _ = pf.ShimProvider(&SchemaOnlyProvider{})
Expand Down
Loading

0 comments on commit 18db7c5

Please sign in to comment.