mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-08 11:38:15 +00:00
Merge pull request #118399 from skitt/ioutil-sig-api-machinery
api-machinery: stop using deprecated io/ioutil
This commit is contained in:
commit
10beda334e
@ -20,7 +20,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
@ -237,7 +237,7 @@ func TestVersion(t *testing.T) {
|
|||||||
func decodeResponse(resp *http.Response, obj interface{}) error {
|
func decodeResponse(resp *http.Response, obj interface{}) error {
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
data, err := ioutil.ReadAll(resp.Body)
|
data, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ package wsstream
|
|||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"reflect"
|
"reflect"
|
||||||
@ -57,7 +56,7 @@ func TestRawConn(t *testing.T) {
|
|||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
data, err := ioutil.ReadAll(conn.channels[0])
|
data, err := io.ReadAll(conn.channels[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
@ -140,7 +139,7 @@ func TestBase64Conn(t *testing.T) {
|
|||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
data, err := ioutil.ReadAll(conn.channels[0])
|
data, err := io.ReadAll(conn.channels[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
|
@ -21,7 +21,6 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
@ -251,7 +250,7 @@ func readWebSocket(r *Reader, t *testing.T, fn func(*websocket.Conn), protocols
|
|||||||
fn(client)
|
fn(client)
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := ioutil.ReadAll(client)
|
data, err := io.ReadAll(client)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return data, err
|
return data, err
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -60,7 +59,7 @@ func ReadAdmissionConfiguration(pluginNames []string, configFilePath string, con
|
|||||||
return configProvider{config: &apiserver.AdmissionConfiguration{}}, nil
|
return configProvider{config: &apiserver.AdmissionConfiguration{}}, nil
|
||||||
}
|
}
|
||||||
// a file was provided, so we just read it.
|
// a file was provided, so we just read it.
|
||||||
data, err := ioutil.ReadFile(configFilePath)
|
data, err := os.ReadFile(configFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to read admission control configuration from %q [%v]", configFilePath, err)
|
return nil, fmt.Errorf("unable to read admission control configuration from %q [%v]", configFilePath, err)
|
||||||
}
|
}
|
||||||
@ -141,7 +140,7 @@ func GetAdmissionPluginConfigurationFor(pluginCfg apiserver.AdmissionPluginConfi
|
|||||||
}
|
}
|
||||||
// there is nothing nested, so we delegate to path
|
// there is nothing nested, so we delegate to path
|
||||||
if pluginCfg.Path != "" {
|
if pluginCfg.Path != "" {
|
||||||
content, err := ioutil.ReadFile(pluginCfg.Path)
|
content, err := os.ReadFile(pluginCfg.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Fatalf("Couldn't open admission plugin configuration %s: %#v", pluginCfg.Path, err)
|
klog.Fatalf("Couldn't open admission plugin configuration %s: %#v", pluginCfg.Path, err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||||||
package admission
|
package admission
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
@ -33,7 +33,7 @@ import (
|
|||||||
|
|
||||||
func TestReadAdmissionConfiguration(t *testing.T) {
|
func TestReadAdmissionConfiguration(t *testing.T) {
|
||||||
// create a place holder file to hold per test config
|
// create a place holder file to hold per test config
|
||||||
configFile, err := ioutil.TempFile("", "admission-plugin-config")
|
configFile, err := os.CreateTemp("", "admission-plugin-config")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected err: %v", err)
|
t.Fatalf("unexpected err: %v", err)
|
||||||
}
|
}
|
||||||
@ -188,7 +188,7 @@ func TestReadAdmissionConfiguration(t *testing.T) {
|
|||||||
require.NoError(t, apiserverapiv1.AddToScheme(scheme))
|
require.NoError(t, apiserverapiv1.AddToScheme(scheme))
|
||||||
|
|
||||||
for testName, testCase := range testCases {
|
for testName, testCase := range testCases {
|
||||||
if err = ioutil.WriteFile(configFileName, []byte(testCase.ConfigBody), 0644); err != nil {
|
if err = os.WriteFile(configFileName, []byte(testCase.ConfigBody), 0644); err != nil {
|
||||||
t.Fatalf("unexpected err writing temp file: %v", err)
|
t.Fatalf("unexpected err writing temp file: %v", err)
|
||||||
}
|
}
|
||||||
config, err := ReadAdmissionConfiguration(testCase.PluginNames, configFileName, scheme)
|
config, err := ReadAdmissionConfiguration(testCase.PluginNames, configFileName, scheme)
|
||||||
@ -203,7 +203,7 @@ func TestReadAdmissionConfiguration(t *testing.T) {
|
|||||||
|
|
||||||
func TestEmbeddedConfiguration(t *testing.T) {
|
func TestEmbeddedConfiguration(t *testing.T) {
|
||||||
// create a place holder file to hold per test config
|
// create a place holder file to hold per test config
|
||||||
configFile, err := ioutil.TempFile("", "admission-plugin-config")
|
configFile, err := os.CreateTemp("", "admission-plugin-config")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected err: %v", err)
|
t.Fatalf("unexpected err: %v", err)
|
||||||
}
|
}
|
||||||
@ -297,7 +297,7 @@ func TestEmbeddedConfiguration(t *testing.T) {
|
|||||||
require.NoError(t, apiserverapiv1alpha1.AddToScheme(scheme))
|
require.NoError(t, apiserverapiv1alpha1.AddToScheme(scheme))
|
||||||
require.NoError(t, apiserverapiv1.AddToScheme(scheme))
|
require.NoError(t, apiserverapiv1.AddToScheme(scheme))
|
||||||
|
|
||||||
if err = ioutil.WriteFile(configFileName, []byte(test.ConfigBody), 0644); err != nil {
|
if err = os.WriteFile(configFileName, []byte(test.ConfigBody), 0644); err != nil {
|
||||||
t.Errorf("[%s] unexpected err writing temp file: %v", desc, err)
|
t.Errorf("[%s] unexpected err writing temp file: %v", desc, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -311,7 +311,7 @@ func TestEmbeddedConfiguration(t *testing.T) {
|
|||||||
t.Errorf("[%s] Failed to get Foo config: %v", desc, err)
|
t.Errorf("[%s] Failed to get Foo config: %v", desc, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
bs, err := ioutil.ReadAll(r)
|
bs, err := io.ReadAll(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("[%s] Failed to read Foo config data: %v", desc, err)
|
t.Errorf("[%s] Failed to read Foo config data: %v", desc, err)
|
||||||
continue
|
continue
|
||||||
|
@ -19,7 +19,6 @@ package resourcequota
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/serializer"
|
"k8s.io/apimachinery/pkg/runtime/serializer"
|
||||||
@ -50,7 +49,7 @@ func LoadConfiguration(config io.Reader) (*resourcequotaapi.Configuration, error
|
|||||||
return internalConfig, nil
|
return internalConfig, nil
|
||||||
}
|
}
|
||||||
// we have a config so parse it.
|
// we have a config so parse it.
|
||||||
data, err := ioutil.ReadAll(config)
|
data, err := io.ReadAll(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ package config
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
@ -47,7 +46,7 @@ func LoadConfig(configFile io.Reader) (string, error) {
|
|||||||
var kubeconfigFile string
|
var kubeconfigFile string
|
||||||
if configFile != nil {
|
if configFile != nil {
|
||||||
// we have a config so parse it.
|
// we have a config so parse it.
|
||||||
data, err := ioutil.ReadAll(configFile)
|
data, err := io.ReadAll(configFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
@ -115,7 +114,7 @@ func splitStream(config io.Reader) (io.Reader, io.Reader, error) {
|
|||||||
return nil, nil, nil
|
return nil, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
configBytes, err := ioutil.ReadAll(config)
|
configBytes, err := io.ReadAll(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ package server
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
@ -192,7 +192,7 @@ func TestNewWithDelegate(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
data, _ := ioutil.ReadAll(resp.Body)
|
data, _ := io.ReadAll(resp.Body)
|
||||||
if http.StatusOK != resp.StatusCode {
|
if http.StatusOK != resp.StatusCode {
|
||||||
t.Logf("got %d", resp.StatusCode)
|
t.Logf("got %d", resp.StatusCode)
|
||||||
t.Log(string(data))
|
t.Log(string(data))
|
||||||
@ -233,7 +233,7 @@ func checkPath(url string, expectedStatusCode int, expectedBody string, t *testi
|
|||||||
dump, _ := httputil.DumpResponse(resp, true)
|
dump, _ := httputil.DumpResponse(resp, true)
|
||||||
t.Log(string(dump))
|
t.Log(string(dump))
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -256,7 +256,7 @@ func checkExpectedPathsAtRoot(url string, expectedPaths []string, t *testing.T)
|
|||||||
dump, _ := httputil.DumpResponse(resp, true)
|
dump, _ := httputil.DumpResponse(resp, true)
|
||||||
t.Log(string(dump))
|
t.Log(string(dump))
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ func (c *DynamicFileCAContent) AddListener(listener Listener) {
|
|||||||
|
|
||||||
// loadCABundle determines the next set of content for the file.
|
// loadCABundle determines the next set of content for the file.
|
||||||
func (c *DynamicFileCAContent) loadCABundle() error {
|
func (c *DynamicFileCAContent) loadCABundle() error {
|
||||||
caBundle, err := ioutil.ReadFile(c.filename)
|
caBundle, err := os.ReadFile(c.filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -80,11 +80,11 @@ func (c *DynamicCertKeyPairContent) AddListener(listener Listener) {
|
|||||||
|
|
||||||
// loadCertKeyPair determines the next set of content for the file.
|
// loadCertKeyPair determines the next set of content for the file.
|
||||||
func (c *DynamicCertKeyPairContent) loadCertKeyPair() error {
|
func (c *DynamicCertKeyPairContent) loadCertKeyPair() error {
|
||||||
cert, err := ioutil.ReadFile(c.certFile)
|
cert, err := os.ReadFile(c.certFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
key, err := ioutil.ReadFile(c.keyFile)
|
key, err := os.ReadFile(c.keyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ package egressselector
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
@ -51,7 +51,7 @@ func ReadEgressSelectorConfiguration(configFilePath string) (*apiserver.EgressSe
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
// a file was provided, so we just read it.
|
// a file was provided, so we just read it.
|
||||||
data, err := ioutil.ReadFile(configFilePath)
|
data, err := os.ReadFile(configFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to read egress selector configuration from %q [%v]", configFilePath, err)
|
return nil, fmt.Errorf("unable to read egress selector configuration from %q [%v]", configFilePath, err)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ package egressselector
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
@ -279,12 +278,12 @@ spec:
|
|||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
proxyConfig := fmt.Sprintf("test-egress-selector-config-%s", tc.name)
|
proxyConfig := fmt.Sprintf("test-egress-selector-config-%s", tc.name)
|
||||||
if tc.createFile {
|
if tc.createFile {
|
||||||
f, err := ioutil.TempFile("", proxyConfig)
|
f, err := os.CreateTemp("", proxyConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer utiltesting.CloseAndRemove(t, f)
|
defer utiltesting.CloseAndRemove(t, f)
|
||||||
if err := ioutil.WriteFile(f.Name(), []byte(tc.contents), os.FileMode(0755)); err != nil {
|
if err := os.WriteFile(f.Name(), []byte(tc.contents), os.FileMode(0755)); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
proxyConfig = f.Name()
|
proxyConfig = f.Name()
|
||||||
|
@ -22,10 +22,10 @@ import (
|
|||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -277,7 +277,7 @@ func getTLSConfig(t *apiserver.TLSConfig) (*tls.Config, error) {
|
|||||||
}
|
}
|
||||||
certPool := x509.NewCertPool()
|
certPool := x509.NewCertPool()
|
||||||
if caCert != "" {
|
if caCert != "" {
|
||||||
certBytes, err := ioutil.ReadFile(caCert)
|
certBytes, err := os.ReadFile(caCert)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to read cert file %s, got %v", caCert, err)
|
return nil, fmt.Errorf("failed to read cert file %s, got %v", caCert, err)
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -971,7 +971,7 @@ func setupDoer(t *testing.T, info *SecureServingInfo) doer {
|
|||||||
// in this test, we don't depend on the body of the response, so we can
|
// in this test, we don't depend on the body of the response, so we can
|
||||||
// close the Body here to ensure the underlying transport can be reused
|
// close the Body here to ensure the underlying transport can be reused
|
||||||
if response != nil {
|
if response != nil {
|
||||||
ioutil.ReadAll(response.Body)
|
io.ReadAll(response.Body)
|
||||||
response.Body.Close()
|
response.Body.Close()
|
||||||
}
|
}
|
||||||
return result{
|
return result{
|
||||||
|
@ -21,7 +21,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
@ -233,7 +232,7 @@ func TestInstallAPIGroups(t *testing.T) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("[%d] unexpected error reading body at path %q: %v", i, path, err)
|
t.Errorf("[%d] unexpected error reading body at path %q: %v", i, path, err)
|
||||||
continue
|
continue
|
||||||
@ -277,7 +276,7 @@ func TestInstallAPIGroups(t *testing.T) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err = ioutil.ReadAll(resp.Body)
|
body, err = io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("[%d] unexpected error reading body at path %q: %v", i, path, err)
|
t.Errorf("[%d] unexpected error reading body at path %q: %v", i, path, err)
|
||||||
continue
|
continue
|
||||||
@ -339,7 +338,7 @@ func TestPrepareRun(t *testing.T) {
|
|||||||
// healthz checks are installed in PrepareRun
|
// healthz checks are installed in PrepareRun
|
||||||
resp, err = http.Get(server.URL + "/healthz")
|
resp, err = http.Get(server.URL + "/healthz")
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
data, _ := ioutil.ReadAll(resp.Body)
|
data, _ := io.ReadAll(resp.Body)
|
||||||
if http.StatusOK != resp.StatusCode {
|
if http.StatusOK != resp.StatusCode {
|
||||||
t.Logf("got %d", resp.StatusCode)
|
t.Logf("got %d", resp.StatusCode)
|
||||||
t.Log(string(data))
|
t.Log(string(data))
|
||||||
@ -368,7 +367,7 @@ func TestUpdateOpenAPISpec(t *testing.T) {
|
|||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.Equal(http.StatusOK, resp.StatusCode)
|
assert.Equal(http.StatusOK, resp.StatusCode)
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.Equal(oldSpec, body)
|
assert.Equal(oldSpec, body)
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
@ -387,7 +386,7 @@ func TestUpdateOpenAPISpec(t *testing.T) {
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
assert.Equal(http.StatusOK, resp.StatusCode)
|
assert.Equal(http.StatusOK, resp.StatusCode)
|
||||||
|
|
||||||
body, err = ioutil.ReadAll(resp.Body)
|
body, err = io.ReadAll(resp.Body)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.Equal(newSpec, body)
|
assert.Equal(newSpec, body)
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
@ -142,7 +142,7 @@ func TestGracefulShutdownForActiveHTTP2Streams(t *testing.T) {
|
|||||||
|
|
||||||
// validate
|
// validate
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
_, err = ioutil.ReadAll(resp.Body)
|
_, err = io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("%v", err)
|
t.Errorf("%v", err)
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ package storage
|
|||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
@ -337,7 +337,7 @@ func backends(storageConfig storagebackend.Config, grOverrides map[schema.GroupR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(storageConfig.Transport.TrustedCAFile) > 0 {
|
if len(storageConfig.Transport.TrustedCAFile) > 0 {
|
||||||
if caCert, err := ioutil.ReadFile(storageConfig.Transport.TrustedCAFile); err != nil {
|
if caCert, err := os.ReadFile(storageConfig.Transport.TrustedCAFile); err != nil {
|
||||||
klog.Errorf("failed to read ca file while getting backends: %s", err)
|
klog.Errorf("failed to read ca file while getting backends: %s", err)
|
||||||
} else {
|
} else {
|
||||||
caPool := x509.NewCertPool()
|
caPool := x509.NewCertPool()
|
||||||
|
@ -18,9 +18,9 @@ package webhook
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -233,7 +233,7 @@ func restConfigFromKubeconfig(configAuthInfo *clientcmdapi.AuthInfo) (*rest.Conf
|
|||||||
config.BearerToken = configAuthInfo.Token
|
config.BearerToken = configAuthInfo.Token
|
||||||
config.BearerTokenFile = configAuthInfo.TokenFile
|
config.BearerTokenFile = configAuthInfo.TokenFile
|
||||||
} else if len(configAuthInfo.TokenFile) > 0 {
|
} else if len(configAuthInfo.TokenFile) > 0 {
|
||||||
tokenBytes, err := ioutil.ReadFile(configAuthInfo.TokenFile)
|
tokenBytes, err := os.ReadFile(configAuthInfo.TokenFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
@ -688,7 +687,7 @@ func TestWithExponentialBackoff(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func bootstrapTestDir(t *testing.T) string {
|
func bootstrapTestDir(t *testing.T) string {
|
||||||
dir, err := ioutil.TempDir("", "")
|
dir, err := os.MkdirTemp("", "")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@ -703,7 +702,7 @@ func bootstrapTestDir(t *testing.T) string {
|
|||||||
|
|
||||||
// Write the certificate files to disk or fail
|
// Write the certificate files to disk or fail
|
||||||
for fileName, fileData := range files {
|
for fileName, fileData := range files {
|
||||||
if err := ioutil.WriteFile(filepath.Join(dir, fileName), fileData, 0400); err != nil {
|
if err := os.WriteFile(filepath.Join(dir, fileName), fileData, 0400); err != nil {
|
||||||
os.RemoveAll(dir)
|
os.RemoveAll(dir)
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -713,7 +712,7 @@ func bootstrapTestDir(t *testing.T) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newKubeConfigFile(config v1.Config) (string, error) {
|
func newKubeConfigFile(config v1.Config) (string, error) {
|
||||||
configFile, err := ioutil.TempFile("", "")
|
configFile, err := os.CreateTemp("", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"net/url"
|
"net/url"
|
||||||
@ -416,7 +415,7 @@ func TestStreamRandomData(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := ioutil.ReadAll(bytes.NewReader(stdout.Bytes()))
|
data, err := io.ReadAll(bytes.NewReader(stdout.Bytes()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("error reading the stream: %v", err)
|
t.Errorf("error reading the stream: %v", err)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user