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

Replace deprecated ioutil calls #308

Merged
merged 1 commit into from
Feb 17, 2024
Merged
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
4 changes: 2 additions & 2 deletions cmd/config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cmd

import (
"io/ioutil"
"os"

log "github.com/sirupsen/logrus"

Expand Down Expand Up @@ -70,7 +70,7 @@ type AutoplanConfig struct {
// in to preserve some parts of the old config
func readOldConfig() (*AtlantisConfig, error) {
// The old file not existing is not an error, as it should not exist on the very first run
bytes, err := ioutil.ReadFile(outputPath)
bytes, err := os.ReadFile(outputPath)
if err != nil {
log.Info("Could not find an old config file. Starting from scratch")
return nil, nil
Expand Down
5 changes: 2 additions & 3 deletions cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"golang.org/x/sync/singleflight"

"context"
"io/ioutil"
"os"
"path/filepath"
"runtime"
Expand Down Expand Up @@ -880,7 +879,7 @@ func main(cmd *cobra.Command, args []string) error {

// Write output
if len(outputPath) != 0 {
ioutil.WriteFile(outputPath, []byte(yamlString), 0644)
os.WriteFile(outputPath, []byte(yamlString), 0644)
} else {
log.Println(yamlString)
}
Expand Down Expand Up @@ -958,5 +957,5 @@ func RunWithFlags(filename string, args []string) ([]byte, error) {
rootCmd.SetArgs(args)
rootCmd.Execute()

return ioutil.ReadFile(filename)
return os.ReadFile(filename)
}
11 changes: 5 additions & 6 deletions cmd/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmd

import (
"fmt"
"io/ioutil"
"math/rand"
"os"
"path/filepath"
Expand Down Expand Up @@ -74,7 +73,7 @@ func runTest(t *testing.T, goldenFile string, args []string) {
return
}

goldenContentsBytes, err := ioutil.ReadFile(goldenFile)
goldenContentsBytes, err := os.ReadFile(goldenFile)
goldenContents := &AtlantisConfig{}
yaml.Unmarshal(goldenContentsBytes, goldenContents)
if err != nil {
Expand Down Expand Up @@ -331,7 +330,7 @@ func TestPreservingOldWorkflows(t *testing.T) {
steps:
- run: terragrunt plan -no-color -out $PLANFILE
`)
ioutil.WriteFile(filename, contents, 0644)
os.WriteFile(filename, contents, 0644)

content, err := RunWithFlags(filename, []string{
"generate",
Expand All @@ -345,7 +344,7 @@ func TestPreservingOldWorkflows(t *testing.T) {
return
}

goldenContents, err := ioutil.ReadFile(filepath.Join("golden", "oldWorkflowsPreserved.yaml"))
goldenContents, err := os.ReadFile(filepath.Join("golden", "oldWorkflowsPreserved.yaml"))
if err != nil {
t.Error("Failed to read golden file")
return
Expand Down Expand Up @@ -377,7 +376,7 @@ func TestPreservingOldProjects(t *testing.T) {
dir: someDir
name: projectFromPreviousRun
`)
ioutil.WriteFile(filename, contents, 0644)
os.WriteFile(filename, contents, 0644)

content, err := RunWithFlags(filename, []string{
"generate",
Expand All @@ -392,7 +391,7 @@ func TestPreservingOldProjects(t *testing.T) {
return
}

goldenContents, err := ioutil.ReadFile(filepath.Join("golden", "oldProjectsPreserved.yaml"))
goldenContents, err := os.ReadFile(filepath.Join("golden", "oldProjectsPreserved.yaml"))
if err != nil {
t.Error("Failed to read golden file")
return
Expand Down
Loading