Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated io/ioutil package references #733

Merged
merged 1 commit into from
Apr 9, 2024
Merged
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
3 changes: 1 addition & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/goccy/go-yaml"
"github.com/jessevdk/go-flags"
"github.com/pkg/errors"
"io/ioutil"
"os"
)

Expand Down Expand Up @@ -118,7 +117,7 @@ func (t *TLS) MakeConfig(serverName string) (*tls.Config, error) {
if t.Insecure {
tlsConfig.InsecureSkipVerify = true
} else if t.Ca != "" {
raw, err := ioutil.ReadFile(t.Ca)
raw, err := os.ReadFile(t.Ca)
if err != nil {
return nil, errors.Wrap(err, "can't read CA file")
}
Expand Down
13 changes: 6 additions & 7 deletions pkg/icingadb/objectpacker/objectpacker.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"github.com/pkg/errors"
"io"
"io/ioutil"
"reflect"
"sort"
)
Expand Down Expand Up @@ -102,7 +101,7 @@ func packValue(in reflect.Value, out io.Writer) error {
// If there aren't any values to pack, ...
if l < 1 {
// ... create one and pack it - panics on disallowed type.
_ = packValue(reflect.Zero(in.Type().Elem()), ioutil.Discard)
_ = packValue(reflect.Zero(in.Type().Elem()), io.Discard)
}

return nil
Expand Down Expand Up @@ -140,13 +139,13 @@ func packValue(in reflect.Value, out io.Writer) error {
packedKey = key.Slice(0, key.Len()).Interface().([]byte)
} else {
// Not just stringify the key (below), but also pack it (here) - panics on disallowed type.
_ = packValue(iter.Key(), ioutil.Discard)
_ = packValue(iter.Key(), io.Discard)

packedKey = []byte(fmt.Sprint(key.Interface()))
}
} else {
// Not just stringify the key (below), but also pack it (here) - panics on disallowed type.
_ = packValue(iter.Key(), ioutil.Discard)
_ = packValue(iter.Key(), io.Discard)

packedKey = []byte(fmt.Sprint(key.Interface()))
}
Expand Down Expand Up @@ -176,8 +175,8 @@ func packValue(in reflect.Value, out io.Writer) error {
typ := in.Type()

// ... create one and pack it - panics on disallowed type.
_ = packValue(reflect.Zero(typ.Key()), ioutil.Discard)
_ = packValue(reflect.Zero(typ.Elem()), ioutil.Discard)
_ = packValue(reflect.Zero(typ.Key()), io.Discard)
_ = packValue(reflect.Zero(typ.Elem()), io.Discard)
}

return nil
Expand All @@ -186,7 +185,7 @@ func packValue(in reflect.Value, out io.Writer) error {
err := packValue(reflect.Value{}, out)

// Create a fictive referenced value and pack it - panics on disallowed type.
_ = packValue(reflect.Zero(in.Type().Elem()), ioutil.Discard)
_ = packValue(reflect.Zero(in.Type().Elem()), io.Discard)

return err
} else {
Expand Down
4 changes: 2 additions & 2 deletions tests/history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
"io/ioutil"
"io"
"math"
"net/http"
"sort"
Expand Down Expand Up @@ -717,7 +717,7 @@ func processCheckResult(t *testing.T, client *utils.Icinga2Client, hostname stri
response, err := client.PostJson("/v1/actions/process-check-result", bytes.NewBuffer(reqBody))
require.NoError(t, err, "process-check-result")
if !assert.Equal(t, 200, response.StatusCode, "process-check-result") {
body, err := ioutil.ReadAll(response.Body)
body, err := io.ReadAll(response.Body)
require.NoError(t, err, "reading process-check-result response")
it.Logger(t).Error("process-check-result", zap.ByteString("api-response", body))
t.FailNow()
Expand Down
Loading