diff --git a/pkg/test/istioio/framework.go b/pkg/test/istioio/framework.go index c22c428858..80ae766f9b 100644 --- a/pkg/test/istioio/framework.go +++ b/pkg/test/istioio/framework.go @@ -1,14 +1,14 @@ +// Copyright 2020 Istio Authors +// // Package istioio includes the framework for doc testing. This package will // first scan through all the docs to collect their information, and then // setup istio as appropriate to run each test. // -// Copyright 2020 Istio 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 +// 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, @@ -19,7 +19,6 @@ package istioio import ( "fmt" - "io/ioutil" "os" "path/filepath" "regexp" @@ -123,7 +122,7 @@ func checkFile(path string) (*TestCase, error) { testCase := &TestCase{path: shortPath} // read the script file - script, err := ioutil.ReadFile(path) + script, err := os.ReadFile(path) if err != nil { return testCase, err } diff --git a/pkg/test/istioio/script.go b/pkg/test/istioio/script.go index b35d5ec822..2a48e4f0b1 100644 --- a/pkg/test/istioio/script.go +++ b/pkg/test/istioio/script.go @@ -17,7 +17,6 @@ package istioio import ( "bufio" "fmt" - "io/ioutil" "os" "os/exec" "path" @@ -45,16 +44,15 @@ var _ Step = Script{} // // To simplify common tasks, the following environment variables are set when the script is executed: // -// - TEST_OUTPUT_DIR: -// Set to the working directory of the current test. By default, scripts are run from this -// directory. This variable is useful for cases where the execution `WorkDir` has been set, -// but the script needs to access files in the test working directory. -// - TEST_DEBUG_FILE: -// Set to the file where debugging output will be written. -// - KUBECONFIG: -// Set to the value from the test framework. This is necessary to make kubectl commands execute -// with the configuration specified on the command line. -// +// - TEST_OUTPUT_DIR: +// Set to the working directory of the current test. By default, scripts are run from this +// directory. This variable is useful for cases where the execution `WorkDir` has been set, +// but the script needs to access files in the test working directory. +// - TEST_DEBUG_FILE: +// Set to the file where debugging output will be written. +// - KUBECONFIG: +// Set to the value from the test framework. This is necessary to make kubectl commands execute +// with the configuration specified on the command line. type Script struct { // Input for the parser. Input Input @@ -89,7 +87,7 @@ func (s Script) run(ctx framework.TestContext) { // Copy the command to workDir. _, fileName := filepath.Split(s.Name()) - if err := ioutil.WriteFile(path.Join(ctx.WorkDir(), fileName), []byte(command), 0o644); err != nil { + if err := os.WriteFile(path.Join(ctx.WorkDir(), fileName), []byte(command), 0o644); err != nil { ctx.Fatalf("failed copying command %s to workDir: %v", s.Name(), err) } diff --git a/pkg/test/istioio/snapshot_validator.go b/pkg/test/istioio/snapshot_validator.go index 5836f6abca..842036859e 100644 --- a/pkg/test/istioio/snapshot_validator.go +++ b/pkg/test/istioio/snapshot_validator.go @@ -16,7 +16,6 @@ package istioio import ( "fmt" - "io/ioutil" "os" "path/filepath" "time" @@ -54,7 +53,7 @@ func (s SnapshotValidator) run(ctx framework.TestContext) { return } - inBeforeBytes, err := ioutil.ReadFile(inBeforeFile) + inBeforeBytes, err := os.ReadFile(inBeforeFile) if err != nil { ctx.Fatalf("failed reading before snapshot: %v", err) } @@ -62,7 +61,7 @@ func (s SnapshotValidator) run(ctx framework.TestContext) { // Copy the before file to the current working directory to aid debugging. inBeforeFileCopy := filepath.Join(ctx.WorkDir(), filepath.Base(inBeforeFile)) - if err := ioutil.WriteFile(inBeforeFileCopy, inBeforeBytes, os.ModePerm); err != nil { + if err := os.WriteFile(inBeforeFileCopy, inBeforeBytes, os.ModePerm); err != nil { ctx.Fatalf("failed copying before snapshot: %v", err) } @@ -92,8 +91,8 @@ func (s SnapshotValidator) run(ctx framework.TestContext) { return nil, true, err } - if err := ioutil.WriteFile(diffFile, []byte(diffText), os.ModePerm); err != nil { - // Fatal error, shouldn't happen + if err := os.WriteFile(diffFile, []byte(diffText), os.ModePerm); err != nil { + // Fatal os.shouldn't happen return nil, true, err } diff --git a/pkg/test/istioio/snapshotter.go b/pkg/test/istioio/snapshotter.go index 6342c32b69..3afd9c0236 100644 --- a/pkg/test/istioio/snapshotter.go +++ b/pkg/test/istioio/snapshotter.go @@ -15,7 +15,6 @@ package istioio import ( - "io/ioutil" "os" "path/filepath" @@ -59,7 +58,7 @@ func (s *Snapshotter) run(ctx framework.TestContext) { } outputFile := filepath.Join(ctx.WorkDir(), s.StepName+".json") - if err := ioutil.WriteFile(outputFile, []byte(snapshotJSON), os.ModePerm); err != nil { + if err := os.WriteFile(outputFile, []byte(snapshotJSON), os.ModePerm); err != nil { ctx.Fatal("failed writing snapshot file: %v", err) } diff --git a/tests/setup/multicluster/doc_test.go b/tests/setup/multicluster/doc_test.go index 3fcf5930eb..11ca5c3abb 100644 --- a/tests/setup/multicluster/doc_test.go +++ b/tests/setup/multicluster/doc_test.go @@ -4,7 +4,7 @@ // 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 +// 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, diff --git a/tests/setup/profile_default/doc_test.go b/tests/setup/profile_default/doc_test.go index 9f64fe9ee0..12024c1a72 100644 --- a/tests/setup/profile_default/doc_test.go +++ b/tests/setup/profile_default/doc_test.go @@ -4,7 +4,7 @@ // 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 +// 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, diff --git a/tests/setup/profile_demo/doc_test.go b/tests/setup/profile_demo/doc_test.go index 60b538606a..a71058cdbf 100644 --- a/tests/setup/profile_demo/doc_test.go +++ b/tests/setup/profile_demo/doc_test.go @@ -4,7 +4,7 @@ // 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 +// 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, diff --git a/tests/setup/profile_none/doc_test.go b/tests/setup/profile_none/doc_test.go index 5cbdefe13f..02fda5001e 100644 --- a/tests/setup/profile_none/doc_test.go +++ b/tests/setup/profile_none/doc_test.go @@ -4,7 +4,7 @@ // 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 +// 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,