diff --git a/main.go b/main.go index b2953bb6..1fbca33b 100644 --- a/main.go +++ b/main.go @@ -2,7 +2,6 @@ package main import ( "fmt" - "io/ioutil" "os" "strings" @@ -644,7 +643,7 @@ func cleanCache(c *cli.Context) { } func parseScriptOptions() *options.ChartsScriptOptions { - configYaml, err := ioutil.ReadFile(ChartsScriptOptionsFile) + configYaml, err := os.ReadFile(ChartsScriptOptionsFile) if err != nil { logrus.Fatalf("Unable to find configuration file: %s", err) } diff --git a/pkg/charts/crdchart.go b/pkg/charts/crdchart.go index b1ef0c10..242695dc 100644 --- a/pkg/charts/crdchart.go +++ b/pkg/charts/crdchart.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "io" - "io/ioutil" "os" "path/filepath" "strings" @@ -77,7 +76,7 @@ func AddCRDValidationToChart(fs billy.Filesystem, helmChartPathWithoutCRDs, helm return nil } absPath := filesystem.GetAbsPath(fs, path) - yamlFile, err := ioutil.ReadFile(absPath) + yamlFile, err := os.ReadFile(absPath) if err != nil { return fmt.Errorf("unable to read file %s: %s", absPath, err) } @@ -133,7 +132,7 @@ func AddCRDValidationToChart(fs billy.Filesystem, helmChartPathWithoutCRDs, helm validateInstallCRDsContents := fmt.Sprintf(ValidateInstallCRDContentsFmt, strings.Join(formattedCRDs, "\n")) validateInstallCRDsDestpath := filepath.Join(helmChartPathWithoutCRDs, path.ChartValidateInstallCRDFile) // Write to file - err = ioutil.WriteFile(filesystem.GetAbsPath(fs, validateInstallCRDsDestpath), []byte(validateInstallCRDsContents), os.ModePerm) + err = os.WriteFile(filesystem.GetAbsPath(fs, validateInstallCRDsDestpath), []byte(validateInstallCRDsContents), os.ModePerm) if err != nil { return fmt.Errorf("encountered error while writing into %s: %s", validateInstallCRDsDestpath, err) } diff --git a/pkg/filesystem/filesystem.go b/pkg/filesystem/filesystem.go index 3bb379ed..16f035e6 100644 --- a/pkg/filesystem/filesystem.go +++ b/pkg/filesystem/filesystem.go @@ -6,15 +6,15 @@ import ( "compress/gzip" "crypto/sha1" "fmt" - "github.com/rancher/charts-build-scripts/pkg/util" "io" - "io/ioutil" "net/http" "os" "path/filepath" "sort" "strings" + "github.com/rancher/charts-build-scripts/pkg/util" + "github.com/go-git/go-billy/v5" "github.com/go-git/go-billy/v5/osfs" "github.com/sirupsen/logrus" @@ -591,11 +591,11 @@ func CopyDir(fs billy.Filesystem, srcDir string, dstDir string) error { if isDir { return fs.MkdirAll(dstPath, os.ModePerm) } - data, err := ioutil.ReadFile(GetAbsPath(fs, srcPath)) + data, err := os.ReadFile(GetAbsPath(fs, srcPath)) if err != nil { return err } - return ioutil.WriteFile(GetAbsPath(fs, dstPath), data, os.ModePerm) + return os.WriteFile(GetAbsPath(fs, dstPath), data, os.ModePerm) }) } @@ -608,7 +608,7 @@ func MakeSubdirectoryRoot(fs billy.Filesystem, path, subdirectory string) error if !exists { return fmt.Errorf("subdirectory %s does not exist in path %s in filesystem %s", subdirectory, path, fs.Root()) } - absTempDir, err := ioutil.TempDir(fs.Root(), "make-subdirectory-root") + absTempDir, err := os.MkdirTemp(fs.Root(), "make-subdirectory-root") if err != nil { return err } diff --git a/pkg/options/package.go b/pkg/options/package.go index a9e1d774..2f3529dd 100644 --- a/pkg/options/package.go +++ b/pkg/options/package.go @@ -2,7 +2,6 @@ package options import ( "fmt" - "io/ioutil" "os" "github.com/go-git/go-billy/v5" @@ -105,7 +104,7 @@ func LoadPackageOptionsFromFile(fs billy.Filesystem, path string) (PackageOption if !exists { return packageOptions, fmt.Errorf("unable to load package options from file %s since it does not exist", filesystem.GetAbsPath(fs, path)) } - chartOptionsBytes, err := ioutil.ReadFile(filesystem.GetAbsPath(fs, path)) + chartOptionsBytes, err := os.ReadFile(filesystem.GetAbsPath(fs, path)) if err != nil { return packageOptions, err } @@ -146,7 +145,7 @@ func LoadChartOptionsFromFile(fs billy.Filesystem, path string) (ChartOptions, e if !exists { return chartOptions, fmt.Errorf("unable to load chart options from file %s since it does not exist", filesystem.GetAbsPath(fs, path)) } - chartOptionsBytes, err := ioutil.ReadFile(filesystem.GetAbsPath(fs, path)) + chartOptionsBytes, err := os.ReadFile(filesystem.GetAbsPath(fs, path)) if err != nil { return chartOptions, err } diff --git a/pkg/options/validate.go b/pkg/options/validate.go index d2f56686..95df0c02 100644 --- a/pkg/options/validate.go +++ b/pkg/options/validate.go @@ -1,7 +1,6 @@ package options import ( - "io/ioutil" "os" "github.com/hashicorp/go-version" @@ -78,7 +77,7 @@ func LoadReleaseOptionsFromFile(fs billy.Filesystem, path string) (ReleaseOption // If release.yaml does not exist, return an empty ReleaseOptions return releaseOptions, nil } - releaseOptionsBytes, err := ioutil.ReadFile(filesystem.GetAbsPath(fs, path)) + releaseOptionsBytes, err := os.ReadFile(filesystem.GetAbsPath(fs, path)) if err != nil { return releaseOptions, err } diff --git a/pkg/repository/git.go b/pkg/repository/git.go index 79793646..e0cc784a 100644 --- a/pkg/repository/git.go +++ b/pkg/repository/git.go @@ -2,7 +2,6 @@ package repository import ( "fmt" - "io/ioutil" "os" "path" "time" @@ -118,7 +117,7 @@ func CreateInitialCommit(repo *git.Repository) error { if err != nil { return err } - if err = ioutil.WriteFile(path.Join(repoPath, "README.md"), []byte{}, 0644); err != nil { + if err = os.WriteFile(path.Join(repoPath, "README.md"), []byte{}, 0644); err != nil { return err } return CommitAll(repo, "Create initial commit")