Skip to content

Commit

Permalink
chore: remove refs to deprecated io/ioutil
Browse files Browse the repository at this point in the history
Signed-off-by: guoguangwu <[email protected]>
  • Loading branch information
testwill committed Oct 17, 2023
1 parent 1a81c4b commit 771c1c8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
3 changes: 1 addition & 2 deletions pkg/controller/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package controller
import (
"github.com/golang/glog"
"io"
"io/ioutil"
"os"
"strings"
"text/template"
Expand Down Expand Up @@ -61,7 +60,7 @@ func NewVarnishController(
varnishSignaller *signaller.Signaller,
vclTemplateFile string,
) (*VarnishController, error) {
contents, err := ioutil.ReadFile(vclTemplateFile)
contents, err := os.ReadFile(vclTemplateFile)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"crypto/md5"
"encoding/hex"
"fmt"
"io/ioutil"
"os"
"os/exec"
"sort"
"strconv"
Expand Down Expand Up @@ -86,7 +86,7 @@ func (v *VarnishController) rebuildConfig(ctx context.Context) error {
return err
}

secret, err := ioutil.ReadFile(v.SecretFile)
secret, err := os.ReadFile(v.SecretFile)
if err != nil {
return err
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/signaller/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"net/http"
"strconv"
"time"
Expand Down Expand Up @@ -69,7 +68,7 @@ func (b *Signaller) Run() error {
func (b *Signaller) Serve(w http.ResponseWriter, r *http.Request) {
t := time.Now()

body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
b.errors <- err
http.Error(w, err.Error(), http.StatusInternalServerError)
Expand Down Expand Up @@ -144,7 +143,7 @@ func (b *Signaller) ProcessSignalQueue() {
}

if response != nil {
if _, err := io.Copy(ioutil.Discard, response.Body); err != nil {
if _, err := io.Copy(io.Discard, response.Body); err != nil {
glog.Error("error on discarding response body for connection reuse:", err)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/watcher/template_watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package watcher
import (
"github.com/fsnotify/fsnotify"
"github.com/golang/glog"
"io/ioutil"
"os"
)

func (t *fsnotifyTemplateWatcher) Run() (chan []byte, chan error) {
Expand All @@ -20,7 +20,7 @@ func (t *fsnotifyTemplateWatcher) watch(updates chan []byte, errors chan error)
if ev.Op&(fsnotify.Write|fsnotify.Create) > 0 {
glog.V(6).Infof("observed %s event on %s", ev.String(), ev.Name)

content, err := ioutil.ReadFile(t.filename)
content, err := os.ReadFile(t.filename)
if err != nil {
glog.Warningf("error while reading file %s: %s", t.filename, err.Error())

Expand Down
5 changes: 2 additions & 3 deletions pkg/watcher/template_watch_poll.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"crypto/md5"
"encoding/hex"
"github.com/golang/glog"
"io/ioutil"
"os"
"time"
)
Expand Down Expand Up @@ -56,7 +55,7 @@ func (t *pollingTemplateWatcher) watch(updates chan []byte, errors chan error) {

t.lastObservedTimestamp = modtime

content, err := ioutil.ReadFile(t.filename)
content, err := os.ReadFile(t.filename)
if err != nil {
glog.Warningf("error while reading file %s: %s", t.filename, err.Error())

Expand All @@ -71,7 +70,7 @@ func (t *pollingTemplateWatcher) watch(updates chan []byte, errors chan error) {

// print template info to assist troubleshooting
func logTemplateInfo(filename string, modtime time.Time, errors chan error) {
content, err := ioutil.ReadFile(filename)
content, err := os.ReadFile(filename)
if err != nil {
glog.Warningf("error while reading file %s: %s", filename, err.Error())
errors <- err
Expand Down

0 comments on commit 771c1c8

Please sign in to comment.