Skip to content

Commit

Permalink
Remove deprecated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
nlewo committed Dec 16, 2022
1 parent 36432a3 commit 3b0c0ee
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 20 deletions.
4 changes: 2 additions & 2 deletions closure/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package closure

import (
"encoding/json"
"io/ioutil"
"os"
)

type Storepath struct {
Expand All @@ -11,7 +11,7 @@ type Storepath struct {
}

func ReadClosureGraphFile(filename string) (storepaths []Storepath, err error) {
content, err := ioutil.ReadFile(filename)
content, err := os.ReadFile(filename)
if err != nil {
return
}
Expand Down
9 changes: 4 additions & 5 deletions cmd/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"runtime"

Expand Down Expand Up @@ -51,7 +50,7 @@ func imageFromDir(outputFilename, directory string) error {
if err != nil {
return err
}
err = ioutil.WriteFile(outputFilename, []byte(res), 0666)
err = os.WriteFile(outputFilename, []byte(res), 0666)
if err != nil {
return err
}
Expand All @@ -64,7 +63,7 @@ func image(outputFilename, imageConfigPath string, fromImageFilename string, lay
var image types.Image

logrus.Infof("Getting image configuration from %s", imageConfigPath)
imageConfigJson, err := ioutil.ReadFile(imageConfigPath)
imageConfigJson, err := os.ReadFile(imageConfigPath)
if err != nil {
return err
}
Expand All @@ -88,7 +87,7 @@ func image(outputFilename, imageConfigPath string, fromImageFilename string, lay
image.ImageConfig = imageConfig
for _, path := range layerPaths {
var layers []types.Layer
layerJson, err := ioutil.ReadFile(path)
layerJson, err := os.ReadFile(path)
if err != nil {
return err
}
Expand All @@ -103,7 +102,7 @@ func image(outputFilename, imageConfigPath string, fromImageFilename string, lay
if err != nil {
return err
}
err = ioutil.WriteFile(outputFilename, []byte(res), 0666)
err = os.WriteFile(outputFilename, []byte(res), 0666)
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/layers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
_ "crypto/sha512"
"encoding/json"
"fmt"
"io/ioutil"
"os"

"github.com/nlewo/nix2container/closure"
Expand Down Expand Up @@ -131,7 +130,7 @@ func layersToJson(outputFilename string, layers []types.Layer) error {
if err != nil {
return err
}
err = ioutil.WriteFile(outputFilename, []byte(res), 0666)
err = os.WriteFile(outputFilename, []byte(res), 0666)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package cmd

import (
"encoding/json"
"io/ioutil"
"os"

"github.com/nlewo/nix2container/types"
)

func readPermsFile(filename string) (permPaths []types.PermPath, err error) {
content, err := ioutil.ReadFile(filename)
content, err := os.ReadFile(filename)
if err != nil {
return permPaths, err
}
Expand All @@ -20,7 +20,7 @@ func readPermsFile(filename string) (permPaths []types.PermPath, err error) {
}

func readRewritesFile(filename string) (rewritePaths []types.RewritePath, err error) {
content, err := ioutil.ReadFile(filename)
content, err := os.ReadFile(filename)
if err != nil {
return rewritePaths, err
}
Expand Down
7 changes: 3 additions & 4 deletions nix/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"os"

"github.com/containers/image/v5/manifest"
Expand Down Expand Up @@ -105,7 +104,7 @@ func NewImageFromFile(filename string) (image types.Image, err error) {
return image, err
}
defer file.Close()
content, err := ioutil.ReadAll(file)
content, err := io.ReadAll(file)
if err != nil {
return image, err
}
Expand All @@ -125,7 +124,7 @@ func NewImageFromDir(directory string) (image types.Image, err error) {
return image, err
}
defer manifestFile.Close()
content, err := ioutil.ReadAll(manifestFile)
content, err := io.ReadAll(manifestFile)
if err != nil {
return image, err
}
Expand All @@ -135,7 +134,7 @@ func NewImageFromDir(directory string) (image types.Image, err error) {
return image, err
}

content, err = ioutil.ReadFile(directory + "/" + v1Manifest.Config.Digest.Encoded())
content, err = os.ReadFile(directory + "/" + v1Manifest.Config.Digest.Encoded())
if err != nil {
return image, err
}
Expand Down
3 changes: 1 addition & 2 deletions nix/tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"archive/tar"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"regexp"
Expand All @@ -16,7 +15,7 @@ import (
)

func TarPathsWrite(paths types.Paths, destinationDirectory string) (string, digest.Digest, int64, error) {
f, err := ioutil.TempFile(destinationDirectory, "")
f, err := os.CreateTemp(destinationDirectory, "")
if err != nil {
return "", "", 0, err
}
Expand Down
4 changes: 2 additions & 2 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package types

import (
"encoding/json"
"io/ioutil"
"io"
"os"

v1 "github.com/opencontainers/image-spec/specs-go/v1"
Expand Down Expand Up @@ -82,7 +82,7 @@ func NewLayersFromFile(filename string) ([]Layer, error) {
return nil, err
}
defer file.Close()
content, err := ioutil.ReadAll(file)
content, err := io.ReadAll(file)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 3b0c0ee

Please sign in to comment.