diff --git a/pkg/termination/write.go b/pkg/termination/write.go index 8be6a74ffa8..3ddae367131 100644 --- a/pkg/termination/write.go +++ b/pkg/termination/write.go @@ -18,7 +18,6 @@ package termination import ( "encoding/json" - "io/ioutil" "os" v1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" @@ -34,7 +33,7 @@ const ( func WriteMessage(path string, pro []v1beta1.PipelineResourceResult) error { // if the file at path exists, concatenate the new values otherwise create it // file at path already exists - fileContents, err := ioutil.ReadFile(path) + fileContents, err := os.ReadFile(path) if err == nil { var existingEntries []v1beta1.PipelineResourceResult if err := json.Unmarshal(fileContents, &existingEntries); err == nil { diff --git a/pkg/termination/write_test.go b/pkg/termination/write_test.go index 3ba07468cce..3dded19a17c 100644 --- a/pkg/termination/write_test.go +++ b/pkg/termination/write_test.go @@ -17,7 +17,6 @@ package termination import ( "errors" - "io/ioutil" "log" "os" "strings" @@ -30,7 +29,7 @@ import ( ) func TestExistingFile(t *testing.T) { - tmpFile, err := ioutil.TempFile(os.TempDir(), "tempFile") + tmpFile, err := os.CreateTemp(os.TempDir(), "tempFile") if err != nil { log.Fatal("Cannot create temporary file", err) } @@ -59,7 +58,7 @@ func TestExistingFile(t *testing.T) { logger.Fatalf("Errot while writing message: %s", err) } - if fileContents, err := ioutil.ReadFile(tmpFile.Name()); err != nil { + if fileContents, err := os.ReadFile(tmpFile.Name()); err != nil { logger.Fatalf("Unexpected error reading %v: %v", tmpFile.Name(), err) } else { want := `[{"key":"key1","value":"hello"},{"key":"key2","value":"world"}]` @@ -71,7 +70,7 @@ func TestExistingFile(t *testing.T) { func TestMaxSizeFile(t *testing.T) { value := strings.Repeat("a", 4096) - tmpFile, err := ioutil.TempFile(os.TempDir(), "tempFile") + tmpFile, err := os.CreateTemp(os.TempDir(), "tempFile") if err != nil { log.Fatal("Cannot create temporary file", err) }