mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Remove ioutil from controller-manager
Signed-off-by: inosato <si17_21@yahoo.co.jp>
This commit is contained in:
parent
3902a53419
commit
dc9be06154
@ -18,7 +18,7 @@ package config
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/serializer"
|
"k8s.io/apimachinery/pkg/runtime/serializer"
|
||||||
@ -59,7 +59,7 @@ func init() {
|
|||||||
// The parsed LeaderMigrationConfiguration may be invalid.
|
// The parsed LeaderMigrationConfiguration may be invalid.
|
||||||
// It returns an error if the file did not exist.
|
// It returns an error if the file did not exist.
|
||||||
func ReadLeaderMigrationConfiguration(configFilePath string) (*internal.LeaderMigrationConfiguration, error) {
|
func ReadLeaderMigrationConfiguration(configFilePath string) (*internal.LeaderMigrationConfiguration, error) {
|
||||||
data, err := ioutil.ReadFile(configFilePath)
|
data, err := os.ReadFile(configFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to read leader migration configuration from %q: %w", configFilePath, err)
|
return nil, fmt.Errorf("unable to read leader migration configuration from %q: %w", configFilePath, err)
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
@ -114,12 +113,12 @@ controllerLeaders:
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
configFile, err := ioutil.TempFile("", tc.name)
|
configFile, err := os.CreateTemp("", tc.name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer os.Remove(configFile.Name())
|
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 {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||||||
package options
|
package options
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
@ -185,12 +184,12 @@ controllerLeaders:
|
|||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
flags := tc.flags
|
flags := tc.flags
|
||||||
if tc.configContent != "" {
|
if tc.configContent != "" {
|
||||||
configFile, err := ioutil.TempFile("", tc.name)
|
configFile, err := os.CreateTemp("", tc.name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer os.Remove(configFile.Name())
|
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 {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user