diff --git a/CHANGELOG.md b/CHANGELOG.md index e072fa1c3..d009f13aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/apps/logs.go b/apps/logs.go index e72364736..4e337d5eb 100644 --- a/apps/logs.go +++ b/apps/logs.go @@ -2,7 +2,7 @@ package apps import ( "encoding/json" - "io/ioutil" + "io" "strings" "time" @@ -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) } diff --git a/apps/run.go b/apps/run.go index c5a48afc0..22c8c8f1e 100644 --- a/apps/run.go +++ b/apps/run.go @@ -8,7 +8,6 @@ import ( "encoding/json" "fmt" stdio "io" - "io/ioutil" "mime/multipart" "net" "net/http" @@ -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") } @@ -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) } @@ -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 diff --git a/cmd/autocomplete/current_app.go b/cmd/autocomplete/current_app.go index 7cee935d8..bb22b7c01 100644 --- a/cmd/autocomplete/current_app.go +++ b/cmd/autocomplete/current_app.go @@ -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 { diff --git a/config/auth.go b/config/auth.go index 2a99be851..4ee9e7682 100644 --- a/config/auth.go +++ b/config/auth.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/url" "os" "strings" @@ -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) diff --git a/crypto/sshkeys/read.go b/crypto/sshkeys/read.go index fe79f9477..82ad82576 100644 --- a/crypto/sshkeys/read.go +++ b/crypto/sshkeys/read.go @@ -4,7 +4,7 @@ import ( "encoding/asn1" "encoding/pem" "fmt" - "io/ioutil" + "os" "path/filepath" "strings" @@ -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) } diff --git a/db/backup_download.go b/db/backup_download.go index e4a3d30f5..c2263c874 100644 --- a/db/backup_download.go +++ b/db/backup_download.go @@ -4,7 +4,6 @@ import ( "fmt" httpclient "github.com/Scalingo/go-scalingo/v4/http" "io" - "io/ioutil" "net/http" "os" "time" @@ -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() @@ -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", }) } diff --git a/deployments/deploy.go b/deployments/deploy.go index b4f3fb3ef..7850a8395 100644 --- a/deployments/deploy.go +++ b/deployments/deploy.go @@ -2,7 +2,6 @@ package deployments import ( "io" - "io/ioutil" "net/http" "os" "strings" @@ -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)) } diff --git a/domains/ssl.go b/domains/ssl.go index dbbfe2559..2af14df0b 100644 --- a/domains/ssl.go +++ b/domains/ssl.go @@ -1,7 +1,7 @@ package domains import ( - "io/ioutil" + "os" "github.com/Scalingo/cli/config" "github.com/Scalingo/cli/io" @@ -65,11 +65,11 @@ func validateSSL(cert, key string) (string, string, error) { return "", "", errgo.New("--key 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) } diff --git a/go.mod b/go.mod index 6e4ef7531..503c3ad92 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/keys/add.go b/keys/add.go index 7241b9c67..eca96f15f 100644 --- a/keys/add.go +++ b/keys/add.go @@ -2,7 +2,6 @@ package keys import ( "fmt" - "io/ioutil" "os" "github.com/Scalingo/cli/config" @@ -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") } diff --git a/update/check.go b/update/check.go index ecabba69a..29796a0d9 100644 --- a/update/check.go +++ b/update/check.go @@ -2,7 +2,7 @@ package update import ( "fmt" - "io/ioutil" + stdio "io" "net/http" "strings" "time" @@ -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) }