Skip to content

Commit

Permalink
client: move from io/ioutil to io and os packages
Browse files Browse the repository at this point in the history
Signed-off-by: Eng Zer Jun <[email protected]>
  • Loading branch information
Juneezee committed Oct 2, 2022
1 parent a0ed441 commit 6b101e5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
7 changes: 3 additions & 4 deletions client/lxd_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"crypto/sha256"
"fmt"
"io"
"io/ioutil"
"mime"
"mime/multipart"
"net/http"
Expand Down Expand Up @@ -417,7 +416,7 @@ func (r *ProtocolLXD) CreateImage(image api.ImagesPost, args *ImageCreateArgs) (
contentType = "application/octet-stream"
} else {
// If split image, we need mime encoding
tmpfile, err := ioutil.TempFile("", "lxc_image_")
tmpfile, err := os.CreateTemp("", "lxc_image_")
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -762,14 +761,14 @@ func (r *ProtocolLXD) CopyImage(source ImageServer, image api.Image, args *Image

// Relay mode
if args != nil && args.Mode == "relay" {
metaFile, err := ioutil.TempFile("", "lxc_image_")
metaFile, err := os.CreateTemp("", "lxc_image_")
if err != nil {
return nil, err
}

defer func() { _ = os.Remove(metaFile.Name()) }()

rootfsFile, err := ioutil.TempFile("", "lxc_image_")
rootfsFile, err := os.CreateTemp("", "lxc_image_")
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions client/lxd_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package lxd

import (
"fmt"
"io/ioutil"
"io"
"net/http"

"github.com/gorilla/websocket"
Expand Down Expand Up @@ -184,7 +184,7 @@ func (r *ProtocolLXD) GetMetrics() (string, error) {
}

// Get the content.
content, err := ioutil.ReadAll(resp.Body)
content, err := io.ReadAll(resp.Body)
if err != nil {
return "", err
}
Expand Down
5 changes: 2 additions & 3 deletions client/simplestreams_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"crypto/sha256"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -156,7 +155,7 @@ func (r *ProtocolSimpleStreams) GetImageFile(fingerprint string, req ImageFileRe
}

// Create temporary file for the delta
deltaFile, err := ioutil.TempFile("", "lxc_image_")
deltaFile, err := os.CreateTemp("", "lxc_image_")
if err != nil {
return nil, err
}
Expand All @@ -172,7 +171,7 @@ func (r *ProtocolSimpleStreams) GetImageFile(fingerprint string, req ImageFileRe
}

// Create temporary file for the delta
patchedFile, err := ioutil.TempFile("", "lxc_image_")
patchedFile, err := os.CreateTemp("", "lxc_image_")
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 6b101e5

Please sign in to comment.