Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
io/ioutil is deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
jbygdell committed Nov 2, 2022
1 parent 84900e3 commit 1304182
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
4 changes: 2 additions & 2 deletions bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package main
import (
"crypto/tls"
"crypto/x509"
"io/ioutil"
"net/http"
"os"
"reflect"
"strings"

Expand Down Expand Up @@ -66,7 +66,7 @@ func transportConfigS3(config S3Config) http.RoundTripper {
cfg.RootCAs = systemCAs

if config.cacert != "" {
cacert, e := ioutil.ReadFile(config.cacert) // #nosec this file comes from our config
cacert, e := os.ReadFile(config.cacert) // #nosec this file comes from our config
if e != nil {
log.Fatalf("failed to append %q to RootCAs: %v", cacert, e)
}
Expand Down
10 changes: 5 additions & 5 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"io/ioutil"
"os"
"path"
"reflect"
"strings"
Expand Down Expand Up @@ -253,7 +253,7 @@ func TLSConfigBroker(c *Config) (*tls.Config, error) {
continue
}

cacert, e := ioutil.ReadFile(cacert) // #nosec this file comes from our configuration
cacert, e := os.ReadFile(cacert) // #nosec this file comes from our configuration
if e != nil {
return nil, fmt.Errorf("failed to append %q to RootCAs: %v", cacert, e)
}
Expand All @@ -268,11 +268,11 @@ func TLSConfigBroker(c *Config) (*tls.Config, error) {
}

if c.Broker.verifyPeer {
cert, e := ioutil.ReadFile(c.Broker.clientCert)
cert, e := os.ReadFile(c.Broker.clientCert)
if e != nil {
return nil, fmt.Errorf("failed to read client cert %q, reason: %v", c.Broker.clientKey, e)
}
key, e := ioutil.ReadFile(c.Broker.clientKey)
key, e := os.ReadFile(c.Broker.clientKey)
if e != nil {
return nil, fmt.Errorf("failed to read client key %q, reason: %v", c.Broker.clientKey, e)
}
Expand Down Expand Up @@ -302,7 +302,7 @@ func TLSConfigProxy(c *Config) (*tls.Config, error) {
cfg.RootCAs = systemCAs

if c.S3.cacert != "" {
cacert, e := ioutil.ReadFile(c.S3.cacert) // #nosec this file comes from our configuration
cacert, e := os.ReadFile(c.S3.cacert) // #nosec this file comes from our configuration
if e != nil {
return nil, fmt.Errorf("failed to append %q to RootCAs: %v", cacert, e)
}
Expand Down
4 changes: 2 additions & 2 deletions healthchecks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"crypto/tls"
"io/ioutil"
"io"
"log"
"net"
"net/http"
Expand Down Expand Up @@ -47,7 +47,7 @@ func TestHealthchecks(t *testing.T) {
if err != nil {
log.Fatal(err)
}
_, err = ioutil.ReadAll(res.Body)
_, err = io.ReadAll(res.Body)
res.Body.Close()
if err != nil {
log.Fatal(err)
Expand Down
5 changes: 2 additions & 3 deletions helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"io/ioutil"
"os"
"path/filepath"
"time"
Expand Down Expand Up @@ -101,7 +100,7 @@ func MakeFolder(path string) (string, string, error) {
// ParsePrivateRSAKey reads and parses the RSA private key
func ParsePrivateRSAKey(path, keyName string) (*rsa.PrivateKey, error) {
keyPath := path + keyName
prKey, err := ioutil.ReadFile(filepath.Clean(keyPath))
prKey, err := os.ReadFile(filepath.Clean(keyPath))
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -215,7 +214,7 @@ func CreateHSToken(key []byte, headerAlg, headerType string, tokenClaims map[str
// ParsePrivateECKey reads and parses the EC private key
func ParsePrivateECKey(path, keyName string) (*ecdsa.PrivateKey, error) {
keyPath := path + keyName
prKey, err := ioutil.ReadFile(filepath.Clean(keyPath))
prKey, err := os.ReadFile(filepath.Clean(keyPath))
if err != nil {
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"crypto/tls"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -141,7 +141,7 @@ func (p *Proxy) allowedResponse(w http.ResponseWriter, r *http.Request) {

// Read any remaining data in the connection and
// Close so connection can be reused.
_, _ = ioutil.ReadAll(s3response.Body)
_, _ = io.ReadAll(s3response.Body)
_ = s3response.Body.Close()
}

Expand Down Expand Up @@ -338,7 +338,7 @@ func (p *Proxy) newSession() (*session.Session, error) {
var mySession *session.Session
var err error
if p.s3.cacert != "" {
cert, _ := ioutil.ReadFile(p.s3.cacert)
cert, _ := os.ReadFile(p.s3.cacert)
cacert := bytes.NewReader(cert)
mySession, err = session.NewSessionWithOptions(session.Options{
CustomCABundle: cacert,
Expand Down
5 changes: 2 additions & 3 deletions userauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"encoding/pem"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -242,7 +241,7 @@ func (u *ValidateFromToken) getjwtkey(jwtpubkeypath string) error {
}
if info.Mode().IsRegular() {
log.Debug("Reading file: ", filepath.Join(filepath.Clean(jwtpubkeypath), info.Name()))
keyData, err := ioutil.ReadFile(filepath.Join(filepath.Clean(jwtpubkeypath), info.Name()))
keyData, err := os.ReadFile(filepath.Join(filepath.Clean(jwtpubkeypath), info.Name()))
if err != nil {
return fmt.Errorf("token file error: %v", err)
}
Expand Down Expand Up @@ -293,7 +292,7 @@ func (u *ValidateFromToken) getjwtpubkey(jwtpubkeyurl string) error {
if err != nil {
return fmt.Errorf("failed to get JWK (%v)", err)
}
b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
if err != nil {
return fmt.Errorf("failed to read key response (%v)", err)
}
Expand Down

0 comments on commit 1304182

Please sign in to comment.