Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove refs to deprecated io/ioutil #496

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions command/dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package command

import (
"fmt"
"io/ioutil"
"io"
"os"
"strings"

Expand Down Expand Up @@ -96,9 +96,9 @@ func (c *DispatchCommand) Run(args []string) int {
if len(args) == 2 {
switch args[1] {
case "-":
payload, readErr = ioutil.ReadAll(os.Stdin)
payload, readErr = io.ReadAll(os.Stdin)
default:
payload, readErr = ioutil.ReadFile(args[1])
payload, readErr = os.ReadFile(args[1])
}
if readErr != nil {
c.UI.Error(fmt.Sprintf("Error reading input data: %v", readErr))
Expand Down
5 changes: 2 additions & 3 deletions helper/files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package helper

import (
"io/ioutil"
"os"
"reflect"
"testing"
Expand Down Expand Up @@ -32,7 +31,7 @@ func TestHelper_GetDefaultTmplFile(t *testing.T) {

// Use write file as tmpfile adds a prefix which doesn't work with the
// GetDefaultTmplFile function.
err := ioutil.WriteFile(f, d1, 0600)
err := os.WriteFile(f, d1, 0600)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -70,7 +69,7 @@ func TestHelper_GetDefaultVarFile(t *testing.T) {

// Use write file as tmpfile adds a prefix which doesn't work with the
// GetDefaultTmplFile function.
err := ioutil.WriteFile(tc.VarFile, d1, 0600)
err := os.WriteFile(tc.VarFile, d1, 0600)
if err != nil {
t.Fatal(err)
}
Expand Down
3 changes: 1 addition & 2 deletions template/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"reflect"
"strconv"
Expand Down Expand Up @@ -298,7 +297,7 @@ func fileContents() func(string) (string, error) {
if s == "" {
return "", nil
}
contents, err := ioutil.ReadFile(s)
contents, err := os.ReadFile(s)
if err != nil {
return "", err
}
Expand Down
8 changes: 4 additions & 4 deletions template/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path"

"github.com/hashicorp/levant/client"
Expand Down Expand Up @@ -85,7 +85,7 @@ func RenderTemplate(templateFile string, variableFiles []string, addr string, fl
}
}

src, err := ioutil.ReadFile(t.jobTemplateFile)
src, err := os.ReadFile(t.jobTemplateFile)
if err != nil {
return
}
Expand All @@ -103,7 +103,7 @@ func RenderTemplate(templateFile string, variableFiles []string, addr string, fl

func (t *tmpl) parseJSONVars(variableFile string) (variables map[string]interface{}, err error) {

jsonFile, err := ioutil.ReadFile(variableFile)
jsonFile, err := os.ReadFile(variableFile)
if err != nil {
return
}
Expand Down Expand Up @@ -136,7 +136,7 @@ func (t *tmpl) parseTFVars(variableFile string) (map[string]interface{}, error)

func (t *tmpl) parseYAMLVars(variableFile string) (variables map[string]interface{}, err error) {

yamlFile, err := ioutil.ReadFile(variableFile)
yamlFile, err := os.ReadFile(variableFile)
if err != nil {
return
}
Expand Down