diff --git a/staging/src/k8s.io/controller-manager/pkg/leadermigration/config/config.go b/staging/src/k8s.io/controller-manager/pkg/leadermigration/config/config.go index 460c4ec9d91..fc8cf17141a 100644 --- a/staging/src/k8s.io/controller-manager/pkg/leadermigration/config/config.go +++ b/staging/src/k8s.io/controller-manager/pkg/leadermigration/config/config.go @@ -18,7 +18,7 @@ package config import ( "fmt" - "io/ioutil" + "os" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/serializer" @@ -59,7 +59,7 @@ func init() { // The parsed LeaderMigrationConfiguration may be invalid. // It returns an error if the file did not exist. func ReadLeaderMigrationConfiguration(configFilePath string) (*internal.LeaderMigrationConfiguration, error) { - data, err := ioutil.ReadFile(configFilePath) + data, err := os.ReadFile(configFilePath) if err != nil { return nil, fmt.Errorf("unable to read leader migration configuration from %q: %w", configFilePath, err) } diff --git a/staging/src/k8s.io/controller-manager/pkg/leadermigration/config/config_test.go b/staging/src/k8s.io/controller-manager/pkg/leadermigration/config/config_test.go index 076d9fdac29..07b3c430478 100644 --- a/staging/src/k8s.io/controller-manager/pkg/leadermigration/config/config_test.go +++ b/staging/src/k8s.io/controller-manager/pkg/leadermigration/config/config_test.go @@ -17,7 +17,6 @@ limitations under the License. package config import ( - "io/ioutil" "os" "reflect" "testing" @@ -114,12 +113,12 @@ controllerLeaders: for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - configFile, err := ioutil.TempFile("", tc.name) + configFile, err := os.CreateTemp("", tc.name) if err != nil { t.Fatal(err) } defer os.Remove(configFile.Name()) - err = ioutil.WriteFile(configFile.Name(), []byte(tc.content), os.FileMode(0755)) + err = os.WriteFile(configFile.Name(), []byte(tc.content), os.FileMode(0755)) if err != nil { t.Fatal(err) } diff --git a/staging/src/k8s.io/controller-manager/pkg/leadermigration/options/options_test.go b/staging/src/k8s.io/controller-manager/pkg/leadermigration/options/options_test.go index 05c58e98c53..f78be12adc8 100644 --- a/staging/src/k8s.io/controller-manager/pkg/leadermigration/options/options_test.go +++ b/staging/src/k8s.io/controller-manager/pkg/leadermigration/options/options_test.go @@ -17,7 +17,6 @@ limitations under the License. package options import ( - "io/ioutil" "os" "reflect" "testing" @@ -185,12 +184,12 @@ controllerLeaders: t.Run(tc.name, func(t *testing.T) { flags := tc.flags if tc.configContent != "" { - configFile, err := ioutil.TempFile("", tc.name) + configFile, err := os.CreateTemp("", tc.name) if err != nil { t.Fatal(err) } defer os.Remove(configFile.Name()) - err = ioutil.WriteFile(configFile.Name(), []byte(tc.configContent), os.FileMode(0755)) + err = os.WriteFile(configFile.Name(), []byte(tc.configContent), os.FileMode(0755)) if err != nil { t.Fatal(err) }