Skip to content

Commit

Permalink
Merge pull request #133 from fluxcd/remove-ioutil
Browse files Browse the repository at this point in the history
Remove deprecated `io/ioutil`
  • Loading branch information
stefanprodan authored Nov 22, 2021
2 parents eb55926 + e73e690 commit 91f89c4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
3 changes: 1 addition & 2 deletions github/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"errors"
"fmt"
"io/ioutil"
"math/rand"
"net/http"
"os"
Expand Down Expand Up @@ -140,7 +139,7 @@ var _ = Describe("GitHub Provider", func() {
BeforeSuite(func() {
githubToken := os.Getenv("GITHUB_TOKEN")
if len(githubToken) == 0 {
b, err := ioutil.ReadFile(ghTokenFile)
b, err := os.ReadFile(ghTokenFile)
if token := string(b); err == nil && len(token) != 0 {
githubToken = token
} else {
Expand Down
9 changes: 4 additions & 5 deletions gitlab/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"math/rand"
"net/http"
"os"
Expand Down Expand Up @@ -90,9 +89,9 @@ type customTransport struct {
}

func getBodyFromReaderWithoutConsuming(r *io.ReadCloser) string {
body, _ := ioutil.ReadAll(*r)
body, _ := io.ReadAll(*r)
(*r).Close()
*r = ioutil.NopCloser(bytes.NewBuffer(body))
*r = io.NopCloser(bytes.NewBuffer(body))
return string(body)
}

Expand Down Expand Up @@ -124,7 +123,7 @@ func (t *customTransport) RoundTrip(req *http.Request) (*http.Response, error) {
strings.Contains(string(responseBody), ProjectStillBeingDeleted) {
time.Sleep(2 * time.Second)
if req != nil && req.Body != nil {
req.Body = ioutil.NopCloser(strings.NewReader(requestBody))
req.Body = io.NopCloser(strings.NewReader(requestBody))
}
retryCount--
continue
Expand Down Expand Up @@ -189,7 +188,7 @@ var _ = Describe("GitLab Provider", func() {
BeforeSuite(func() {
gitlabToken := os.Getenv("GITLAB_TOKEN")
if len(gitlabToken) == 0 {
b, err := ioutil.ReadFile(ghTokenFile)
b, err := os.ReadFile(ghTokenFile)
if token := string(b); err == nil && len(token) != 0 {
gitlabToken = token
} else {
Expand Down
3 changes: 1 addition & 2 deletions stash/integration_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package stash
import (
"context"
"fmt"
"io/ioutil"
"math/rand"
"net/http"
"os"
Expand Down Expand Up @@ -186,7 +185,7 @@ var _ = Describe("Stash Provider", func() {

stashToken := os.Getenv("STASH_TOKEN")
if stashToken == "" {
b, err := ioutil.ReadFile(stashTokenFile)
b, err := os.ReadFile(stashTokenFile)
if token := string(b); err == nil && token != "" {
stashToken = token
} else {
Expand Down

0 comments on commit 91f89c4

Please sign in to comment.