From ade1d897f6b90ba0ea1fdd4b3dcdf7ba72f6ae9a Mon Sep 17 00:00:00 2001
From: Philipp Trulson
Date: Tue, 3 Dec 2024 15:27:28 +0100
Subject: [PATCH] Fix `ioutil` deprecations
---
pkg/lokiutil/client.go | 4 ++--
pkg/testutil/golden.go | 5 ++---
pkg/vaultutil/kubernetes.go | 4 ++--
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/pkg/lokiutil/client.go b/pkg/lokiutil/client.go
index eceb65a..203bfd0 100644
--- a/pkg/lokiutil/client.go
+++ b/pkg/lokiutil/client.go
@@ -2,7 +2,7 @@ package lokiutil
import (
"bytes"
- "io/ioutil"
+ "io"
"net/http"
"os"
"time"
@@ -156,7 +156,7 @@ func (c *Client) sendBatch(batch Batch) error {
}
defer resp.Body.Close()
- resBody, err := ioutil.ReadAll(resp.Body)
+ resBody, err := io.ReadAll(resp.Body)
if err != nil {
return errors.WithStack(err)
}
diff --git a/pkg/testutil/golden.go b/pkg/testutil/golden.go
index c658ede..3adc3c4 100644
--- a/pkg/testutil/golden.go
+++ b/pkg/testutil/golden.go
@@ -2,7 +2,6 @@ package testutil
import (
"encoding/json"
- "io/ioutil"
"os"
"github.com/pmezard/go-difflib/difflib"
@@ -21,14 +20,14 @@ type TB interface {
func assertGolden(t TB, filename string, data []byte, showDiff bool) {
if os.Getenv(GoldenUpdateEnv) != "" {
- err := ioutil.WriteFile(filename, data, os.FileMode(0644))
+ err := os.WriteFile(filename, data, os.FileMode(0644))
if err != nil {
t.Error(err)
return
}
}
- golden, err := ioutil.ReadFile(filename)
+ golden, err := os.ReadFile(filename)
if os.IsNotExist(err) {
golden = []byte{}
} else if err != nil {
diff --git a/pkg/vaultutil/kubernetes.go b/pkg/vaultutil/kubernetes.go
index 5238c68..b4e4fed 100644
--- a/pkg/vaultutil/kubernetes.go
+++ b/pkg/vaultutil/kubernetes.go
@@ -1,7 +1,7 @@
package vaultutil
import (
- "io/ioutil"
+ "os"
"path"
"github.com/hashicorp/vault/api"
@@ -14,7 +14,7 @@ const (
)
func KubernetesToken(client *api.Client, role string) (*api.Secret, error) {
- jwt, err := ioutil.ReadFile(KubernetesTokenPath)
+ jwt, err := os.ReadFile(KubernetesTokenPath)
if err != nil {
return nil, errors.WithStack(err)
}