mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
Stop using deprecated ioutil functions
This commit is contained in:
@@ -5,7 +5,7 @@ package commands
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -88,11 +88,11 @@ func TestAnnotateCommand(t *testing.T) {
|
||||
func initTestDir(t *testing.T) string {
|
||||
t.Helper()
|
||||
d := t.TempDir()
|
||||
err := ioutil.WriteFile(filepath.Join(d, "f1.yaml"), []byte(f1Input), 0600)
|
||||
err := os.WriteFile(filepath.Join(d, "f1.yaml"), []byte(f1Input), 0600)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(d, "f2.yaml"), []byte(f2Input), 0600)
|
||||
err = os.WriteFile(filepath.Join(d, "f2.yaml"), []byte(f2Input), 0600)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ package commands_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -22,7 +21,7 @@ import (
|
||||
func TestCmd_files(t *testing.T) {
|
||||
d := t.TempDir()
|
||||
|
||||
err := ioutil.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
err := os.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
@@ -45,7 +44,7 @@ spec:
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`
|
||||
err = os.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`
|
||||
apiVersion: v1
|
||||
kind: Abstraction
|
||||
metadata:
|
||||
@@ -119,7 +118,7 @@ spec:
|
||||
func TestCmd_filesWithReconcilers(t *testing.T) {
|
||||
d := t.TempDir()
|
||||
|
||||
err := ioutil.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
err := os.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
@@ -142,7 +141,7 @@ spec:
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`
|
||||
err = os.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`
|
||||
apiVersion: v1
|
||||
kind: Abstraction
|
||||
metadata:
|
||||
@@ -225,7 +224,7 @@ spec:
|
||||
func TestCmd_filesWithoutNonReconcilers(t *testing.T) {
|
||||
d := t.TempDir()
|
||||
|
||||
err := ioutil.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
err := os.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
@@ -248,7 +247,7 @@ spec:
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`
|
||||
err = os.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`
|
||||
apiVersion: v1
|
||||
kind: Abstraction
|
||||
metadata:
|
||||
@@ -303,7 +302,7 @@ spec:
|
||||
func TestCmd_outputTruncateFile(t *testing.T) {
|
||||
d := t.TempDir()
|
||||
|
||||
err := ioutil.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
err := os.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
@@ -326,7 +325,7 @@ spec:
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`
|
||||
err = os.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`
|
||||
apiVersion: v1
|
||||
kind: Abstraction
|
||||
metadata:
|
||||
@@ -353,7 +352,7 @@ spec:
|
||||
return
|
||||
}
|
||||
|
||||
f, err := ioutil.TempFile("", "kustomize-cat-test-dest")
|
||||
f, err := os.CreateTemp("", "kustomize-cat-test-dest")
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
@@ -372,7 +371,7 @@ spec:
|
||||
return
|
||||
}
|
||||
|
||||
actual, err := ioutil.ReadFile(f.Name())
|
||||
actual, err := os.ReadFile(f.Name())
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
@@ -413,7 +412,7 @@ spec:
|
||||
func TestCmd_outputCreateFile(t *testing.T) {
|
||||
d := t.TempDir()
|
||||
|
||||
err := ioutil.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
err := os.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
@@ -436,7 +435,7 @@ spec:
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`
|
||||
err = os.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`
|
||||
apiVersion: v1
|
||||
kind: Abstraction
|
||||
metadata:
|
||||
@@ -479,7 +478,7 @@ spec:
|
||||
return
|
||||
}
|
||||
|
||||
actual, err := ioutil.ReadFile(f)
|
||||
actual, err := os.ReadFile(f)
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
@@ -213,7 +213,7 @@ func schemaFromFile(schemaPath string) (*spec.Schema, error) {
|
||||
if schemaPath == "" {
|
||||
return sc, nil
|
||||
}
|
||||
sch, err := ioutil.ReadFile(schemaPath)
|
||||
sch, err := os.ReadFile(schemaPath)
|
||||
if err != nil {
|
||||
return sc, err
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ package commands_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -702,13 +701,13 @@ spec:
|
||||
baseDir := t.TempDir()
|
||||
|
||||
f := filepath.Join(baseDir, "Krmfile")
|
||||
err := ioutil.WriteFile(f, []byte(test.inputOpenAPI), 0600)
|
||||
err := os.WriteFile(f, []byte(test.inputOpenAPI), 0600)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
if test.schema != "" {
|
||||
sch, err := ioutil.TempFile("", "schema.json")
|
||||
sch, err := os.CreateTemp("", "schema.json")
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -717,7 +716,7 @@ spec:
|
||||
os.Remove(sch.Name())
|
||||
})
|
||||
|
||||
err = ioutil.WriteFile(sch.Name(), []byte(test.schema), 0600)
|
||||
err = os.WriteFile(sch.Name(), []byte(test.schema), 0600)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -725,12 +724,12 @@ spec:
|
||||
test.args = append(test.args, "--schema-path", sch.Name())
|
||||
}
|
||||
|
||||
r, err := ioutil.TempFile(baseDir, "k8s-cli-*.yaml")
|
||||
r, err := os.CreateTemp(baseDir, "k8s-cli-*.yaml")
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
t.Cleanup(func() { r.Close() })
|
||||
err = ioutil.WriteFile(r.Name(), []byte(test.input), 0600)
|
||||
err = os.WriteFile(r.Name(), []byte(test.input), 0600)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -763,7 +762,7 @@ spec:
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
actualResources, err := ioutil.ReadFile(r.Name())
|
||||
actualResources, err := os.ReadFile(r.Name())
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -773,7 +772,7 @@ spec:
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
actualOpenAPI, err := ioutil.ReadFile(f)
|
||||
actualOpenAPI, err := os.ReadFile(f)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ package commands_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -356,17 +356,17 @@ spec:
|
||||
|
||||
baseDir := t.TempDir()
|
||||
f := filepath.Join(baseDir, "Krmfile")
|
||||
err := ioutil.WriteFile(f, []byte(test.inputOpenAPI), 0600)
|
||||
err := os.WriteFile(f, []byte(test.inputOpenAPI), 0600)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
r, err := ioutil.TempFile(baseDir, "k8s-cli-*.yaml")
|
||||
r, err := os.CreateTemp(baseDir, "k8s-cli-*.yaml")
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
t.Cleanup(func() { r.Close() })
|
||||
err = ioutil.WriteFile(r.Name(), []byte(test.input), 0600)
|
||||
err = os.WriteFile(r.Name(), []byte(test.input), 0600)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -399,7 +399,7 @@ spec:
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
actualResources, err := ioutil.ReadFile(r.Name())
|
||||
actualResources, err := os.ReadFile(r.Name())
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -409,7 +409,7 @@ spec:
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
actualOpenAPI, err := ioutil.ReadFile(f)
|
||||
actualOpenAPI, err := os.ReadFile(f)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ package commands_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -302,17 +302,17 @@ kind: Deployment
|
||||
|
||||
baseDir := t.TempDir()
|
||||
f := filepath.Join(baseDir, "Krmfile")
|
||||
err := ioutil.WriteFile(f, []byte(test.inputOpenAPI), 0600)
|
||||
err := os.WriteFile(f, []byte(test.inputOpenAPI), 0600)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
r, err := ioutil.TempFile(baseDir, "k8s-cli-*.yaml")
|
||||
r, err := os.CreateTemp(baseDir, "k8s-cli-*.yaml")
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
t.Cleanup(func() { r.Close() })
|
||||
err = ioutil.WriteFile(r.Name(), []byte(test.input), 0600)
|
||||
err = os.WriteFile(r.Name(), []byte(test.input), 0600)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -346,7 +346,7 @@ kind: Deployment
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
actualResources, err := ioutil.ReadFile(r.Name())
|
||||
actualResources, err := os.ReadFile(r.Name())
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -356,7 +356,7 @@ kind: Deployment
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
actualOpenAPI, err := ioutil.ReadFile(f)
|
||||
actualOpenAPI, err := os.ReadFile(f)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ package commands_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -429,17 +429,17 @@ spec:
|
||||
|
||||
baseDir := t.TempDir()
|
||||
f := filepath.Join(baseDir, "Krmfile")
|
||||
err := ioutil.WriteFile(f, []byte(test.inputOpenAPI), 0600)
|
||||
err := os.WriteFile(f, []byte(test.inputOpenAPI), 0600)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
r, err := ioutil.TempFile(baseDir, "k8s-cli-*.yaml")
|
||||
r, err := os.CreateTemp(baseDir, "k8s-cli-*.yaml")
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
t.Cleanup(func() { r.Close() })
|
||||
err = ioutil.WriteFile(r.Name(), []byte(test.input), 0600)
|
||||
err = os.WriteFile(r.Name(), []byte(test.input), 0600)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -472,7 +472,7 @@ spec:
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
actualOpenAPI, err := ioutil.ReadFile(f)
|
||||
actualOpenAPI, err := os.ReadFile(f)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -482,7 +482,7 @@ spec:
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
actualResources, err := ioutil.ReadFile(r.Name())
|
||||
actualResources, err := os.ReadFile(r.Name())
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -56,7 +55,7 @@ func (r *InitRunner) runE(c *cobra.Command, args []string) error {
|
||||
return errors.Errorf("directory already initialized with a Krmfile")
|
||||
}
|
||||
|
||||
return ioutil.WriteFile(filename, []byte(strings.TrimSpace(`
|
||||
return os.WriteFile(filename, []byte(strings.TrimSpace(`
|
||||
apiVersion: config.k8s.io/v1alpha1
|
||||
kind: Krmfile
|
||||
`)), 0600)
|
||||
|
||||
@@ -5,7 +5,7 @@ package commands_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -409,12 +409,12 @@ openAPI:
|
||||
|
||||
dir := t.TempDir()
|
||||
|
||||
err := ioutil.WriteFile(filepath.Join(dir, "Krmfile"), []byte(test.openapi), 0600)
|
||||
err := os.WriteFile(filepath.Join(dir, "Krmfile"), []byte(test.openapi), 0600)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(filepath.Join(dir, "deployment.yaml"), []byte(test.input), 0600)
|
||||
err = os.WriteFile(filepath.Join(dir, "deployment.yaml"), []byte(test.input), 0600)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -433,7 +433,7 @@ openAPI:
|
||||
}
|
||||
|
||||
// make sure that the resources are not altered
|
||||
actualResources, err := ioutil.ReadFile(filepath.Join(dir, "deployment.yaml"))
|
||||
actualResources, err := os.ReadFile(filepath.Join(dir, "deployment.yaml"))
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -443,7 +443,7 @@ openAPI:
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
actualOpenAPI, err := ioutil.ReadFile(filepath.Join(dir, "Krmfile"))
|
||||
actualOpenAPI, err := os.ReadFile(filepath.Join(dir, "Krmfile"))
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ package commands_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -1000,17 +1000,17 @@ spec:
|
||||
baseDir := t.TempDir()
|
||||
|
||||
f := filepath.Join(baseDir, "Krmfile")
|
||||
err := ioutil.WriteFile(f, []byte(test.inputOpenAPI), 0600)
|
||||
err := os.WriteFile(f, []byte(test.inputOpenAPI), 0600)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
r, err := ioutil.TempFile(baseDir, "k8s-cli-*.yaml")
|
||||
r, err := os.CreateTemp(baseDir, "k8s-cli-*.yaml")
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
t.Cleanup(func() { r.Close() })
|
||||
err = ioutil.WriteFile(r.Name(), []byte(test.input), 0600)
|
||||
err = os.WriteFile(r.Name(), []byte(test.input), 0600)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -1037,7 +1037,7 @@ spec:
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
actualResources, err := ioutil.ReadFile(r.Name())
|
||||
actualResources, err := os.ReadFile(r.Name())
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -1047,7 +1047,7 @@ spec:
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
actualOpenAPI, err := ioutil.ReadFile(f)
|
||||
actualOpenAPI, err := os.ReadFile(f)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ package commands_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
func TestCountCommand_files(t *testing.T) {
|
||||
d := t.TempDir()
|
||||
|
||||
err := ioutil.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
err := os.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
@@ -42,7 +42,7 @@ spec:
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`kind: Deployment
|
||||
err = os.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx
|
||||
|
||||
@@ -6,7 +6,6 @@ package e2e
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -706,7 +705,7 @@ metadata:
|
||||
t.Skip()
|
||||
}
|
||||
|
||||
dir, err := ioutil.TempDir("", "kustomize-test-data-")
|
||||
dir, err := os.MkdirTemp("", "kustomize-test-data-")
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -715,7 +714,7 @@ metadata:
|
||||
|
||||
// write the input
|
||||
for path, data := range tt.files(binDir) {
|
||||
err := ioutil.WriteFile(path, []byte(data), 0600)
|
||||
err := os.WriteFile(path, []byte(data), 0600)
|
||||
testutil.AssertNoError(t, err)
|
||||
}
|
||||
|
||||
@@ -737,7 +736,7 @@ metadata:
|
||||
testutil.AssertNoError(t, err, stdErr.String())
|
||||
|
||||
for path, data := range tt.expectedFiles(binDir) {
|
||||
b, err := ioutil.ReadFile(path)
|
||||
b, err := os.ReadFile(path)
|
||||
testutil.AssertNoError(t, err, stdErr.String())
|
||||
|
||||
if !assert.Equal(t, strings.TrimSpace(data), strings.TrimSpace(string(b)), stdErr.String()) {
|
||||
@@ -757,7 +756,7 @@ func build() string {
|
||||
// only build the binaries once
|
||||
buildOnce.Do(func() {
|
||||
var err error
|
||||
binDir, err = ioutil.TempDir("", "kustomize-test-")
|
||||
binDir, err = os.MkdirTemp("", "kustomize-test-")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ package e2e
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -43,7 +42,7 @@ func runTests(t *testing.T, tests []test) {
|
||||
for i := range tests {
|
||||
tt := tests[i]
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
dataDir, err := ioutil.TempDir("", "kustomize-test-data-")
|
||||
dataDir, err := os.MkdirTemp("", "kustomize-test-data-")
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -52,7 +51,7 @@ func runTests(t *testing.T, tests []test) {
|
||||
|
||||
// write the input
|
||||
for path, data := range tt.files {
|
||||
err := ioutil.WriteFile(path, []byte(data), 0600)
|
||||
err := os.WriteFile(path, []byte(data), 0600)
|
||||
testutil.AssertNoError(t, err)
|
||||
}
|
||||
|
||||
@@ -79,7 +78,7 @@ func runTests(t *testing.T, tests []test) {
|
||||
}
|
||||
|
||||
for path, data := range tt.expectedFiles {
|
||||
b, err := ioutil.ReadFile(path)
|
||||
b, err := os.ReadFile(path)
|
||||
testutil.AssertNoError(t, err, stdErr.String())
|
||||
|
||||
if !assert.Equal(t, strings.TrimSpace(data), strings.TrimSpace(string(b)), stdErr.String()) {
|
||||
|
||||
@@ -5,7 +5,6 @@ package commands_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -21,22 +20,22 @@ import (
|
||||
|
||||
// TestCmd_files verifies the fmt command formats the files
|
||||
func TestFmtCommand_files(t *testing.T) {
|
||||
f1, err := ioutil.TempFile("", "cmdfmt*.yaml")
|
||||
f1, err := os.CreateTemp("", "cmdfmt*.yaml")
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
defer os.RemoveAll(f1.Name())
|
||||
err = ioutil.WriteFile(f1.Name(), testyaml.UnformattedYaml1, 0600)
|
||||
err = os.WriteFile(f1.Name(), testyaml.UnformattedYaml1, 0600)
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
f2, err := ioutil.TempFile("", "cmdfmt*.yaml")
|
||||
f2, err := os.CreateTemp("", "cmdfmt*.yaml")
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
defer os.RemoveAll(f2.Name())
|
||||
err = ioutil.WriteFile(f2.Name(), testyaml.UnformattedYaml2, 0600)
|
||||
err = os.WriteFile(f2.Name(), testyaml.UnformattedYaml2, 0600)
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
@@ -50,7 +49,7 @@ func TestFmtCommand_files(t *testing.T) {
|
||||
}
|
||||
|
||||
// verify the contents
|
||||
b, err := ioutil.ReadFile(f1.Name())
|
||||
b, err := os.ReadFile(f1.Name())
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
@@ -58,7 +57,7 @@ func TestFmtCommand_files(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
b, err = ioutil.ReadFile(f2.Name())
|
||||
b, err = os.ReadFile(f2.Name())
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
@@ -84,20 +83,20 @@ func TestFmtCommand_stdin(t *testing.T) {
|
||||
// TestCmd_filesAndstdin verifies that if both files and stdin input are provided, only
|
||||
// the files are formatted and the input is ignored
|
||||
func TestFmtCmd_filesAndStdin(t *testing.T) {
|
||||
f1, err := ioutil.TempFile("", "cmdfmt*.yaml")
|
||||
f1, err := os.CreateTemp("", "cmdfmt*.yaml")
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
err = ioutil.WriteFile(f1.Name(), testyaml.UnformattedYaml1, 0600)
|
||||
err = os.WriteFile(f1.Name(), testyaml.UnformattedYaml1, 0600)
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
f2, err := ioutil.TempFile("", "cmdfmt*.yaml")
|
||||
f2, err := os.CreateTemp("", "cmdfmt*.yaml")
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
err = ioutil.WriteFile(f2.Name(), testyaml.UnformattedYaml2, 0600)
|
||||
err = os.WriteFile(f2.Name(), testyaml.UnformattedYaml2, 0600)
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
@@ -117,7 +116,7 @@ func TestFmtCmd_filesAndStdin(t *testing.T) {
|
||||
}
|
||||
|
||||
// verify the output
|
||||
b, err := ioutil.ReadFile(f1.Name())
|
||||
b, err := os.ReadFile(f1.Name())
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
@@ -125,7 +124,7 @@ func TestFmtCmd_filesAndStdin(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
b, err = ioutil.ReadFile(f2.Name())
|
||||
b, err = os.ReadFile(f2.Name())
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ package commands_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
func TestGrepCommand_files(t *testing.T) {
|
||||
d := t.TempDir()
|
||||
|
||||
err := ioutil.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
err := os.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
@@ -42,7 +42,7 @@ spec:
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`kind: Deployment
|
||||
err = os.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx
|
||||
|
||||
@@ -5,7 +5,6 @@ package commands_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -27,7 +26,7 @@ func TestInit_args(t *testing.T) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
actual, err := ioutil.ReadFile(filepath.Join(d, "Krmfile"))
|
||||
actual, err := os.ReadFile(filepath.Join(d, "Krmfile"))
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -71,7 +70,7 @@ func TestInit_noargs(t *testing.T) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
actual, err := ioutil.ReadFile(filepath.Join(d, "Krmfile"))
|
||||
actual, err := os.ReadFile(filepath.Join(d, "Krmfile"))
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
package commands_test
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
func TestMerge3Command(t *testing.T) {
|
||||
datadir := t.TempDir()
|
||||
|
||||
err := ioutil.WriteFile(filepath.Join(datadir, "java-deployment.resource.yaml"), []byte(`apiVersion: apps/v1
|
||||
err := os.WriteFile(filepath.Join(datadir, "java-deployment.resource.yaml"), []byte(`apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: app
|
||||
@@ -58,7 +58,7 @@ spec:
|
||||
|
||||
expectedDir := t.TempDir()
|
||||
|
||||
err = ioutil.WriteFile(filepath.Join(expectedDir, "java-deployment.resource.yaml"), []byte(`apiVersion: apps/v1
|
||||
err = os.WriteFile(filepath.Join(expectedDir, "java-deployment.resource.yaml"), []byte(`apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: app
|
||||
@@ -104,7 +104,7 @@ spec:
|
||||
|
||||
updatedDir := t.TempDir()
|
||||
|
||||
err = ioutil.WriteFile(filepath.Join(updatedDir, "java-deployment.resource.yaml"), []byte(`apiVersion: apps/v1
|
||||
err = os.WriteFile(filepath.Join(updatedDir, "java-deployment.resource.yaml"), []byte(`apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: app
|
||||
@@ -147,7 +147,7 @@ spec:
|
||||
|
||||
destDir := t.TempDir()
|
||||
|
||||
err = ioutil.WriteFile(filepath.Join(destDir, "java-deployment.resource.yaml"), []byte(`apiVersion: apps/v1
|
||||
err = os.WriteFile(filepath.Join(destDir, "java-deployment.resource.yaml"), []byte(`apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: app
|
||||
|
||||
@@ -5,7 +5,7 @@ package commands_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
@@ -72,7 +72,7 @@ items:
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
actual, err := ioutil.ReadFile(filepath.Join(d, "f1.yaml"))
|
||||
actual, err := os.ReadFile(filepath.Join(d, "f1.yaml"))
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -99,7 +99,7 @@ spec:
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
actual, err = ioutil.ReadFile(filepath.Join(d, "f2.yaml"))
|
||||
actual, err = os.ReadFile(filepath.Join(d, "f2.yaml"))
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -147,7 +147,7 @@ items:
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
actual, err := ioutil.ReadFile(filepath.Join(d, "f1.json"))
|
||||
actual, err := os.ReadFile(filepath.Join(d, "f1.json"))
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ package commands_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
func TestSourceCommand(t *testing.T) {
|
||||
d := t.TempDir()
|
||||
|
||||
err := ioutil.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
err := os.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
@@ -39,7 +39,7 @@ spec:
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`
|
||||
err = os.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`
|
||||
apiVersion: v1
|
||||
kind: Abstraction
|
||||
metadata:
|
||||
@@ -141,7 +141,7 @@ items:
|
||||
func TestSourceCommandJSON(t *testing.T) {
|
||||
d := t.TempDir()
|
||||
|
||||
err := ioutil.WriteFile(filepath.Join(d, "f1.json"), []byte(`
|
||||
err := os.WriteFile(filepath.Join(d, "f1.json"), []byte(`
|
||||
{
|
||||
"kind": "Deployment",
|
||||
"metadata": {
|
||||
@@ -161,7 +161,7 @@ func TestSourceCommandJSON(t *testing.T) {
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(d, "f2.json"), []byte(`
|
||||
err = os.WriteFile(filepath.Join(d, "f2.json"), []byte(`
|
||||
{
|
||||
"apiVersion": "v1",
|
||||
"kind": "Abstraction",
|
||||
|
||||
@@ -6,7 +6,6 @@ package commands_test
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
@@ -32,7 +31,7 @@ func TestTreeCommandDefaultCurDir_files(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
err = ioutil.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
err = os.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
apiVersion: v1
|
||||
kind: Abstraction
|
||||
metadata:
|
||||
@@ -67,7 +66,7 @@ spec:
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`kind: Deployment
|
||||
err = os.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx
|
||||
@@ -103,7 +102,7 @@ spec:
|
||||
func TestTreeCommand_files(t *testing.T) {
|
||||
d := t.TempDir()
|
||||
|
||||
err := ioutil.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
err := os.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
apiVersion: v1
|
||||
kind: Abstraction
|
||||
metadata:
|
||||
@@ -138,7 +137,7 @@ spec:
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`kind: Deployment
|
||||
err = os.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx
|
||||
@@ -173,7 +172,7 @@ spec:
|
||||
func TestTreeCommand_Kustomization(t *testing.T) {
|
||||
d := t.TempDir()
|
||||
|
||||
err := ioutil.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`kind: Deployment
|
||||
err := os.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx
|
||||
@@ -187,7 +186,7 @@ spec:
|
||||
return
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(filepath.Join(d, "Kustomization"), []byte(`apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
err = os.WriteFile(filepath.Join(d, "Kustomization"), []byte(`apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
- f2.yaml
|
||||
@@ -220,7 +219,7 @@ func TestTreeCommand_subpkgs(t *testing.T) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
err = os.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
apiVersion: v1
|
||||
kind: Abstraction
|
||||
metadata:
|
||||
@@ -255,7 +254,7 @@ spec:
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(d, "subpkg", "f2.yaml"), []byte(`kind: Deployment
|
||||
err = os.WriteFile(filepath.Join(d, "subpkg", "f2.yaml"), []byte(`kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx
|
||||
@@ -269,7 +268,7 @@ spec:
|
||||
return
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(filepath.Join(d, "Krmfile"), []byte(`apiVersion: kpt.dev/v1alpha1
|
||||
err = os.WriteFile(filepath.Join(d, "Krmfile"), []byte(`apiVersion: kpt.dev/v1alpha1
|
||||
kind: Krmfile
|
||||
metadata:
|
||||
name: mainpkg
|
||||
@@ -279,7 +278,7 @@ openAPI:
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(d, "subpkg", "Krmfile"), []byte(`apiVersion: kpt.dev/v1alpha1
|
||||
err = os.WriteFile(filepath.Join(d, "subpkg", "Krmfile"), []byte(`apiVersion: kpt.dev/v1alpha1
|
||||
kind: Krmfile
|
||||
metadata:
|
||||
name: subpkg
|
||||
@@ -423,7 +422,7 @@ spec:
|
||||
func TestTreeCommand_includeReconcilers(t *testing.T) {
|
||||
d := t.TempDir()
|
||||
|
||||
err := ioutil.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
err := os.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
@@ -446,7 +445,7 @@ spec:
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`
|
||||
err = os.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`
|
||||
apiVersion: gcr.io/example/reconciler:v1
|
||||
kind: Abstraction
|
||||
metadata:
|
||||
@@ -491,7 +490,7 @@ spec:
|
||||
func TestTreeCommand_excludeNonReconcilers(t *testing.T) {
|
||||
d := t.TempDir()
|
||||
|
||||
err := ioutil.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
err := os.WriteFile(filepath.Join(d, "f1.yaml"), []byte(`
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
@@ -514,7 +513,7 @@ spec:
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`
|
||||
err = os.WriteFile(filepath.Join(d, "f2.yaml"), []byte(`
|
||||
apiVersion: v1
|
||||
kind: Abstraction
|
||||
metadata:
|
||||
|
||||
@@ -6,7 +6,6 @@ package runner
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -137,27 +136,27 @@ func createTestDirStructure(dir string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(dir, "subpkg1", "Krmfile"), []byte(""), 0644)
|
||||
err = os.WriteFile(filepath.Join(dir, "subpkg1", "Krmfile"), []byte(""), 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(dir, "subpkg2", "Krmfile"), []byte(""), 0644)
|
||||
err = os.WriteFile(filepath.Join(dir, "subpkg2", "Krmfile"), []byte(""), 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(dir, "subpkg2/subpkg3", "Krmfile"), []byte(""), 0644)
|
||||
err = os.WriteFile(filepath.Join(dir, "subpkg2/subpkg3", "Krmfile"), []byte(""), 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(dir, "subpkg4", "error.txt"), []byte(""), 0644)
|
||||
err = os.WriteFile(filepath.Join(dir, "subpkg4", "error.txt"), []byte(""), 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(dir, "subpkg4", "Krmfile"), []byte(""), 0644)
|
||||
err = os.WriteFile(filepath.Join(dir, "subpkg4", "Krmfile"), []byte(""), 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(dir, "Krmfile"), []byte(""), 0644)
|
||||
err = os.WriteFile(filepath.Join(dir, "Krmfile"), []byte(""), 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -167,7 +166,7 @@ func createTestDirStructure(dir string) error {
|
||||
type TestRunner struct{}
|
||||
|
||||
func (r *TestRunner) ExecuteCmd(w io.Writer, pkgPath string) error {
|
||||
children, err := ioutil.ReadDir(pkgPath)
|
||||
children, err := os.ReadDir(pkgPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ package repo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
@@ -68,7 +67,7 @@ func loadProtoModules(
|
||||
|
||||
func loadProtoModule(path string) (*protoModule, error) {
|
||||
mPath := filepath.Join(path, goModFile)
|
||||
content, err := ioutil.ReadFile(mPath)
|
||||
content, err := os.ReadFile(mPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error reading %q: %v\n", mPath, err)
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"sigs.k8s.io/yaml"
|
||||
)
|
||||
@@ -25,7 +25,7 @@ type PackageSpec struct {
|
||||
}
|
||||
|
||||
func ReadSpec(fileName string) *ModuleSpec {
|
||||
bytes, err := ioutil.ReadFile(fileName)
|
||||
bytes, err := os.ReadFile(fileName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
package internal_test
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
@@ -51,7 +50,7 @@ func TestReadSpec(t *testing.T) {
|
||||
|
||||
// Write content to temp file, returning file name.
|
||||
func writeFile(t *testing.T, content []byte) string {
|
||||
f, err := ioutil.TempFile("", "testjunk")
|
||||
f, err := os.CreateTemp("", "testjunk")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -68,7 +67,7 @@ func main() {
|
||||
source := os.Args[1]
|
||||
dest := os.Args[2]
|
||||
|
||||
files, err := ioutil.ReadDir(source)
|
||||
files, err := os.ReadDir(source)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||
os.Exit(1)
|
||||
@@ -79,7 +78,7 @@ func main() {
|
||||
if filepath.Ext(f.Name()) != ".md" {
|
||||
continue
|
||||
}
|
||||
b, err := ioutil.ReadFile(filepath.Join(source, f.Name()))
|
||||
b, err := os.ReadFile(filepath.Join(source, f.Name()))
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||
os.Exit(1)
|
||||
@@ -96,7 +95,7 @@ func main() {
|
||||
} else if licenseFile == "none" {
|
||||
// no license -- maybe added by another tool
|
||||
} else {
|
||||
b, err := ioutil.ReadFile(licenseFile)
|
||||
b, err := os.ReadFile(licenseFile)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||
os.Exit(1)
|
||||
@@ -117,7 +116,7 @@ package ` + filepath.Base(dest) + "\n"}
|
||||
}
|
||||
|
||||
o := strings.Join(out, "\n")
|
||||
err = ioutil.WriteFile(filepath.Join(dest, "docs.go"), []byte(o), 0600)
|
||||
err = os.WriteFile(filepath.Join(dest, "docs.go"), []byte(o), 0600)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||
os.Exit(1)
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -130,7 +130,7 @@ func (c *Converter) readEmbeddedFile(name string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
defer r.Close()
|
||||
contents, err := ioutil.ReadAll(r)
|
||||
contents, err := io.ReadAll(r)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -139,7 +139,7 @@ func (c *Converter) readEmbeddedFile(name string) (string, error) {
|
||||
}
|
||||
|
||||
func (c *Converter) readDiskFile(path string) (string, error) {
|
||||
f, err := ioutil.ReadFile(path)
|
||||
f, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -159,7 +159,7 @@ func (c *Converter) mkDstDir() error {
|
||||
func (c *Converter) write(m map[string]string) error {
|
||||
for k, v := range m {
|
||||
p := filepath.Join(c.outputDir, k)
|
||||
err := ioutil.WriteFile(p, []byte(v), 0644)
|
||||
err := os.WriteFile(p, []byte(v), 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ package krmfunction
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
@@ -116,7 +116,7 @@ func TestTransformerConverter(t *testing.T) {
|
||||
t.Skip("TODO: fix this test, which was not running in CI and does not pass")
|
||||
dir := t.TempDir()
|
||||
|
||||
err := ioutil.WriteFile(filepath.Join(dir, "Plugin.go"),
|
||||
err := os.WriteFile(filepath.Join(dir, "Plugin.go"),
|
||||
getTransformerCode(), 0644)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -214,7 +214,7 @@ func TestGeneratorConverter(t *testing.T) {
|
||||
t.Skip("TODO: fix this test, which was not running in CI and does not pass")
|
||||
dir := t.TempDir()
|
||||
|
||||
err := ioutil.WriteFile(filepath.Join(dir, "Plugin.go"),
|
||||
err := os.WriteFile(filepath.Join(dir, "Plugin.go"),
|
||||
getGeneratorCode(), 0644)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user