Skip to content

Commit 59ea72e

Browse files
committed
refactor: remove deprecated usages of ioutil (dep 1.16) for replacements
1 parent 0ba3653 commit 59ea72e

File tree

5 files changed

+8
-10
lines changed

5 files changed

+8
-10
lines changed

internal/app/gitops-commit/slackhttp/manifest.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package slackhttp
33
import (
44
"fmt"
55
"gopkg.in/yaml.v3"
6-
"io/ioutil"
6+
"os"
77
)
88

99
type Manifest struct {
@@ -29,7 +29,7 @@ func LoadManifest(f string) (*Manifest, error) {
2929
registry: NewNamedRepositoryRegistry(),
3030
}
3131

32-
d, err := ioutil.ReadFile(f)
32+
d, err := os.ReadFile(f)
3333

3434
if err != nil {
3535
return nil, fmt.Errorf("cannot read yaml file: %w", err)

internal/app/gitops-commit/slackhttp/middleware.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"github.com/google/martian/log"
55
"github.com/slack-go/slack"
66
"io"
7-
"io/ioutil"
87
"net/http"
98
)
109

@@ -17,7 +16,7 @@ func (s *server) SlackCommandMiddleware(next func(w http.ResponseWriter, s slack
1716
return
1817
}
1918

20-
r.Body = ioutil.NopCloser(io.TeeReader(r.Body, &verifier))
19+
r.Body = io.NopCloser(io.TeeReader(r.Body, &verifier))
2120
s, err := slack.SlashCommandParse(r)
2221
if err != nil {
2322
w.WriteHeader(http.StatusInternalServerError)

internal/pkg/gitops/git.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"github.com/go-git/go-git/v5"
66
"github.com/go-git/go-git/v5/plumbing/object"
77
"github.com/go-git/go-git/v5/plumbing/transport/ssh"
8-
"io/ioutil"
98
"os"
109
"time"
1110
)
@@ -19,7 +18,7 @@ type GitOptions struct {
1918
}
2019

2120
func NewGitOptions(keys *ssh.PublicKeys) (*GitOptions, func(), error) {
22-
dir, err := ioutil.TempDir("/tmp", "prefix")
21+
dir, err := os.MkdirTemp("/tmp", "prefix")
2322
if err != nil {
2423
return nil, nil, err
2524
}

internal/pkg/gitops/handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package gitops
22

33
import (
44
"fmt"
5-
"io/ioutil"
5+
"os"
66
)
77

88
type DeployVersionCommand struct {
@@ -23,7 +23,7 @@ func DeployVersionHandler(c DeployVersionCommand) error {
2323

2424
filename := fmt.Sprintf("%s/%s", c.GitOptions.WorkingDirectory, c.File)
2525

26-
f, err := ioutil.ReadFile(filename)
26+
f, err := os.ReadFile(filename)
2727

2828
if err != nil {
2929
return fmt.Errorf("cannot read file: %w", err)

internal/pkg/gitops/version.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"errors"
66
"fmt"
77
"gopkg.in/yaml.v3"
8-
"io/ioutil"
8+
"os"
99
"regexp"
1010
"strconv"
1111
"strings"
@@ -32,7 +32,7 @@ func ReadCurrentVersion(f []byte, notation string) (string, error) {
3232

3333
func WriteVersion(f []byte, version string, newVersion string, filename string) error {
3434
output := bytes.Replace(f, []byte(version), []byte(newVersion), -1)
35-
err := ioutil.WriteFile(filename, output, 0666)
35+
err := os.WriteFile(filename, output, 0666)
3636

3737
if err != nil {
3838
return fmt.Errorf("cannot replace version: %w", err)

0 commit comments

Comments
 (0)