Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
updates dependencies to v58 and move ioutils to os.
  • Loading branch information
adrien-barret committed Jan 15, 2024
1 parent b3327f8 commit b3fbfef
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 22 deletions.
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.TempFile("", "example")

Check failure on line 17 in appsTransport_test.go

View workflow job for this annotation

GitHub Actions / Build

undefined: os.TempFile
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
23 changes: 11 additions & 12 deletions transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
Expand All @@ -15,7 +14,7 @@ import (
"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 TestNew(t *testing.T) {
}

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
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -168,7 +167,7 @@ func TestNew_appendHeader(t *testing.T) {
if err != nil {
t.Fatal("unexpected error:", err)
}
tr.BaseURL = ts.URL
itr.BaseURL = ts.URL

Check failure on line 170 in transport_test.go

View workflow job for this annotation

GitHub Actions / Build

undefined: itr

client := http.Client{Transport: tr}
_, err = client.Do(req)
Expand Down Expand Up @@ -226,8 +225,8 @@ func TestRefreshTokenWithParameters(t *testing.T) {
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, _ = os.ReadAll(req.Body)

Check failure on line 228 in transport_test.go

View workflow job for this annotation

GitHub Actions / Build

undefined: os.ReadAll
req.Body = os.NopCloser(bytes.NewBuffer(gotBodyBytes))

Check failure on line 229 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 @@ -251,7 +250,7 @@ func TestRefreshTokenWithParameters(t *testing.T) {
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
return &http.Response{
Body: tokenBody,
StatusCode: 200,
Expand Down Expand Up @@ -295,22 +294,22 @@ func TestRefreshTokenWithTrailingSlashBaseURL(t *testing.T) {
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
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)
req.Body = os.NopCloser(bytes.NewBuffer(gotBodyBytes))
gotBodyString := string(gotBodyBytes)

// Compare request sent with request received.
Expand All @@ -334,7 +333,7 @@ func TestRefreshTokenWithTrailingSlashBaseURL(t *testing.T) {
if err != nil {
return nil, fmt.Errorf("error converting token into io.ReadWriter: %+v", err)
}
tokenBody := ioutil.NopCloser(tokenReadWriter)
tokenBody := os.NopCloser(tokenReadWriter)
return &http.Response{
Body: tokenBody,
StatusCode: 200,
Expand Down

0 comments on commit b3fbfef

Please sign in to comment.