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
2 changes: 1 addition & 1 deletion cluster/gce/gci/append_or_replace_prefixed_line_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ jelloworld
}
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
f, err := os.CreateTemp("", "append_or_replace_test")
f, err := os.CreateTemp(t.TempDir(), "append_or_replace_test")
if err != nil {
t.Fatalf("Failed to create temp file: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/auth-provider-gcp/app/getcredentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package app
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"os"

Expand Down Expand Up @@ -112,7 +112,7 @@ func getCredentials(authFlow string) error {
if err != nil {
return err
}
unparsedRequest, err := ioutil.ReadAll(os.Stdin)
unparsedRequest, err := io.ReadAll(os.Stdin)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/gke-gcloud-auth-plugin/cred.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strings"
Expand Down Expand Up @@ -369,7 +369,7 @@ func executeCommand(name string, arg ...string) ([]byte, error) {
}

func readFile(filename string) ([]byte, error) {
return ioutil.ReadFile(filename)
return os.ReadFile(filename)
}

func timeNow() time.Time {
Expand Down
5 changes: 2 additions & 3 deletions cmd/gke-gcloud-auth-plugin/cred_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"context"
"fmt"
"os"
"path"
"testing"
"time"
Expand Down Expand Up @@ -703,14 +702,14 @@ func TestCloudsdkBasedGcloudAccessToken(t *testing.T) {
}

tokenForEnvVar := "gcloud_token_in_env_var"
os.Setenv(cloudsdkAuthAccessEnvVar, tokenForEnvVar)
t.Setenv(cloudsdkAuthAccessEnvVar, tokenForEnvVar)

ec, err := p.execCredential()
if err != nil {
t.Fatalf("err should be nil")
}

os.Setenv(cloudsdkAuthAccessEnvVar, "")
t.Setenv(cloudsdkAuthAccessEnvVar, "")

if diff := cmp.Diff(ec.Status.Token, tokenForEnvVar); diff != "" {
t.Errorf("unexpected token (-want +got): %s", diff)
Expand Down
7 changes: 3 additions & 4 deletions pkg/credentialconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -108,7 +107,7 @@ func ReadDockercfgFile(searchPaths []string) (cfg DockerConfig, err error) {
continue
}
klog.V(4).Infof("looking for .dockercfg at %s", absDockerConfigFileLocation)
contents, err := ioutil.ReadFile(absDockerConfigFileLocation)
contents, err := os.ReadFile(absDockerConfigFileLocation)
if os.IsNotExist(err) {
continue
}
Expand Down Expand Up @@ -160,7 +159,7 @@ func ReadDockerConfigJSONFile(searchPaths []string) (cfg DockerConfig, err error
func ReadSpecificDockerConfigJSONFile(filePath string) (cfg DockerConfig, err error) {
var contents []byte

if contents, err = ioutil.ReadFile(filePath); err != nil {
if contents, err = os.ReadFile(filePath); err != nil {
return nil, err
}
return readDockerConfigJSONFileFromBytes(contents)
Expand Down Expand Up @@ -212,7 +211,7 @@ func ReadURL(url string, client *http.Client, header *http.Header) (body []byte,
}

limitedReader := &io.LimitedReader{R: resp.Body, N: maxReadLength}
contents, err := ioutil.ReadAll(limitedReader)
contents, err := io.ReadAll(limitedReader)
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/credentialconfig/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package credentialconfig
import (
"encoding/base64"
"encoding/json"
"io/ioutil"
"os"
"path/filepath"
"reflect"
Expand All @@ -33,7 +32,7 @@ func TestReadDockerConfigFile(t *testing.T) {
//test dockerconfig json
inputDockerconfigJSONFile := "{ \"auths\": { \"http://foo.example.com\":{\"auth\":\"Zm9vOmJhcgo=\",\"email\":\"[email protected]\"}}}"

preferredPath, err := ioutil.TempDir("", "test_foo_bar_dockerconfigjson_")
preferredPath, err := os.MkdirTemp(t.TempDir(), "test_foo_bar_dockerconfigjson_")
if err != nil {
t.Fatalf("Creating tmp dir fail: %v", err)
return
Expand Down
4 changes: 2 additions & 2 deletions pkg/gcpcredential/gcpcredential.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ package gcpcredential

import (
"encoding/json"
"io/ioutil"
"net/http"
"os"
"os/exec"
"runtime"
"strings"
Expand Down Expand Up @@ -102,7 +102,7 @@ func onGCEVM() bool {
}
name = fields[1]
} else {
data, err := ioutil.ReadFile(GCEProductNameFile)
data, err := os.ReadFile(GCEProductNameFile)
if err != nil {
klog.V(2).Infof("Error while reading product_name: %v", err)
return false
Expand Down
3 changes: 1 addition & 2 deletions providers/gce/gcpcredential/credentialutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"

"k8s.io/cloud-provider/credentialconfig"
Expand Down Expand Up @@ -68,7 +67,7 @@ func ReadURL(url string, client *http.Client, header *http.Header) (body []byte,
}

limitedReader := &io.LimitedReader{R: resp.Body, N: maxReadLength}
contents, err := ioutil.ReadAll(limitedReader)
contents, err := io.ReadAll(limitedReader)
if err != nil {
return nil, err
}
Expand Down