Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update ioutils for os and updated github dependencies to v58 #111

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions appsTransport.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"crypto/rsa"
"errors"
"fmt"
"io/ioutil"
"net/http"
"os"
"strconv"
"time"

Expand All @@ -30,7 +30,7 @@ type AppsTransport struct {

// NewAppsTransportKeyFromFile returns a AppsTransport using a private key from file.
func NewAppsTransportKeyFromFile(tr http.RoundTripper, appID int64, privateKeyFile string) (*AppsTransport, error) {
privateKey, err := ioutil.ReadFile(privateKeyFile)
privateKey, err := os.ReadFile(privateKeyFile)
if err != nil {
return nil, fmt.Errorf("could not read private key: %s", err)
}
Expand Down
3 changes: 1 addition & 2 deletions appsTransport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package ghinstallation
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
Expand All @@ -15,7 +14,7 @@ import (
)

func TestNewAppsTransportKeyFromFile(t *testing.T) {
tmpfile, err := ioutil.TempFile("", "example")
tmpfile, err := os.CreateTemp(t.TempDir(), "example")
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ go 1.13
require (
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/google/go-cmp v0.6.0
github.com/google/go-github/v57 v57.0.0
github.com/google/go-github/v58 v58.0.0
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-github/v57 v57.0.0 h1:L+Y3UPTY8ALM8x+TV0lg+IEBI+upibemtBD8Q9u7zHs=
github.com/google/go-github/v57 v57.0.0/go.mod h1:s0omdnye0hvK/ecLvpsGfJMiRt85PimQh4oygmLIxHw=
github.com/google/go-github/v58 v58.0.0 h1:Una7GGERlF/37XfkPwpzYJe0Vp4dt2k1kCjlxwjIvzw=
github.com/google/go-github/v58 v58.0.0/go.mod h1:k4hxDKEfoWpSqFlc8LTpGd9fu2KrV1YAa6Hi6FmDNY4=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
6 changes: 3 additions & 3 deletions transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"strings"
"sync"
"time"

"github.com/google/go-github/v57/github"
"github.com/google/go-github/v58/github"
)

const (
Expand Down Expand Up @@ -73,7 +73,7 @@ var _ http.RoundTripper = &Transport{}

// NewKeyFromFile returns a Transport using a private key from file.
func NewKeyFromFile(tr http.RoundTripper, appID, installationID int64, privateKeyFile string) (*Transport, error) {
privateKey, err := ioutil.ReadFile(privateKeyFile)
privateKey, err := os.ReadFile(privateKeyFile)
if err != nil {
return nil, fmt.Errorf("could not read private key: %s", err)
}
Expand Down
21 changes: 10 additions & 11 deletions transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
Expand All @@ -15,7 +14,7 @@
"time"

"github.com/google/go-cmp/cmp"
"github.com/google/go-github/v57/github"
"github.com/google/go-github/v58/github"
)

const (
Expand Down Expand Up @@ -129,7 +128,7 @@
}

func TestNewKeyFromFile(t *testing.T) {
tmpfile, err := ioutil.TempFile("", "example")
tmpfile, err := os.TempFile("", "example")

Check failure on line 131 in transport_test.go

View workflow job for this annotation

GitHub Actions / Build

undefined: os.TempFile
adrien-barret marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
t.Fatal(err)
}
Expand All @@ -142,7 +141,7 @@
t.Fatal(err)
}

_, err = NewKeyFromFile(&http.Transport{}, appID, installationID, tmpfile.Name())

Check failure on line 144 in transport_test.go

View workflow job for this annotation

GitHub Actions / Build

cannot assign error to err in multiple assignment
if err != nil {
t.Fatal("unexpected error:", err)
}
Expand Down Expand Up @@ -226,8 +225,8 @@
rt: func(req *http.Request) (*http.Response, error) {
// Convert io.ReadCloser to String without deleting body data.
var gotBodyBytes []byte
gotBodyBytes, _ = ioutil.ReadAll(req.Body)
req.Body = ioutil.NopCloser(bytes.NewBuffer(gotBodyBytes))
gotBodyBytes, _ = io.ReadAll(req.Body)

Check failure on line 228 in transport_test.go

View workflow job for this annotation

GitHub Actions / Build

undefined: io
wlynch marked this conversation as resolved.
Show resolved Hide resolved
req.Body = io.NopCloser(bytes.NewBuffer(gotBodyBytes))

Check failure on line 229 in transport_test.go

View workflow job for this annotation

GitHub Actions / Build

undefined: io
gotBodyString := string(gotBodyBytes)

// Compare request sent with request received.
Expand All @@ -251,7 +250,7 @@
if err != nil {
return nil, fmt.Errorf("error converting token into io.ReadWriter: %+v", err)
}
tokenBody := ioutil.NopCloser(tokenReadWriter)
tokenBody := os.NopCloser(tokenReadWriter)

Check failure on line 253 in transport_test.go

View workflow job for this annotation

GitHub Actions / Build

undefined: os.NopCloser
adrien-barret marked this conversation as resolved.
Show resolved Hide resolved
return &http.Response{
Body: tokenBody,
StatusCode: 200,
Expand Down Expand Up @@ -295,22 +294,22 @@
rt: func(req *http.Request) (*http.Response, error) {
if strings.Contains(req.URL.Path, "//") {
return &http.Response{
Body: ioutil.NopCloser(strings.NewReader("Forbidden\n")),
Body: os.NopCloser(strings.NewReader("Forbidden\n")),

Check failure on line 297 in transport_test.go

View workflow job for this annotation

GitHub Actions / Build

undefined: os.NopCloser
adrien-barret marked this conversation as resolved.
Show resolved Hide resolved
StatusCode: 401,
}, fmt.Errorf("Got simulated 401 Github Forbidden response")
}

if req.URL.Path == "test_endpoint/" && req.Header.Get("Authorization") == fmt.Sprintf("token %s", tokenToBe) {
return &http.Response{
Body: ioutil.NopCloser(strings.NewReader("Beautiful\n")),
Body: os.NopCloser(strings.NewReader("Beautiful\n")),

Check failure on line 304 in transport_test.go

View workflow job for this annotation

GitHub Actions / Build

undefined: os.NopCloser
StatusCode: 200,
}, nil
}

// Convert io.ReadCloser to String without deleting body data.
var gotBodyBytes []byte
gotBodyBytes, _ = ioutil.ReadAll(req.Body)
req.Body = ioutil.NopCloser(bytes.NewBuffer(gotBodyBytes))
gotBodyBytes, _ = os.ReadAll(req.Body)

Check failure on line 311 in transport_test.go

View workflow job for this annotation

GitHub Actions / Build

undefined: os.ReadAll
adrien-barret marked this conversation as resolved.
Show resolved Hide resolved
req.Body = os.NopCloser(bytes.NewBuffer(gotBodyBytes))

Check failure on line 312 in transport_test.go

View workflow job for this annotation

GitHub Actions / Build

undefined: os.NopCloser
gotBodyString := string(gotBodyBytes)

// Compare request sent with request received.
Expand All @@ -334,7 +333,7 @@
if err != nil {
return nil, fmt.Errorf("error converting token into io.ReadWriter: %+v", err)
}
tokenBody := ioutil.NopCloser(tokenReadWriter)
tokenBody := os.NopCloser(tokenReadWriter)

Check failure on line 336 in transport_test.go

View workflow job for this annotation

GitHub Actions / Build

undefined: os.NopCloser
return &http.Response{
Body: tokenBody,
StatusCode: 200,
Expand Down
Loading