Skip to content

Commit

Permalink
- fix lints for new version
Browse files Browse the repository at this point in the history
  • Loading branch information
Hakan committed Dec 26, 2021
1 parent 3b3e8f0 commit 7dcc05a
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 22 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ linters:
disable:
- exhaustivestruct
- wrapcheck
- ireturn
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/gax-go/v2 v2.1.1 // indirect
github.com/googleapis/google-cloud-go-testing v0.0.0-20210719221736-1c9a4c676720 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,9 @@ github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLe
github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0=
Expand Down
4 changes: 2 additions & 2 deletions internal/io/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func WriteSSHKey(fileName string, data []byte) error {

if _, err = os.Stat(sshDirectory); os.IsNotExist(err) {
//nolint:gomnd // change this later.
err = os.Mkdir(sshDirectory, os.FileMode(0777))
err = os.Mkdir(sshDirectory, os.FileMode(0o777))
if err != nil {
return err
}
Expand All @@ -36,7 +36,7 @@ func WriteSSHKey(fileName string, data []byte) error {
sshPath := filepath.Join(sshDirectory, fileName)

//nolint:gomnd // change this later.
err = ioutil.WriteFile(sshPath, data, os.FileMode(0600))
err = ioutil.WriteFile(sshPath, data, os.FileMode(0o600))
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/bw.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (b Bitwarden) GetName() string {
func (b Bitwarden) Add(item *Item) error {
_, err := b.Get(item.Name)
if err == nil {
return ItemAlreadyExists{Name: item.Name}
return ItemAlreadyExistsError{Name: item.Name}
}

encodedValues, err := item.EncodeValues()
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/bw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestBitwarden_Add(t *testing.T) {
},
}

bw := provider.Bitwarden{
bitw := provider.Bitwarden{
Commander: internal.Commander{Executor: test.NewExecutor(expectedCommands)},
}

Expand All @@ -44,7 +44,7 @@ func TestBitwarden_Add(t *testing.T) {
},
}

err := bw.Add(&item)
err := bitw.Add(&item)

assert.NoError(t, err)
}
Expand Down
12 changes: 6 additions & 6 deletions internal/provider/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package provider

import "fmt"

// NotFound occurs when no provider found.
type NotFound struct {
// NotFoundError occurs when no provider found.
type NotFoundError struct {
Name *string
}

func (e NotFound) Error() string {
func (e NotFoundError) Error() string {
return fmt.Sprintf("no provider found for %s", *e.Name)
}

Expand All @@ -21,11 +21,11 @@ func (e ExecutionFailedError) Error() string {
return fmt.Sprintf("'%s': Execution failed: %s", e.Command, e.Message)
}

// ItemAlreadyExists occurs when given item is not found in the provder.
type ItemAlreadyExists struct {
// ItemAlreadyExistsError occurs when given item is not found in the provder.
type ItemAlreadyExistsError struct {
Name string
}

func (e ItemAlreadyExists) Error() string {
func (e ItemAlreadyExistsError) Error() string {
return fmt.Sprintf("item %s already exists", e.Name)
}
2 changes: 1 addition & 1 deletion internal/provider/op.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (o OnePassword) GetName() string {
func (o OnePassword) Add(item *Item) error {
_, err := o.Get(item.Name)
if err == nil {
return ItemAlreadyExists{Name: item.Name}
return ItemAlreadyExistsError{Name: item.Name}
}

encodedValues, err := item.EncodeValues()
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/op_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestOnePassword_Add(t *testing.T) {
},
}

op := provider.OnePassword{
onep := provider.OnePassword{
Commander: internal.Commander{Executor: test.NewExecutor(expectedCommands)},
}

Expand All @@ -52,7 +52,7 @@ func TestOnePassword_Add(t *testing.T) {
},
}

err := op.Add(&item)
err := onep.Add(&item)

assert.NoError(t, err)
}
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func main() {
SilenceUsage: true,
}

c := commander.NewCommander(root).
comm := commander.NewCommander(root).
SetCommand(
cmd.Version(),
cmd.Get(),
Expand All @@ -26,7 +26,7 @@ func main() {
).
Init()

if err := c.Execute(); err != nil {
if err := comm.Execute(); err != nil {
os.Exit(1)
}
}
6 changes: 3 additions & 3 deletions test/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package test

import "fmt"

// FixtureFileNotFound occurs when the requested fixture file does not exist.
type FixtureFileNotFound struct {
// FixtureFileNotFoundError occurs when the requested fixture file does not exist.
type FixtureFileNotFoundError struct {
Path string
Name string
}

func (e FixtureFileNotFound) Error() string {
func (e FixtureFileNotFoundError) Error() string {
return fmt.Sprintf("Fixture file does not exist: %s/fixtures/%s", e.Path, e.Name)
}
2 changes: 1 addition & 1 deletion test/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func LoadFixture(name string) ([]byte, error) {
if err != nil {
path, _ := os.Getwd()

return []byte{}, FixtureFileNotFound{Path: path, Name: name}
return []byte{}, FixtureFileNotFoundError{Path: path, Name: name}
}

return content, nil
Expand Down
2 changes: 1 addition & 1 deletion test/fixture_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ func TestMust_hasError(t *testing.T) {
}
}()

_ = Must([]byte{}, FixtureFileNotFound{Path: "/path", Name: "file"})
_ = Must([]byte{}, FixtureFileNotFoundError{Path: "/path", Name: "file"})
}

0 comments on commit 7dcc05a

Please sign in to comment.