mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-11-03 18:46:21 +00:00
Remove 99% of deprecated ioutil usage
Signed-off-by: David Gageot <david.gageot@docker.com>
This commit is contained in:
@@ -2,7 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -37,7 +37,7 @@ func (p *ProviderOpenstack) Extract() ([]byte, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = ioutil.WriteFile(path.Join(ConfigPath, Hostname), hostname, 0644)
|
||||
err = os.WriteFile(path.Join(ConfigPath, Hostname), hostname, 0644)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("OpenStack: Failed to write hostname: %s", err)
|
||||
}
|
||||
@@ -79,7 +79,7 @@ func (p *ProviderOpenstack) Extract() ([]byte, error) {
|
||||
func openstackMetaGet(lookupName string, fileName string, fileMode os.FileMode) {
|
||||
if lookupValue, err := openstackGet(metaDataURL + lookupName); err == nil {
|
||||
// we got a value from the metadata server, now save to filesystem
|
||||
err = ioutil.WriteFile(path.Join(ConfigPath, fileName), lookupValue, fileMode)
|
||||
err = os.WriteFile(path.Join(ConfigPath, fileName), lookupValue, fileMode)
|
||||
if err != nil {
|
||||
// we couldn't save the file for some reason
|
||||
log.Printf("OpenStack: Failed to write %s:%s %s", fileName, lookupValue, err)
|
||||
@@ -108,7 +108,7 @@ func openstackGet(url string) ([]byte, error) {
|
||||
if resp.StatusCode != 200 {
|
||||
return nil, fmt.Errorf("OpenStack: Status not ok: %d", resp.StatusCode)
|
||||
}
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("OpenStack: Failed to read http response: %s", err)
|
||||
}
|
||||
@@ -126,7 +126,7 @@ func (p *ProviderOpenstack) handleSSH() error {
|
||||
return fmt.Errorf("Failed to create %s: %s", SSH, err)
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(path.Join(ConfigPath, SSH, "authorized_keys"), sshKeys, 0600)
|
||||
err = os.WriteFile(path.Join(ConfigPath, SSH, "authorized_keys"), sshKeys, 0600)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to write ssh keys: %s", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user