Skip to content
Open
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
4 changes: 2 additions & 2 deletions pkg/leaderelection/leaderelection.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package leaderelection
import (
"context"
"fmt"
"io/ioutil"
"math"
"os"
"strings"
"time"

Expand Down Expand Up @@ -89,7 +89,7 @@ func LeaderElectionDefaulting(config configv1.LeaderElection, defaultNamespace,
ret.Namespace = defaultNamespace
} else {
// Fall back to the namespace associated with the service account token, if available
if data, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace"); err == nil {
if data, err := os.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace"); err == nil {
if ns := strings.TrimSpace(string(data)); len(ns) > 0 {
ret.Namespace = ns
}
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/lib/common_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package lib
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
neturl "net/url"
Expand All @@ -27,7 +27,7 @@ const (
)

func ReadFile(path string) ([]byte, error) {
file, err := ioutil.ReadFile(path)
file, err := os.ReadFile(path)
return file, err
}

Expand Down Expand Up @@ -282,7 +282,7 @@ func MakeHTTPRequest(url string, requestMethod HTTPMethod, payload string) (stri
defer resp.Body.Close()

if resp.StatusCode >= 200 && resp.StatusCode < 300 {
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return "", string(body), fmt.Errorf("Error reading response body: %v", err)
}
Expand All @@ -291,7 +291,7 @@ func MakeHTTPRequest(url string, requestMethod HTTPMethod, payload string) (stri

// The response status code indicates an error
// Read the error response body
responseBody, responseErr := ioutil.ReadAll(resp.Body)
responseBody, responseErr := io.ReadAll(resp.Body)
if responseErr != nil {
return "", string(responseBody), fmt.Errorf("HTTP request failed with status code %d: %v", resp.StatusCode, responseErr)
}
Expand Down