mirror of
https://github.com/kubernetes/node-problem-detector.git
synced 2026-08-23 22:26:27 +00:00
chore: remove refs to deprecated io/ioutil
This commit is contained in:
@@ -18,7 +18,7 @@ package custompluginmonitor
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
@@ -57,7 +57,7 @@ func NewCustomPluginMonitorOrDie(configPath string) types.Monitor {
|
||||
configPath: configPath,
|
||||
tomb: tomb.NewTomb(),
|
||||
}
|
||||
f, err := ioutil.ReadFile(configPath)
|
||||
f, err := os.ReadFile(configPath)
|
||||
if err != nil {
|
||||
glog.Fatalf("Failed to read configuration file %q: %v", configPath, err)
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -132,12 +131,12 @@ func (p *Plugin) runRules() {
|
||||
// readFromReader reads the maxBytes from the reader and drains the rest.
|
||||
func readFromReader(reader io.ReadCloser, maxBytes int64) ([]byte, error) {
|
||||
limitReader := io.LimitReader(reader, maxBytes)
|
||||
data, err := ioutil.ReadAll(limitReader)
|
||||
data, err := io.ReadAll(limitReader)
|
||||
if err != nil {
|
||||
return []byte{}, err
|
||||
}
|
||||
// Drain the reader
|
||||
if _, err := io.Copy(ioutil.Discard, reader); err != nil {
|
||||
if _, err := io.Copy(io.Discard, reader); err != nil {
|
||||
return []byte{}, err
|
||||
}
|
||||
return data, nil
|
||||
|
||||
Reference in New Issue
Block a user