Skip to content

Commit

Permalink
update(ioutil) Remove deprecated lib 'ioutil'
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoEb committed Jun 17, 2021
1 parent f6cccdf commit 4aeacc6
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* fix(backup-download) Now download the last successful backup [#663](https://github.com/Scalingo/cli/pull/663)
* fix(review-app-url) add app url in the tablewriter [#664](https://github.com/Scalingo/cli/pull/664)
* fix(backups-download) print error on stderr if the backup status is not 'done' [#665](https://github.com/Scalingo/cli/pull/665)
* update go version to 1.6 and replace ioutil by io/os [#666](https://github.com/Scalingo/cli/pull/666)

### 1.20.2

Expand Down
4 changes: 2 additions & 2 deletions apps/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package apps

import (
"encoding/json"
"io/ioutil"
"io"
"strings"
"time"

Expand Down Expand Up @@ -45,7 +45,7 @@ func Logs(appName string, stream bool, n int, filter string) error {
return errgo.Newf("fail to query logs: %s", res.Status)
}

body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
return errgo.Mask(err, errgo.Any)
}
Expand Down
7 changes: 3 additions & 4 deletions apps/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"encoding/json"
"fmt"
stdio "io"
"io/ioutil"
"mime/multipart"
"net"
"net/http"
Expand Down Expand Up @@ -273,7 +272,7 @@ func (ctx *runContext) exitCode() (int, error) {
}
defer res.Body.Close()

body, err := ioutil.ReadAll(res.Body)
body, err := stdio.ReadAll(res.Body)
if err != nil {
return -1, errgo.Notef(err, "fail to read body when getting exit code")
}
Expand Down Expand Up @@ -394,7 +393,7 @@ func (ctx *runContext) uploadFiles(endpoint string, files []string) error {
}

func (ctx *runContext) compressDir(dir string) (string, error) {
tmpDir, err := ioutil.TempDir(os.TempDir(), "job-file")
tmpDir, err := os.MkdirTemp(os.TempDir(), "job-file")
if err != nil {
return "", errgo.Mask(err, errgo.Any)
}
Expand Down Expand Up @@ -523,7 +522,7 @@ func (ctx *runContext) uploadFile(endpoint string, file string) error {
}
defer res.Body.Close()
if res.StatusCode != 200 {
b, _ := ioutil.ReadAll(res.Body)
b, _ := stdio.ReadAll(res.Body)
return errgo.Newf("Invalid return code %v (%s)", res.Status, strings.TrimSpace(string(b)))
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/autocomplete/current_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package autocomplete
import (
"os"

"github.com/urfave/cli"
"github.com/Scalingo/cli/appdetect"
"github.com/urfave/cli"
)

func CurrentAppCompletion(c *cli.Context) string {
Expand Down
3 changes: 1 addition & 2 deletions config/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/url"
"os"
"strings"
Expand Down Expand Up @@ -300,7 +299,7 @@ func writeAuthFile(authConfig *auth.ConfigData) error {

func existingAuth() (*auth.ConfigData, error) {
authConfig := auth.NewConfigData()
content, err := ioutil.ReadFile(C.AuthFile)
content, err := os.ReadFile(C.AuthFile)
if err == nil {
// We don't care of the error
json.Unmarshal(content, &authConfig)
Expand Down
4 changes: 2 additions & 2 deletions crypto/sshkeys/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/asn1"
"encoding/pem"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"

Expand All @@ -19,7 +19,7 @@ var (
)

func ReadPrivateKey(path string) (ssh.Signer, error) {
privateKeyContent, err := ioutil.ReadFile(path)
privateKeyContent, err := os.ReadFile(path)
if err != nil {
return nil, errgo.Mask(err)
}
Expand Down
7 changes: 3 additions & 4 deletions db/backup_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
httpclient "github.com/Scalingo/go-scalingo/v4/http"
"io"
"io/ioutil"
"net/http"
"os"
"time"
Expand Down Expand Up @@ -37,7 +36,7 @@ func DownloadBackup(app, addon, backupID string, opts DownloadBackupOpts) error
}

if opts.Silent {
logWriter = ioutil.Discard
logWriter = io.Discard
}

client, err := config.ScalingoClient()
Expand Down Expand Up @@ -109,8 +108,8 @@ func DownloadBackup(app, addon, backupID string, opts DownloadBackupOpts) error

if resp.StatusCode != http.StatusOK {
return httpclient.NewRequestFailedError(resp, &httpclient.APIRequest{
URL: downloadURL,
Method: "GET",
URL: downloadURL,
Method: "GET",
})
}

Expand Down
3 changes: 1 addition & 2 deletions deployments/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package deployments

import (
"io"
"io/ioutil"
"net/http"
"os"
"strings"
Expand Down Expand Up @@ -90,7 +89,7 @@ func uploadArchivePath(c *scalingo.Client, archivePath string) (string, error) {
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
body, _ := ioutil.ReadAll(res.Body)
body, _ := io.ReadAll(res.Body)
return "", errgo.Newf("wrong status code after upload %s, body: %s", res.Status, string(body))
}

Expand Down
6 changes: 3 additions & 3 deletions domains/ssl.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package domains

import (
"io/ioutil"
"os"

"github.com/Scalingo/cli/config"
"github.com/Scalingo/cli/io"
Expand Down Expand Up @@ -65,11 +65,11 @@ func validateSSL(cert, key string) (string, string, error) {
return "", "", errgo.New("--key <key path> should be defined")
}

certContent, err := ioutil.ReadFile(cert)
certContent, err := os.ReadFile(cert)
if err != nil {
return "", "", errgo.Mask(err)
}
keyContent, err := ioutil.ReadFile(key)
keyContent, err := os.ReadFile(key)
if err != nil {
return "", "", errgo.Mask(err)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/Scalingo/cli

go 1.15
go 1.16

require (
github.com/ScaleFT/sshkeys v0.0.0-20200327173127-6142f742bca5
Expand Down
3 changes: 1 addition & 2 deletions keys/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package keys

import (
"fmt"
"io/ioutil"
"os"

"github.com/Scalingo/cli/config"
Expand All @@ -21,7 +20,7 @@ func Add(name string, path string) error {
return fmt.Errorf("%s: is too large (%v bytes)", path, stat.Size())
}

keyContent, err := ioutil.ReadFile(path)
keyContent, err := os.ReadFile(path)
if err != nil {
return errgo.Notef(err, "fail to read the key file")
}
Expand Down
4 changes: 2 additions & 2 deletions update/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package update

import (
"fmt"
"io/ioutil"
stdio "io"
"net/http"
"strings"
"time"
Expand Down Expand Up @@ -72,7 +72,7 @@ func getLastVersion() (string, error) {
return "", errgo.Mask(err)
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
body, err := stdio.ReadAll(res.Body)
if err != nil {
return "", errgo.Mask(err)
}
Expand Down

0 comments on commit 4aeacc6

Please sign in to comment.