Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable gci linter with automatic fix. Apply lint fixes. #236

Merged
merged 2 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ install:
go install github.com/pulumi/upgrade-provider

lint:
golangci-lint run
golangci-lint run -E gci --fix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My prior is that make lint shouldn't make code changes. Instead changes should be delegated to another command, such as make lint.fix.

-E -> --enable because I didn't know what -E meant, but --enable is readable.

Suggested change
golangci-lint run -E gci --fix
golangci-lint run --enable gci

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's totally fair - I think a good state is where we can run make lint and see necessary changes.


test:
go test -v ./...
5 changes: 2 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ import (

semver "github.com/Masterminds/semver/v3"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
"github.com/pulumi/upgrade-provider/colorize"
"github.com/pulumi/upgrade-provider/upgrade"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"

"github.com/pulumi/upgrade-provider/colorize"
"github.com/pulumi/upgrade-provider/upgrade"
)

const (
Expand Down
3 changes: 1 addition & 2 deletions upgrade/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import (
"strings"

"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
stepv2 "github.com/pulumi/upgrade-provider/step/v2"
"golang.org/x/mod/modfile"
"golang.org/x/mod/module"

stepv2 "github.com/pulumi/upgrade-provider/step/v2"
)

type RepoKind string
Expand Down
3 changes: 2 additions & 1 deletion upgrade/kind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package upgrade

import (
"context"
"testing"

"github.com/pulumi/upgrade-provider/step/v2"
"github.com/stretchr/testify/assert"
"golang.org/x/mod/modfile"
"golang.org/x/mod/module"
"testing"
)

func TestGetUpstreamProviderOrgFromConfig(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions upgrade/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import (
"os"
"strings"

"golang.org/x/tools/go/ast/astutil"

"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
"golang.org/x/tools/go/ast/astutil"
)

const (
Expand Down
7 changes: 3 additions & 4 deletions upgrade/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ import (

semver "github.com/Masterminds/semver/v3"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
"github.com/pulumi/upgrade-provider/colorize"
"github.com/pulumi/upgrade-provider/step"
stepv2 "github.com/pulumi/upgrade-provider/step/v2"
"golang.org/x/mod/modfile"
"golang.org/x/mod/module"
goSemver "golang.org/x/mod/semver"
"gopkg.in/yaml.v3"

"github.com/pulumi/upgrade-provider/colorize"
"github.com/pulumi/upgrade-provider/step"
stepv2 "github.com/pulumi/upgrade-provider/step/v2"
)

// A "git commit" step that is resilient to no changes in the directory.
Expand Down
3 changes: 1 addition & 2 deletions upgrade/steps_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ import (

"github.com/Masterminds/semver/v3"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
stepv2 "github.com/pulumi/upgrade-provider/step/v2"
"golang.org/x/mod/modfile"
"golang.org/x/mod/module"

stepv2 "github.com/pulumi/upgrade-provider/step/v2"
)

func modPathWithoutVersion(path string) string {
Expand Down
8 changes: 4 additions & 4 deletions upgrade/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ type Context struct {
//
UpstreamProviderName string
// The org component in the upstream provider's repo path.
//
// This must be provided when upstream is hosted at a repo that does
// not match the Go Module path it is declared as. Otherwise it can
//
// This must be provided when upstream is hosted at a repo that does
// not match the Go Module path it is declared as. Otherwise it can
// be inferred.
//
// For example, if we have an upstream provider with import path:
Expand All @@ -62,7 +62,7 @@ type Context struct {
// github.com/my-org/terraform-provider-my-provider
//
// Then UpstreamProviderOrg should be `my-org`.
UpstreamProviderOrg string
UpstreamProviderOrg string

// The desired version of pulumi/{pkg,sdk} to link to.
//
Expand Down
Loading