Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
5 changes: 2 additions & 3 deletions auth/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package auth
import (
"encoding/base64"
"fmt"
"io/ioutil"
"net/http"
"os"
"reflect"
Expand Down Expand Up @@ -38,15 +37,15 @@ func (rw *responseWriter) WriteHeader(statusCode int) {
}

func createBasicAuthFile(contents string) (string, error) {
dir, err := ioutil.TempDir("", "basicauth")
dir, err := os.MkdirTemp("", "basicauth")

if err != nil {
return "", fmt.Errorf("could not create temp dir: %s", err)
}

filename := fmt.Sprintf("%s/%s", dir, uuid.NewUUID())

err = ioutil.WriteFile(filename, []byte(contents), 0666)
err = os.WriteFile(filename, []byte(contents), 0666)

if err != nil {
return "", fmt.Errorf("could not write password file: %s", err)
Expand Down
4 changes: 2 additions & 2 deletions cert/file_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cert
import (
"crypto/tls"
"crypto/x509"
"io/ioutil"
"os"

"github.com/fabiolb/fabio/exit"
)
Expand All @@ -26,7 +26,7 @@ func (s FileSource) LoadClientCAs() (*x509.CertPool, error) {
if s.ClientAuthFile == "" {
return nil, nil
}
pemBlock, err := ioutil.ReadFile(path)
pemBlock, err := os.ReadFile(path)
return map[string][]byte{path: pemBlock}, err
})
}
Expand Down
6 changes: 3 additions & 3 deletions cert/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"crypto/x509"
"encoding/pem"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"net/url"
Expand Down Expand Up @@ -34,7 +34,7 @@ func loadURL(listURL string) (pemBlocks map[string][]byte, err error) {
return nil, err
}
defer resp.Body.Close()
return ioutil.ReadAll(resp.Body)
return io.ReadAll(resp.Body)
}

// fetch the file with the list of filenames
Expand Down Expand Up @@ -88,7 +88,7 @@ func loadPath(root string) (pemBlocks map[string][]byte, err error) {
return nil
}

buf, err := ioutil.ReadFile(path)
buf, err := os.ReadFile(path)
if err != nil {
return fmt.Errorf("cert: %s", err)
}
Expand Down
11 changes: 5 additions & 6 deletions cert/source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"encoding/pem"
"fmt"
"io"
"io/ioutil"
"log"
"math/big"
"net/http"
Expand Down Expand Up @@ -261,7 +260,7 @@ func TestConsulSource(t *testing.T) {
return false
}

n, err := io.Copy(ioutil.Discard, resp.Body)
n, err := io.Copy(io.Discard, resp.Body)
return err == nil && n > 10
}

Expand Down Expand Up @@ -582,7 +581,7 @@ func testSource(t *testing.T, source Source, rootCAs *x509.CertPool, sleep time.
// disable log output for the next call to prevent
// confusing log messages since they are expected
// http: TLS handshake error from 127.0.0.1:55044: remote error: bad certificate
log.SetOutput(ioutil.Discard)
log.SetOutput(io.Discard)
defer log.SetOutput(os.Stderr)

// fail calls https://localhost.org/ for which certificate validation
Expand Down Expand Up @@ -642,7 +641,7 @@ func roundtrip(serverName string, srvConfig *tls.Config, client *http.Client) (c
}
defer resp.Body.Close()

data, err := ioutil.ReadAll(resp.Body)
data, err := io.ReadAll(resp.Body)
if err != nil {
return 0, "", err
}
Expand Down Expand Up @@ -676,15 +675,15 @@ func http20Client(rootCAs *x509.CertPool) (*http.Client, error) {
}

func tempDir() string {
dir, err := ioutil.TempDir("", "fabio")
dir, err := os.MkdirTemp("", "fabio")
if err != nil {
panic(err.Error())
}
return dir
}

func writeFile(filename string, data []byte) {
if err := ioutil.WriteFile(filename, data, 0644); err != nil {
if err := os.WriteFile(filename, data, 0644); err != nil {
panic(err.Error())
}
}
Expand Down
3 changes: 1 addition & 2 deletions cert/vault_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cert
import (
"encoding/json"
"errors"
"io/ioutil"
"log"
"os"
"strings"
Expand Down Expand Up @@ -186,7 +185,7 @@ func getVaultToken(c string) string {
return token
}
if cArray[0] == "file" {
b, err := ioutil.ReadFile(cArray[1]) // just pass the file name
b, err := os.ReadFile(cArray[1]) // just pass the file name
if err != nil {
log.Printf("[WARN] vault: Failed to fetch token from %s", c)
} else {
Expand Down
3 changes: 1 addition & 2 deletions config/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"crypto/tls"
"errors"
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
Expand Down Expand Up @@ -1165,7 +1164,7 @@ func TestLoad(t *testing.T) {
}

case tt.path != "":
if err := ioutil.WriteFile(tt.path, []byte(tt.data), 0600); err != nil {
if err := os.WriteFile(tt.path, []byte(tt.data), 0600); err != nil {
t.Fatalf("error writing file: %s", err)
}
defer os.Remove(tt.path)
Expand Down
6 changes: 3 additions & 3 deletions registry/file/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
package file

import (
"io/ioutil"
"log"
"os"

"github.com/fabiolb/fabio/config"
"github.com/fabiolb/fabio/registry"
"github.com/fabiolb/fabio/registry/static"
)

func NewBackend(cfg *config.File) (registry.Backend, error) {
routes, err := ioutil.ReadFile(cfg.RoutesPath)
routes, err := os.ReadFile(cfg.RoutesPath)
if err != nil {
log.Println("[ERROR] Cannot read routes from ", cfg.RoutesPath)
return nil, err
}
noroutehtml, err := ioutil.ReadFile(cfg.NoRouteHTMLPath)
noroutehtml, err := os.ReadFile(cfg.NoRouteHTMLPath)
if err != nil {
log.Println("[ERROR] Cannot read no route HTML from ", cfg.NoRouteHTMLPath)
return nil, err
Expand Down
Loading