diff --git a/configmap/hash-gen/main.go b/configmap/hash-gen/main.go index 5846167f9..a2b154d92 100644 --- a/configmap/hash-gen/main.go +++ b/configmap/hash-gen/main.go @@ -20,7 +20,6 @@ import ( "bytes" "errors" "fmt" - "io/ioutil" "log" "os" @@ -39,7 +38,7 @@ func main() { // processFile reads the ConfigMap manifest from a file and adds or updates the label // containing the checksum of it's _example data if present. func processFile(fileName string) error { - in, err := ioutil.ReadFile(fileName) + in, err := os.ReadFile(fileName) if err != nil { return fmt.Errorf("failed to read file: %w", err) } @@ -50,7 +49,7 @@ func processFile(fileName string) error { } //nolint:gosec // This is not security critical so open permissions are fine. - if err := ioutil.WriteFile(fileName, out, 0644); err != nil { + if err := os.WriteFile(fileName, out, 0644); err != nil { return fmt.Errorf("failed to write file: %w", err) } return nil diff --git a/configmap/hash-gen/main_test.go b/configmap/hash-gen/main_test.go index ffac0bc6d..7dcaba8cf 100644 --- a/configmap/hash-gen/main_test.go +++ b/configmap/hash-gen/main_test.go @@ -17,7 +17,6 @@ limitations under the License. package main import ( - "io/ioutil" "os" "path" "testing" @@ -28,7 +27,7 @@ import ( func TestProcess(t *testing.T) { for _, test := range []string{"add", "update", "nothing"} { t.Run(test, func(t *testing.T) { - in, err := ioutil.ReadFile(path.Join("testdata", test+".yaml")) + in, err := os.ReadFile(path.Join("testdata", test+".yaml")) if err != nil { t.Fatal("Failed to load test fixture:", err) } @@ -38,7 +37,7 @@ func TestProcess(t *testing.T) { t.Fatal("Expected no error but got", err) } - want, err := ioutil.ReadFile(path.Join("testdata", test+"_want.yaml")) + want, err := os.ReadFile(path.Join("testdata", test+"_want.yaml")) if err != nil && !os.IsNotExist(err) { t.Fatal("Failed to load test fixture:", err) } diff --git a/configmap/load.go b/configmap/load.go index ee40fbf0c..56ad1e4ab 100644 --- a/configmap/load.go +++ b/configmap/load.go @@ -17,7 +17,6 @@ limitations under the License. package configmap import ( - "io/ioutil" "os" "path" "path/filepath" @@ -47,7 +46,7 @@ func Load(p string) (map[string]string, error) { if info.IsDir() { return nil } - b, err := ioutil.ReadFile(p) + b, err := os.ReadFile(p) if err != nil { return err } diff --git a/configmap/load_test.go b/configmap/load_test.go index 313868457..0516b437e 100644 --- a/configmap/load_test.go +++ b/configmap/load_test.go @@ -18,7 +18,6 @@ package configmap import ( "fmt" - "io/ioutil" "os" "path" "testing" @@ -33,7 +32,7 @@ func TestLoad(t *testing.T) { "a.b.c": "blah", ".z.y.x": "hidden!", } - tmpdir, err := ioutil.TempDir("", "") + tmpdir, err := os.MkdirTemp("", "") if err != nil { t.Fatal("TempDir() =", err) } @@ -60,7 +59,7 @@ func TestLoad(t *testing.T) { // Write out the files as they should be loaded. for k, v := range want { // Write the actual file to $/.{timestamp}/key - if err := ioutil.WriteFile(path.Join(tsDir, k), []byte(v), 0644); err != nil { + if err := os.WriteFile(path.Join(tsDir, k), []byte(v), 0644); err != nil { t.Fatalf("WriteFile(..{ts}/%s) = %v", k, err) } // Symlink $/key => $/..data/key @@ -91,7 +90,7 @@ func TestLoadError(t *testing.T) { // "a.b.c": "blah", // ".z.y.x": "hidden!", // } -// tmpdir, err := ioutil.TempDir("", "") +// tmpdir, err := os.MkdirTemp("", "") // if err != nil { // t.Fatal("TempDir() =", err) // } @@ -99,7 +98,7 @@ func TestLoadError(t *testing.T) { // // Write out the files as write-only, so we fail reading. // for k, v := range written { -// err := ioutil.WriteFile(path.Join(tmpdir, k), []byte(v), 0200) +// err := os.WriteFile(path.Join(tmpdir, k), []byte(v), 0200) // if err != nil { // t.Fatalf("WriteFile(%q) = %v", k, err) // } @@ -111,7 +110,7 @@ func TestLoadError(t *testing.T) { // } func TestReadSymlinkedFileError(t *testing.T) { - tmpdir, err := ioutil.TempDir("", "") + tmpdir, err := os.MkdirTemp("", "") if err != nil { t.Fatal("TempDir() =", err) } diff --git a/configmap/testing/configmap.go b/configmap/testing/configmap.go index 909036892..58cf9a21b 100644 --- a/configmap/testing/configmap.go +++ b/configmap/testing/configmap.go @@ -18,7 +18,7 @@ package testing import ( "fmt" - "io/ioutil" + "os" "strings" "testing" "unicode" @@ -45,7 +45,7 @@ func ConfigMapFromTestFile(t testing.TB, name string, allowed ...string) *corev1 func ConfigMapsFromTestFile(t testing.TB, name string, allowed ...string) (*corev1.ConfigMap, *corev1.ConfigMap) { t.Helper() - b, err := ioutil.ReadFile(fmt.Sprintf("testdata/%s.yaml", name)) + b, err := os.ReadFile(fmt.Sprintf("testdata/%s.yaml", name)) if err != nil { t.Fatal("ReadFile() =", err) } diff --git a/go.mod b/go.mod index f219f383f..9e727d4af 100644 --- a/go.mod +++ b/go.mod @@ -49,6 +49,7 @@ require ( k8s.io/code-generator v0.24.4 k8s.io/gengo v0.0.0-20220613173612-397b4ae3bce7 k8s.io/klog/v2 v2.70.2-0.20220707122935-0990e81f1a8f + k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 knative.dev/hack v0.0.0-20220908170219-36b2b3c7a245 sigs.k8s.io/yaml v1.3.0 ) @@ -103,7 +104,6 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42 // indirect - k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect ) diff --git a/metrics/client_test.go b/metrics/client_test.go index ba6de4557..9ad2ac958 100644 --- a/metrics/client_test.go +++ b/metrics/client_test.go @@ -18,7 +18,7 @@ package metrics import ( "bytes" - "io/ioutil" + "io" "net/http" "net/url" "testing" @@ -96,7 +96,7 @@ func TestClientMetrics(t *testing.T) { stub := ClientFunc(func(req *http.Request) (*http.Response, error) { return &http.Response{ StatusCode: http.StatusOK, - Body: ioutil.NopCloser(bytes.NewBufferString("hi")), + Body: io.NopCloser(bytes.NewBufferString("hi")), }, nil }) diff --git a/metrics/e2e_test.go b/metrics/e2e_test.go index 627062065..67ea352c3 100644 --- a/metrics/e2e_test.go +++ b/metrics/e2e_test.go @@ -21,7 +21,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net" "net/http" "sort" @@ -166,7 +165,7 @@ func TestMetricsExport(t *testing.T) { t.Fatalf("failed to fetch prometheus metrics: %+v", err) } defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { t.Fatalf("failed to read prometheus response: %+v", err) } diff --git a/metrics/opencensus_exporter_test.go b/metrics/opencensus_exporter_test.go index d827b7d93..a642f2802 100644 --- a/metrics/opencensus_exporter_test.go +++ b/metrics/opencensus_exporter_test.go @@ -15,8 +15,8 @@ package metrics import ( "crypto/tls" "fmt" - "io/ioutil" "net" + "os" "path/filepath" "testing" @@ -31,11 +31,11 @@ import ( ) func TestOpenCensusConfig(t *testing.T) { - cert, err := ioutil.ReadFile(filepath.Join("testdata", "client-cert.pem")) + cert, err := os.ReadFile(filepath.Join("testdata", "client-cert.pem")) if err != nil { t.Fatal("Couldn't find testdata/client-cert.pem:", err) } - key, err := ioutil.ReadFile(filepath.Join("testdata", "client-key.pem")) + key, err := os.ReadFile(filepath.Join("testdata", "client-key.pem")) if err != nil { t.Fatal("Couldn't find testdata/client-key.pem:", err) } diff --git a/metrics/resource_view.go b/metrics/resource_view.go index 236fd588b..69e4ab435 100644 --- a/metrics/resource_view.go +++ b/metrics/resource_view.go @@ -29,7 +29,7 @@ import ( "go.opencensus.io/stats" "go.opencensus.io/stats/view" "go.opencensus.io/tag" - "k8s.io/apimachinery/pkg/util/clock" + "k8s.io/utils/clock" ) type storedViews struct { @@ -53,7 +53,7 @@ type meters struct { meters map[string]*meterExporter factory ResourceExporterFactory lock sync.Mutex - clock clock.Clock + clock clock.WithTicker ticker clock.Ticker tickerStopChan chan struct{} } @@ -65,7 +65,7 @@ var ( resourceViews = storedViews{} allMeters = meters{ meters: map[string]*meterExporter{"": &defaultMeter}, - clock: clock.Clock(clock.RealClock{}), + clock: clock.RealClock{}, } cleanupOnce = new(sync.Once) diff --git a/metrics/resource_view_test.go b/metrics/resource_view_test.go index 52ac8df5d..f80486657 100644 --- a/metrics/resource_view_test.go +++ b/metrics/resource_view_test.go @@ -24,8 +24,8 @@ import ( "go.opencensus.io/resource" "go.opencensus.io/stats" "go.opencensus.io/stats/view" - "k8s.io/apimachinery/pkg/util/clock" "k8s.io/apimachinery/pkg/util/wait" + testingclock "k8s.io/utils/clock/testing" ) var ( @@ -129,8 +129,8 @@ func TestSetFactory(t *testing.T) { } func TestAllMetersExpiration(t *testing.T) { - allMeters.clock = clock.Clock(clock.NewFakeClock(time.Now())) - fakeClock := allMeters.clock.(*clock.FakeClock) + fakeClock := testingclock.NewFakeClock(time.Now()) + allMeters.clock = fakeClock ClearMetersForTest() // t+0m // Add resource123 @@ -199,8 +199,8 @@ func TestAllMetersExpiration(t *testing.T) { } func TestIfAllMeterResourcesAreRemoved(t *testing.T) { - allMeters.clock = clock.Clock(clock.NewFakeClock(time.Now())) - fakeClock := allMeters.clock.(*clock.FakeClock) + fakeClock := testingclock.NewFakeClock(time.Now()) + allMeters.clock = fakeClock ClearMetersForTest() // t+0m // Register many resources at once for i := 1; i <= 100; i++ { diff --git a/network/error_handler.go b/network/error_handler.go index 763766489..d0b6beedc 100644 --- a/network/error_handler.go +++ b/network/error_handler.go @@ -17,8 +17,8 @@ limitations under the License. package network import ( - "io/ioutil" "net/http" + "os" "go.uber.org/zap" ) @@ -36,7 +36,7 @@ func ErrorHandler(logger *zap.SugaredLogger) func(http.ResponseWriter, *http.Req } func readSockStat(logger *zap.SugaredLogger) string { - b, err := ioutil.ReadFile("/proc/net/sockstat") + b, err := os.ReadFile("/proc/net/sockstat") if err != nil { logger.Errorw("Unable to read sockstat", zap.Error(err)) return "" diff --git a/test/cleanup_test.go b/test/cleanup_test.go index 96f888548..e90ac5a34 100644 --- a/test/cleanup_test.go +++ b/test/cleanup_test.go @@ -20,7 +20,6 @@ import ( "bytes" "errors" "fmt" - "io/ioutil" "os" "os/exec" "strings" @@ -43,8 +42,7 @@ func TestCleanupOnInterrupt(t *testing.T) { return } - // TODO: Move to os.CreateTemp when we adopt 1.16 more widely - readyFile, err := ioutil.TempFile("", "") + readyFile, err := os.CreateTemp("", "") if err != nil { t.Fatalf("failed to setup tests") } diff --git a/test/gcs/gcs.go b/test/gcs/gcs.go index d39652f50..380548d5f 100644 --- a/test/gcs/gcs.go +++ b/test/gcs/gcs.go @@ -21,7 +21,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "os" "path" "strings" @@ -223,7 +222,7 @@ func (g *GCSClient) ReadObject(ctx context.Context, bucketName, objPath string) return contents, err } defer f.Close() - return ioutil.ReadAll(f) + return io.ReadAll(f) } // NewReader creates a new Reader of a gcs file. diff --git a/test/gcs/mock/mock.go b/test/gcs/mock/mock.go index 3113f026d..7ee63f3dc 100644 --- a/test/gcs/mock/mock.go +++ b/test/gcs/mock/mock.go @@ -18,7 +18,6 @@ package mock import ( "context" - "io/ioutil" "os" "path/filepath" "strings" @@ -434,7 +433,7 @@ func (c *clientMocker) Upload(ctx context.Context, bkt, objPath, filePath string return NewNoObjectError(bkt, objName, dir) } - content, err := ioutil.ReadFile(filePath) + content, err := os.ReadFile(filePath) if err != nil { return err } diff --git a/test/gcs/mock/mock_test.go b/test/gcs/mock/mock_test.go index 395398445..40eb77743 100644 --- a/test/gcs/mock/mock_test.go +++ b/test/gcs/mock/mock_test.go @@ -21,7 +21,6 @@ import ( "context" "errors" "fmt" - "io/ioutil" "os" "path" "reflect" @@ -971,7 +970,7 @@ func TestDownload(t *testing.T) { return } - fileContent, err := ioutil.ReadFile(file) + fileContent, err := os.ReadFile(file) if err != nil { t.Fatalf("cannot read content %v, error %v", file, err) } @@ -989,7 +988,7 @@ func TestUpload(t *testing.T) { project1 := "test-project1" object1 := "dir/object1" file := "test/upload" - content, err := ioutil.ReadFile(file) + content, err := os.ReadFile(file) if err != nil { t.Fatalf("cannot read content %v, error %v", file, err) } diff --git a/test/ghutil/client.go b/test/ghutil/client.go index 8c14509f1..2dc162e0b 100644 --- a/test/ghutil/client.go +++ b/test/ghutil/client.go @@ -22,8 +22,8 @@ import ( "context" "errors" "fmt" - "io/ioutil" "log" + "os" "strings" "time" @@ -73,7 +73,7 @@ type GithubClient struct { // NewGithubClient explicitly authenticates to github with giving token and returns a handle func NewGithubClient(tokenFilePath string) (*GithubClient, error) { - b, err := ioutil.ReadFile(tokenFilePath) + b, err := os.ReadFile(tokenFilePath) if err != nil { return nil, err } diff --git a/test/interactive/docker.go b/test/interactive/docker.go index 3b295921f..290918034 100644 --- a/test/interactive/docker.go +++ b/test/interactive/docker.go @@ -19,7 +19,6 @@ package interactive import ( "fmt" - "io/ioutil" "log" "os" "path" @@ -82,7 +81,7 @@ func (d *Docker) AddMount(typeStr, source, target string, optAdditionalArgs ...s // Returns a function to clean up the mount (but does not delete the directory). // Uses sudo and probably only works on Linux func (d *Docker) AddRWOverlay(externalDirectory, internalDirectory string) func() { - tmpDir, err := ioutil.TempDir("", "overlay") + tmpDir, err := os.MkdirTemp("", "overlay") if err != nil { log.Fatal(err) } diff --git a/test/logstream/v2/stream_test.go b/test/logstream/v2/stream_test.go index 4244adc0e..63fdee858 100644 --- a/test/logstream/v2/stream_test.go +++ b/test/logstream/v2/stream_test.go @@ -20,7 +20,7 @@ import ( "context" "errors" "fmt" - "io/ioutil" + "io" "net/http" "strings" "testing" @@ -385,7 +385,7 @@ func (f *fakePods) GetLogs(podName string, opts *corev1.PodLogOptions) *restclie Client: fakerest.CreateHTTPClient(func(request *http.Request) (*http.Response, error) { resp := &http.Response{ StatusCode: http.StatusOK, - Body: ioutil.NopCloser( + Body: io.NopCloser( strings.NewReader(logsForContainer(opts.Container))), } return resp, nil diff --git a/test/mako/config/benchmark.go b/test/mako/config/benchmark.go index 3ddff5cdd..64f1a812c 100644 --- a/test/mako/config/benchmark.go +++ b/test/mako/config/benchmark.go @@ -18,7 +18,6 @@ package config import ( "fmt" - "io/ioutil" "log" "os" "path/filepath" @@ -49,7 +48,7 @@ func getBenchmark() (*mpb.BenchmarkInfo, error) { // Read the Mako config file for this environment. data, koerr := readFileFromKoData(env + ".config") if koerr != nil { - data, err = ioutil.ReadFile(filepath.Join(configMako, env+".config")) + data, err = os.ReadFile(filepath.Join(configMako, env+".config")) if err != nil { //nolint: errorlint // It's fine not to wrap here. return nil, fmt.Errorf("cannot load both from kodata and from config mako config map: %s, %s", koerr.Error(), err.Error()) @@ -72,5 +71,5 @@ func readFileFromKoData(name string) ([]byte, error) { return nil, fmt.Errorf("%q does not exist or is empty", koDataPathEnvName) } fullFilename := filepath.Join(koDataPath, name) - return ioutil.ReadFile(fullFilename) + return os.ReadFile(fullFilename) } diff --git a/test/slackutil/http.go b/test/slackutil/http.go index 072860ff3..41577c9d3 100644 --- a/test/slackutil/http.go +++ b/test/slackutil/http.go @@ -20,7 +20,7 @@ package slackutil import ( "fmt" - "io/ioutil" + "io" "net/http" "net/url" ) @@ -49,5 +49,5 @@ func handleResponse(resp *http.Response) ([]byte, error) { if resp.StatusCode != http.StatusOK { return nil, fmt.Errorf("http response code is not StatusOK: '%v'", resp.StatusCode) } - return ioutil.ReadAll(resp.Body) + return io.ReadAll(resp.Body) } diff --git a/test/slackutil/message_read.go b/test/slackutil/message_read.go index fe13126b0..6feeb52f8 100644 --- a/test/slackutil/message_read.go +++ b/test/slackutil/message_read.go @@ -22,8 +22,8 @@ import ( "encoding/json" "fmt" "html" - "io/ioutil" "net/url" + "os" "strconv" "strings" "time" @@ -44,7 +44,7 @@ type readClient struct { // NewReadClient reads token file and stores it for later authentication func NewReadClient(userName, tokenPath string) (ReadOperations, error) { - b, err := ioutil.ReadFile(tokenPath) + b, err := os.ReadFile(tokenPath) if err != nil { return nil, err } diff --git a/test/slackutil/message_write.go b/test/slackutil/message_write.go index 6c0413cd5..eefd17d8b 100644 --- a/test/slackutil/message_write.go +++ b/test/slackutil/message_write.go @@ -21,7 +21,7 @@ package slackutil import ( "encoding/json" "fmt" - "io/ioutil" + "os" "strings" "net/url" @@ -42,7 +42,7 @@ type writeClient struct { // NewWriteClient reads token file and stores it for later authentication func NewWriteClient(userName, tokenPath string) (WriteOperations, error) { - b, err := ioutil.ReadFile(tokenPath) + b, err := os.ReadFile(tokenPath) if err != nil { return nil, err } diff --git a/test/spoof/spoof.go b/test/spoof/spoof.go index 147a64adc..789d4bd68 100644 --- a/test/spoof/spoof.go +++ b/test/spoof/spoof.go @@ -23,7 +23,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net" "net/http" "net/url" @@ -188,7 +187,7 @@ func (sc *SpoofingClient) Poll(req *http.Request, inState ResponseChecker, check } defer rawResp.Body.Close() - body, err := ioutil.ReadAll(rawResp.Body) + body, err := io.ReadAll(rawResp.Body) if err != nil { return true, err } diff --git a/test/upgrade/execute_failures_test.go b/test/upgrade/execute_failures_test.go index cd5a19ddc..a11448f07 100644 --- a/test/upgrade/execute_failures_test.go +++ b/test/upgrade/execute_failures_test.go @@ -18,7 +18,7 @@ package upgrade_test import ( "fmt" - "io/ioutil" + "io" "os" "testing" @@ -89,6 +89,6 @@ func captureStdOutput(call func()) string { call() _ = w.Close() - out, _ := ioutil.ReadAll(r) + out, _ := io.ReadAll(r) return string(out) } diff --git a/test/zipkin/util.go b/test/zipkin/util.go index 5e9cb5feb..481dddb42 100644 --- a/test/zipkin/util.go +++ b/test/zipkin/util.go @@ -22,7 +22,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "strconv" @@ -226,7 +226,7 @@ func jsonTrace(traceID string) ([]model.SpanModel, error) { } defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return empty, err } diff --git a/vendor/k8s.io/apimachinery/pkg/util/clock/clock.go b/vendor/k8s.io/apimachinery/pkg/util/clock/clock.go deleted file mode 100644 index ff97612df..000000000 --- a/vendor/k8s.io/apimachinery/pkg/util/clock/clock.go +++ /dev/null @@ -1,86 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package clock - -import ( - "time" - - clocks "k8s.io/utils/clock" - testclocks "k8s.io/utils/clock/testing" -) - -// PassiveClock allows for injecting fake or real clocks into code -// that needs to read the current time but does not support scheduling -// activity in the future. -// -// Deprecated: Use k8s.io/utils/clock.PassiveClock instead. -type PassiveClock = clocks.PassiveClock - -// Clock allows for injecting fake or real clocks into code that -// needs to do arbitrary things based on time. -// -// Deprecated: Use k8s.io/utils/clock.WithTickerAndDelayedExecution instead. -type Clock = clocks.WithTickerAndDelayedExecution - -// Deprecated: Use k8s.io/utils/clock.RealClock instead. -type RealClock = clocks.RealClock - -// FakePassiveClock implements PassiveClock, but returns an arbitrary time. -// -// Deprecated: Use k8s.io/utils/clock/testing.FakePassiveClock instead. -type FakePassiveClock = testclocks.FakePassiveClock - -// FakeClock implements Clock, but returns an arbitrary time. -// -// Deprecated: Use k8s.io/utils/clock/testing.FakeClock instead. -type FakeClock = testclocks.FakeClock - -// NewFakePassiveClock returns a new FakePassiveClock. -// -// Deprecated: Use k8s.io/utils/clock/testing.NewFakePassiveClock instead. -func NewFakePassiveClock(t time.Time) *testclocks.FakePassiveClock { - return testclocks.NewFakePassiveClock(t) -} - -// NewFakeClock returns a new FakeClock. -// -// Deprecated: Use k8s.io/utils/clock/testing.NewFakeClock instead. -func NewFakeClock(t time.Time) *testclocks.FakeClock { - return testclocks.NewFakeClock(t) -} - -// IntervalClock implements Clock, but each invocation of Now steps -// the clock forward the specified duration. -// -// WARNING: most of the Clock methods just `panic`; -// only PassiveClock is honestly implemented. -// The alternative, SimpleIntervalClock, has only the -// PassiveClock methods. -// -// Deprecated: Use k8s.io/utils/clock/testing.SimpleIntervalClock instead. -type IntervalClock = testclocks.IntervalClock - -// Timer allows for injecting fake or real timers into code that -// needs to do arbitrary things based on time. -// -// Deprecated: Use k8s.io/utils/clock.Timer instead. -type Timer = clocks.Timer - -// Ticker defines the Ticker interface. -// -// Deprecated: Use k8s.io/utils/clock.Ticker instead. -type Ticker = clocks.Ticker diff --git a/vendor/modules.txt b/vendor/modules.txt index 63fc60b0e..021d422d4 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -719,7 +719,6 @@ k8s.io/apimachinery/pkg/runtime/serializer/versioning k8s.io/apimachinery/pkg/selection k8s.io/apimachinery/pkg/types k8s.io/apimachinery/pkg/util/cache -k8s.io/apimachinery/pkg/util/clock k8s.io/apimachinery/pkg/util/diff k8s.io/apimachinery/pkg/util/errors k8s.io/apimachinery/pkg/util/framer diff --git a/webhook/admission_integration_test.go b/webhook/admission_integration_test.go index caf176097..ae4305997 100644 --- a/webhook/admission_integration_test.go +++ b/webhook/admission_integration_test.go @@ -19,7 +19,7 @@ import ( "bytes" "context" "encoding/json" - "io/ioutil" + "io" "net/http" "net/url" "path" @@ -180,7 +180,7 @@ func TestAdmissionValidResponseForResourceTLS(t *testing.T) { } defer response.Body.Close() - responseBody, err := ioutil.ReadAll(response.Body) + responseBody, err := io.ReadAll(response.Body) if err != nil { t.Error("Failed to read response body", err) return @@ -305,7 +305,7 @@ func TestAdmissionValidResponseForResource(t *testing.T) { } defer response.Body.Close() - responseBody, err := ioutil.ReadAll(response.Body) + responseBody, err := io.ReadAll(response.Body) if err != nil { t.Error("Failed to read response body", err) return @@ -434,7 +434,7 @@ func TestAdmissionInvalidResponseForResource(t *testing.T) { } defer response.Body.Close() - respBody, err := ioutil.ReadAll(response.Body) + respBody, err := io.ReadAll(response.Body) if err != nil { t.Fatal("Failed to read response body", err) } @@ -551,7 +551,7 @@ func TestAdmissionWarningResponseForResource(t *testing.T) { } defer response.Body.Close() - respBody, err := ioutil.ReadAll(response.Body) + respBody, err := io.ReadAll(response.Body) if err != nil { t.Fatal("Failed to read response body", err) } @@ -656,7 +656,7 @@ func TestAdmissionValidResponseForRequestBody(t *testing.T) { } defer response.Body.Close() - responseBody, err := ioutil.ReadAll(response.Body) + responseBody, err := io.ReadAll(response.Body) if err != nil { t.Error("Failed to read response body", err) return diff --git a/webhook/conversion_integration_test.go b/webhook/conversion_integration_test.go index 56aeb4f66..3b99d0091 100644 --- a/webhook/conversion_integration_test.go +++ b/webhook/conversion_integration_test.go @@ -21,7 +21,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "testing" @@ -123,7 +123,7 @@ func TestConversionValidResponse(t *testing.T) { t.Errorf("Response status code = %v, wanted %v", got, want) } - responseBody, err := ioutil.ReadAll(response.Body) + responseBody, err := io.ReadAll(response.Body) if err != nil { t.Fatal("Failed to read response body", err) } @@ -212,7 +212,7 @@ func TestConversionInvalidResponse(t *testing.T) { t.Errorf("Response status code = %v, wanted %v", got, want) } - responseBody, err := ioutil.ReadAll(response.Body) + responseBody, err := io.ReadAll(response.Body) if err != nil { t.Fatal("Failed to read response body", err) } diff --git a/webhook/webhook_integration_test.go b/webhook/webhook_integration_test.go index fd5b0626a..b81b2f4eb 100644 --- a/webhook/webhook_integration_test.go +++ b/webhook/webhook_integration_test.go @@ -19,7 +19,7 @@ package webhook import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "strings" "testing" @@ -91,7 +91,7 @@ func TestMissingContentType(t *testing.T) { } defer response.Body.Close() - responseBody, err := ioutil.ReadAll(response.Body) + responseBody, err := io.ReadAll(response.Body) if err != nil { t.Fatal("Failed to read response body", err) } @@ -147,7 +147,7 @@ func testEmptyRequestBody(t *testing.T, controller interface{}) { } defer response.Body.Close() - responseBody, err := ioutil.ReadAll(response.Body) + responseBody, err := io.ReadAll(response.Body) if err != nil { t.Fatal("Failed to read response body", err) } diff --git a/websocket/connection.go b/websocket/connection.go index 601ee951d..6aa1e6109 100644 --- a/websocket/connection.go +++ b/websocket/connection.go @@ -22,7 +22,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http/httputil" "sync" "time" @@ -302,7 +301,7 @@ func (c *ManagedConnection) read() error { // and if that channel is set. // TODO(markusthoemmes): Return the messageType along with the payload. if c.messageChan != nil && (messageType == websocket.TextMessage || messageType == websocket.BinaryMessage) { - if message, _ := ioutil.ReadAll(reader); message != nil { + if message, _ := io.ReadAll(reader); message != nil { c.messageChan <- message } }