Skip to content

Commit

Permalink
Fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
minamijoyo committed Aug 15, 2023
1 parent ab0e6b7 commit a9940e1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
5 changes: 2 additions & 3 deletions storage/local/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package local

import (
"context"
"io/ioutil"
"os"

"github.com/minamijoyo/tfmigrate/storage"
Expand Down Expand Up @@ -33,7 +32,7 @@ func (s *Storage) Write(ctx context.Context, b []byte) error {
// G306: Expect WriteFile permissions to be 0600 or less
// We ignore it because a history file doesn't contains sensitive data.
// Note that changing a permission to 0600 is breaking change.
return ioutil.WriteFile(s.config.Path, b, 0644)
return os.WriteFile(s.config.Path, b, 0644)
}

// Read reads migration history data from storage.
Expand All @@ -44,5 +43,5 @@ func (s *Storage) Read(ctx context.Context) ([]byte, error) {
// If the key does not exist
return []byte{}, nil
}
return ioutil.ReadFile(s.config.Path)
return os.ReadFile(s.config.Path)
}
9 changes: 4 additions & 5 deletions storage/local/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package local

import (
"context"
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -35,7 +34,7 @@ func TestStorageWrite(t *testing.T) {

for _, tc := range cases {
t.Run(tc.desc, func(t *testing.T) {
localDir, err := ioutil.TempDir("", "localDir")
localDir, err := os.MkdirTemp("", "localDir")
if err != nil {
t.Fatalf("failed to craete temp dir: %s", err)
}
Expand All @@ -55,7 +54,7 @@ func TestStorageWrite(t *testing.T) {
}

if tc.ok {
got, err := ioutil.ReadFile(tc.config.Path)
got, err := os.ReadFile(tc.config.Path)
if err != nil {
t.Fatalf("failed to read contents: %s", err)
}
Expand Down Expand Up @@ -94,13 +93,13 @@ func TestStorageRead(t *testing.T) {

for _, tc := range cases {
t.Run(tc.desc, func(t *testing.T) {
localDir, err := ioutil.TempDir("", "localDir")
localDir, err := os.MkdirTemp("", "localDir")
if err != nil {
t.Fatalf("failed to craete temp dir: %s", err)
}
t.Cleanup(func() { os.RemoveAll(localDir) })

err = ioutil.WriteFile(filepath.Join(localDir, "history.json"), tc.contents, 0600)
err = os.WriteFile(filepath.Join(localDir, "history.json"), tc.contents, 0600)
if err != nil {
t.Fatalf("failed to write contents: %s", err)
}
Expand Down
4 changes: 2 additions & 2 deletions storage/s3/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package s3

import (
"context"
"io/ioutil"
"io"
"strings"
"testing"

Expand Down Expand Up @@ -98,7 +98,7 @@ func TestStorageRead(t *testing.T) {
},
client: &mockClient{
getOutput: &s3.GetObjectOutput{
Body: ioutil.NopCloser(strings.NewReader("foo")),
Body: io.NopCloser(strings.NewReader("foo")),
},
err: nil,
},
Expand Down

0 comments on commit a9940e1

Please sign in to comment.