Remove 99% of deprecated ioutil usage

Signed-off-by: David Gageot <david.gageot@docker.com>
This commit is contained in:
David Gageot
2022-10-07 20:28:10 +02:00
parent 8ef4fa3483
commit d4e132021a
21 changed files with 78 additions and 89 deletions

View File

@@ -3,7 +3,6 @@ package main
import (
"encoding/json"
"flag"
"io/ioutil"
"os"
"path"
"strconv"
@@ -160,7 +159,7 @@ func main() {
log.Printf("Error during metadata probe: %s", err)
}
err = ioutil.WriteFile(path.Join(ConfigPath, "provider"), []byte(p.String()), 0644)
err = os.WriteFile(path.Join(ConfigPath, "provider"), []byte(p.String()), 0644)
if err != nil {
log.Printf("Error writing metadata provider: %s", err)
}
@@ -173,7 +172,7 @@ func main() {
// Handle setting the hostname as a special case. We want to
// do this early and don't really want another container for it.
hostname, err := ioutil.ReadFile(path.Join(ConfigPath, Hostname))
hostname, err := os.ReadFile(path.Join(ConfigPath, Hostname))
if err == nil {
err := syscall.Sethostname(hostname)
if err != nil {
@@ -196,7 +195,7 @@ func main() {
// Will create foobar/foo with mode 0644 and content "hello"
func processUserData(basePath string, data []byte) error {
// Always write the raw data to a file
err := ioutil.WriteFile(path.Join(basePath, "userdata"), data, 0644)
err := os.WriteFile(path.Join(basePath, "userdata"), data, 0644)
if err != nil {
log.Printf("Could not write userdata: %s", err)
return err
@@ -223,7 +222,7 @@ func writeConfigFiles(target string, current Entry) {
log.Printf("Failed to parse permission %+v: %s", current, err)
return
}
if err := ioutil.WriteFile(target, []byte(*current.Content), filemode); err != nil {
if err := os.WriteFile(target, []byte(*current.Content), filemode); err != nil {
log.Printf("Failed to write %s: %s", target, err)
return
}

View File

@@ -3,14 +3,13 @@ package main
import (
"bytes"
"encoding/json"
"io/ioutil"
"os"
"path"
"testing"
)
func TestSampleConfig(t *testing.T) {
basePath, err := ioutil.TempDir("", "metadata")
basePath, err := os.MkdirTemp("", "metadata")
if err != nil {
t.Fatalf("can't make a temp rootdir %v", err)
}
@@ -82,7 +81,7 @@ func TestSerialization(t *testing.T) {
}
func TestWriteSingleFile(t *testing.T) {
basePath, err := ioutil.TempDir(os.TempDir(), "metadata")
basePath, err := os.MkdirTemp(os.TempDir(), "metadata")
if err != nil {
t.Fatalf("can't make a temp rootdir %v", err)
}
@@ -98,7 +97,7 @@ func TestWriteSingleFile(t *testing.T) {
}
func TestWriteEmptyFile(t *testing.T) {
basePath, err := ioutil.TempDir(os.TempDir(), "metadata")
basePath, err := os.MkdirTemp(os.TempDir(), "metadata")
if err != nil {
t.Fatalf("can't make a temp rootdir %v", err)
}
@@ -114,7 +113,7 @@ func TestWriteEmptyFile(t *testing.T) {
}
func TestWriteEmptyDirectory(t *testing.T) {
basePath, err := ioutil.TempDir(os.TempDir(), "metadata")
basePath, err := os.MkdirTemp(os.TempDir(), "metadata")
if err != nil {
t.Fatalf("can't make a temp rootdir %v", err)
}
@@ -132,7 +131,7 @@ func TestWriteEmptyDirectory(t *testing.T) {
}
func TestSetPermission(t *testing.T) {
basePath, err := ioutil.TempDir(os.TempDir(), "metadata")
basePath, err := os.MkdirTemp(os.TempDir(), "metadata")
if err != nil {
t.Fatalf("can't make a temp rootdir %v", err)
}
@@ -155,7 +154,7 @@ func TestSetPermission(t *testing.T) {
}
func TestDeepTree(t *testing.T) {
basePath, err := ioutil.TempDir("", "metadata")
basePath, err := os.MkdirTemp("", "metadata")
if err != nil {
t.Fatalf("can't make a temp rootdir %v", err)
}
@@ -207,7 +206,7 @@ func assertPermission(t *testing.T, path string, expected os.FileMode) {
}
func assertContent(t *testing.T, path, expected string) {
file, err := ioutil.ReadFile(path)
file, err := os.ReadFile(path)
if err != nil {
t.Fatalf("can't read %v: %v", path, err)
}

View File

@@ -2,7 +2,7 @@ package main
import (
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
@@ -37,7 +37,7 @@ func (p *ProviderAWS) 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("AWS: Failed to write hostname: %s", err)
}
@@ -79,7 +79,7 @@ func (p *ProviderAWS) Extract() ([]byte, error) {
func awsMetaGet(lookupName string, fileName string, fileMode os.FileMode) {
if lookupValue, err := awsGet(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("AWS: Failed to write %s:%s %s", fileName, lookupValue, err)
@@ -108,7 +108,7 @@ func awsGet(url string) ([]byte, error) {
if resp.StatusCode != 200 {
return nil, fmt.Errorf("AWS: 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("AWS: Failed to read http response: %s", err)
}
@@ -126,7 +126,7 @@ func (p *ProviderAWS) 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)
}

View File

@@ -2,7 +2,7 @@ package main
import (
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
"strings"
@@ -100,14 +100,14 @@ func FindCIs() []string {
// NewCDROM returns a new ProviderCDROM
func NewCDROM(device string) *ProviderCDROM {
mountPoint, err := ioutil.TempDir("", "cd")
mountPoint, err := os.MkdirTemp("", "cd")
p := ProviderCDROM{device, mountPoint, err, []byte{}, []byte{}}
if err == nil {
if p.err = p.mount(); p.err == nil {
// read the userdata - we read the spec file and the fallback, but eventually
// will remove the fallback
for _, f := range userdataFiles {
userdata, err := ioutil.ReadFile(path.Join(p.mountPoint, f))
userdata, err := os.ReadFile(path.Join(p.mountPoint, f))
// did we find a file?
if err == nil && userdata != nil {
p.userdata = userdata
@@ -118,7 +118,7 @@ func NewCDROM(device string) *ProviderCDROM {
p.err = fmt.Errorf("no userdata file found at any of %v", userdataFiles)
}
// read the metadata
metadata, err := ioutil.ReadFile(path.Join(p.mountPoint, metadataFile))
metadata, err := os.ReadFile(path.Join(p.mountPoint, metadataFile))
// did we find a file?
if err == nil && metadata != nil {
p.metadata = metadata

View File

@@ -2,7 +2,7 @@ package main
import (
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
@@ -41,7 +41,7 @@ func (p *ProviderDigitalOcean) 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("DigitalOcean: Failed to write hostname: %s", err)
}
@@ -77,7 +77,7 @@ func (p *ProviderDigitalOcean) Extract() ([]byte, error) {
func digitalOceanMetaGet(lookupName string, fileName string, fileMode os.FileMode) {
if lookupValue, err := digitalOceanGet(digitalOceanMetaDataURL + 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("DigitalOcean: Failed to write %s:%s %s", fileName, lookupValue, err)
@@ -106,7 +106,7 @@ func digitalOceanGet(url string) ([]byte, error) {
if resp.StatusCode != 200 {
return nil, fmt.Errorf("DigitalOcean: 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("DigitalOcean: Failed to read http response: %s", err)
}
@@ -124,7 +124,7 @@ func (p *ProviderDigitalOcean) 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)
}

View File

@@ -1,7 +1,6 @@
package main
import (
"io/ioutil"
"os"
)
@@ -17,5 +16,5 @@ func (p fileProvider) Probe() bool {
}
func (p fileProvider) Extract() ([]byte, error) {
return ioutil.ReadFile(string(p))
return os.ReadFile(string(p))
}

View File

@@ -2,7 +2,7 @@ package main
import (
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
@@ -43,7 +43,7 @@ func (p *ProviderGCP) 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("GCP: Failed to write hostname: %s", err)
}
@@ -81,7 +81,7 @@ func gcpGet(url string) ([]byte, error) {
if resp.StatusCode != 200 {
return nil, fmt.Errorf("GCP: 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("GCP: Failed to read http response: %s", err)
}
@@ -116,7 +116,7 @@ func (p *ProviderGCP) handleSSH() error {
rootKeys = rootKeys + parts[1] + "\n"
}
}
err = ioutil.WriteFile(path.Join(ConfigPath, SSH, "authorized_keys"), []byte(rootKeys), 0600)
err = os.WriteFile(path.Join(ConfigPath, SSH, "authorized_keys"), []byte(rootKeys), 0600)
if err != nil {
return fmt.Errorf("Failed to write ssh keys: %s", err)
}

View File

@@ -3,7 +3,7 @@ package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
@@ -38,7 +38,7 @@ func (p *ProviderHetzner) 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("Hetzner: Failed to write hostname: %s", err)
}
@@ -74,7 +74,7 @@ func (p *ProviderHetzner) Extract() ([]byte, error) {
func hetznerMetaGet(lookupName string, fileName string, fileMode os.FileMode) {
if lookupValue, err := hetznerGet(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("Hetzner: Failed to write %s:%s %s", fileName, lookupValue, err)
@@ -103,7 +103,7 @@ func hetznerGet(url string) ([]byte, error) {
if resp.StatusCode != 200 {
return nil, fmt.Errorf("Hetzner: 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("Hetzner: Failed to read http response: %s", err)
}

View File

@@ -2,7 +2,7 @@ package main
import (
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
@@ -43,7 +43,7 @@ func (p *ProviderMetaldata) 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("Metaldata: Failed to write hostname: %s", err)
}
@@ -82,7 +82,7 @@ func (p *ProviderMetaldata) Extract() ([]byte, error) {
func metaldataMetaGet(lookupName string, fileName string, fileMode os.FileMode) {
if lookupValue, err := metaldataGet(metaldataMetaDataURL + 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("Metaldata: Failed to write %s:%s %s", fileName, lookupValue, err)
@@ -111,7 +111,7 @@ func metaldataGet(url string) ([]byte, error) {
if resp.StatusCode != 200 {
return nil, fmt.Errorf("Metaldata: 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("Metaldata: Failed to read http response: %s", err)
}
@@ -129,7 +129,7 @@ func (p *ProviderMetaldata) 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)
}

View File

@@ -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)
}

View File

@@ -2,7 +2,6 @@ package main
import (
"fmt"
"io/ioutil"
"net"
"os"
"path"
@@ -47,7 +46,7 @@ func (p *ProviderPacket) Extract() ([]byte, error) {
return nil, p.err
}
if err := ioutil.WriteFile(path.Join(ConfigPath, Hostname), []byte(p.metadata.Hostname), 0644); err != nil {
if err := os.WriteFile(path.Join(ConfigPath, Hostname), []byte(p.metadata.Hostname), 0644); err != nil {
return nil, fmt.Errorf("Packet: Failed to write hostname: %s", err)
}
@@ -57,7 +56,7 @@ func (p *ProviderPacket) Extract() ([]byte, error) {
sshKeys := strings.Join(p.metadata.SSHKeys, "\n")
if err := ioutil.WriteFile(path.Join(ConfigPath, SSH, "authorized_keys"), []byte(sshKeys), 0600); err != nil {
if err := os.WriteFile(path.Join(ConfigPath, SSH, "authorized_keys"), []byte(sshKeys), 0600); err != nil {
return nil, fmt.Errorf("Failed to write ssh keys: %s", err)
}
@@ -125,7 +124,7 @@ func networkConfig(ni metadata.NetworkInfo) error {
// weirdly creating a bind always seems to return EEXIST
fmt.Fprintf(os.Stderr, "Error adding bond0: %v (ignoring)", err)
}
if err := ioutil.WriteFile("/sys/class/net/bond0/bonding/mode", []byte(strconv.Itoa(int(ni.Bonding.Mode))), 0); err != nil {
if err := os.WriteFile("/sys/class/net/bond0/bonding/mode", []byte(strconv.Itoa(int(ni.Bonding.Mode))), 0); err != nil {
return fmt.Errorf("Cannot write to /sys/class/net/bond0/bonding/mode: %v", err)
}
if err := netlink.LinkSetUp(bond); err != nil {

View File

@@ -5,7 +5,7 @@ import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"io"
"log"
"net"
"net/http"
@@ -62,7 +62,7 @@ func (p *ProviderScaleway) Extract() ([]byte, error) {
return nil, fmt.Errorf("Scaleway: Failed to get hostname: %s", 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("Scaleway: Failed to write hostname: %s", err)
}
@@ -72,7 +72,7 @@ func (p *ProviderScaleway) Extract() ([]byte, error) {
return nil, fmt.Errorf("Scaleway: Failed to get instanceID: %s", err)
}
err = ioutil.WriteFile(path.Join(ConfigPath, instanceIDFile), instanceID, 0644)
err = os.WriteFile(path.Join(ConfigPath, instanceIDFile), instanceID, 0644)
if err != nil {
return nil, fmt.Errorf("Scaleway: Failed to write instance_id: %s", err)
}
@@ -82,7 +82,7 @@ func (p *ProviderScaleway) Extract() ([]byte, error) {
return nil, fmt.Errorf("Scaleway: Failed to get instanceLocation: %s", err)
}
err = ioutil.WriteFile(path.Join(ConfigPath, instanceLocationFile), instanceLocation, 0644)
err = os.WriteFile(path.Join(ConfigPath, instanceLocationFile), instanceLocation, 0644)
if err != nil {
return nil, fmt.Errorf("Scaleway: Failed to write instance_location: %s", err)
}
@@ -92,7 +92,7 @@ func (p *ProviderScaleway) Extract() ([]byte, error) {
// not an error
log.Printf("Scaleway: Failed to get publicIP: %s", err)
} else {
err = ioutil.WriteFile(path.Join(ConfigPath, publicIPFile), publicIP, 0644)
err = os.WriteFile(path.Join(ConfigPath, publicIPFile), publicIP, 0644)
if err != nil {
return nil, fmt.Errorf("Scaleway: Failed to write public_ip: %s", err)
}
@@ -104,7 +104,7 @@ func (p *ProviderScaleway) Extract() ([]byte, error) {
return nil, fmt.Errorf("Scaleway: Failed to get privateIP: %s", err)
}
err = ioutil.WriteFile(path.Join(ConfigPath, privateIPFile), privateIP, 0644)
err = os.WriteFile(path.Join(ConfigPath, privateIPFile), privateIP, 0644)
if err != nil {
return nil, fmt.Errorf("Scaleway: Failed to write private_ip: %s", err)
}
@@ -152,7 +152,7 @@ func scalewayGet(url string) ([]byte, error) {
if resp.StatusCode != 200 {
return nil, fmt.Errorf("Scaleway: 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("Scaleway: Failed to read http response: %s", err)
}
@@ -192,7 +192,7 @@ func scalewayGetUserdata() ([]byte, error) {
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
@@ -225,7 +225,7 @@ func (p *ProviderScaleway) handleSSH(metadata []byte) error {
return fmt.Errorf("Failed to create %s: %s", SSH, err)
}
err = ioutil.WriteFile(path.Join(ConfigPath, SSH, "authorized_keys"), []byte(rootKeys), 0600)
err = os.WriteFile(path.Join(ConfigPath, SSH, "authorized_keys"), []byte(rootKeys), 0600)
if err != nil {
return fmt.Errorf("Failed to write ssh keys: %s", err)
}

View File

@@ -2,7 +2,7 @@ package main
import (
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
@@ -41,7 +41,7 @@ func (p *ProviderVultr) 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("Vultr: Failed to write hostname: %s", err)
}
@@ -73,7 +73,7 @@ func (p *ProviderVultr) Extract() ([]byte, error) {
func vultrMetaGet(lookupName string, fileName string, fileMode os.FileMode) {
if lookupValue, err := vultrGet(vultrMetaDataURL + 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("Vultr: Failed to write %s:%s %s", fileName, lookupValue, err)
@@ -102,7 +102,7 @@ func vultrGet(url string) ([]byte, error) {
if resp.StatusCode != 200 {
return nil, fmt.Errorf("Vultr: 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("Vultr: Failed to read http response: %s", err)
}
@@ -120,7 +120,7 @@ func (p *ProviderVultr) 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)
}