Skip to content
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
5 changes: 2 additions & 3 deletions fixtures/util/dynatrace/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -33,7 +32,7 @@ func main() {
}

case "/dynatrace-env.sh", "/liboneagentproc.so", "/ruxitagentproc.conf":
contents, err := ioutil.ReadFile(strings.TrimPrefix(req.URL.Path, "/"))
contents, err := os.ReadFile(strings.TrimPrefix(req.URL.Path, "/"))
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprint(w, err.Error())
Expand Down Expand Up @@ -69,7 +68,7 @@ func main() {
json.NewEncoder(w).Encode(payload)

case "/v1/deployment/installer/agent/processmoduleconfig":
fakeConfig, err := ioutil.ReadFile("fake_config.json")
fakeConfig, err := os.ReadFile("fake_config.json")
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(err.Error()))
Expand Down
5 changes: 2 additions & 3 deletions src/go/brats/brats_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"sort"
Expand Down Expand Up @@ -72,10 +71,10 @@ func CopyBrats(version string) *cutlass.App {
version = dep.Version
}

data, err := ioutil.ReadFile(filepath.Join(dir, "Godeps", "Godeps.json"))
data, err := os.ReadFile(filepath.Join(dir, "Godeps", "Godeps.json"))
Expect(err).ToNot(HaveOccurred())
data = bytes.Replace(data, []byte("<%= version %>"), []byte(version), -1)
Expect(ioutil.WriteFile(filepath.Join(dir, "Godeps", "Godeps.json"), data, 0644)).To(Succeed())
Expect(os.WriteFile(filepath.Join(dir, "Godeps", "Godeps.json"), data, 0644)).To(Succeed())

return cutlass.New(dir)
}
Expand Down
11 changes: 5 additions & 6 deletions src/go/finalize/finalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -220,7 +219,7 @@ func (gf *Finalizer) SetupGoPath() error {
if goPathInImage {
goPath = gf.Stager.BuildDir()
} else {
tmpDir, err := ioutil.TempDir("", "gobuildpack.gopath")
tmpDir, err := os.MkdirTemp("", "gobuildpack.gopath")
if err != nil {
return err
}
Expand All @@ -246,7 +245,7 @@ func (gf *Finalizer) SetupGoPath() error {
}

if goPathInImage {
files, err := ioutil.ReadDir(gf.Stager.BuildDir())
files, err := os.ReadDir(gf.Stager.BuildDir())
if err != nil {
return err
}
Expand Down Expand Up @@ -304,7 +303,7 @@ func (gf *Finalizer) RunDepEnsure() error {

if vendorDirExists {
numSubDirs := 0
files, err := ioutil.ReadDir(filepath.Join(gf.mainPackagePath(), "vendor"))
files, err := os.ReadDir(filepath.Join(gf.mainPackagePath(), "vendor"))
if err != nil {
return err
}
Expand Down Expand Up @@ -345,7 +344,7 @@ func (gf *Finalizer) RunGlideInstall() error {

if vendorDirExists {
numSubDirs := 0
files, err := ioutil.ReadDir(filepath.Join(gf.mainPackagePath(), "vendor"))
files, err := os.ReadDir(filepath.Join(gf.mainPackagePath(), "vendor"))
if err != nil {
return err
}
Expand Down Expand Up @@ -477,7 +476,7 @@ func (gf *Finalizer) CreateStartupEnvironment(tempDir string) error {
mainPkgName = filepath.Base(gf.PackageList[0])
}

err := ioutil.WriteFile(filepath.Join(tempDir, "buildpack-release-step.yml"), []byte(data.ReleaseYAML(mainPkgName)), 0644)
err := os.WriteFile(filepath.Join(tempDir, "buildpack-release-step.yml"), []byte(data.ReleaseYAML(mainPkgName)), 0644)
if err != nil {
gf.Log.Error("Unable to write release yml: %s", err)
return err
Expand Down
43 changes: 21 additions & 22 deletions src/go/finalize/finalize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package finalize_test
import (
"bytes"
"io"
"io/ioutil"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -43,14 +42,14 @@ var _ = Describe("Finalize", func() {
)

BeforeEach(func() {
depsDir, err = ioutil.TempDir("", "go-buildpack.build.")
depsDir, err = os.MkdirTemp("", "go-buildpack.build.")
Expect(err).To(BeNil())

depsIdx = "06"
err = os.MkdirAll(filepath.Join(depsDir, depsIdx), 0755)
Expect(err).To(BeNil())

buildDir, err = ioutil.TempDir("", "go-buildpack.build.")
buildDir, err = os.MkdirTemp("", "go-buildpack.build.")
Expect(err).To(BeNil())

buffer = new(bytes.Buffer)
Expand Down Expand Up @@ -90,7 +89,7 @@ var _ = Describe("Finalize", func() {
Describe("NewFinalizer", func() {
Context("the vendor tool is godep", func() {
BeforeEach(func() {
ioutil.WriteFile(filepath.Join(depsDir, depsIdx, "config.yml"), []byte(`name: "go"
os.WriteFile(filepath.Join(depsDir, depsIdx, "config.yml"), []byte(`name: "go"
config:
GoVersion: 1.4.2
VendorTool: godep
Expand All @@ -109,7 +108,7 @@ config:
})
Context("the vendor tool is glide", func() {
BeforeEach(func() {
ioutil.WriteFile(filepath.Join(depsDir, depsIdx, "config.yml"), []byte(`name: "go"
os.WriteFile(filepath.Join(depsDir, depsIdx, "config.yml"), []byte(`name: "go"
config:
GoVersion: 1.2.4
VendorTool: glide
Expand All @@ -126,7 +125,7 @@ config:
})
Context("the vendor tool is dep", func() {
BeforeEach(func() {
ioutil.WriteFile(filepath.Join(depsDir, depsIdx, "config.yml"), []byte(`name: "go"
os.WriteFile(filepath.Join(depsDir, depsIdx, "config.yml"), []byte(`name: "go"
config:
GoVersion: 1.9.0
VendorTool: dep
Expand Down Expand Up @@ -256,19 +255,19 @@ config:
oldGoBin = os.Getenv("GOBIN")
oldGoSetupGopathInImage = os.Getenv("GO_SETUP_GOPATH_IN_IMAGE")

err := ioutil.WriteFile(filepath.Join(buildDir, "main.go"), []byte("xx"), 0644)
err := os.WriteFile(filepath.Join(buildDir, "main.go"), []byte("xx"), 0644)
Expect(err).To(BeNil())

err = os.MkdirAll(filepath.Join(buildDir, "vendor"), 0755)
Expect(err).To(BeNil())

err = ioutil.WriteFile(filepath.Join(buildDir, "vendor", "lib.go"), []byte("xx"), 0644)
err = os.WriteFile(filepath.Join(buildDir, "vendor", "lib.go"), []byte("xx"), 0644)
Expect(err).To(BeNil())

err = ioutil.WriteFile(filepath.Join(buildDir, "Procfile"), []byte("xx"), 0644)
err = os.WriteFile(filepath.Join(buildDir, "Procfile"), []byte("xx"), 0644)
Expect(err).To(BeNil())

err = ioutil.WriteFile(filepath.Join(buildDir, ".profile"), []byte("xx"), 0644)
err = os.WriteFile(filepath.Join(buildDir, ".profile"), []byte("xx"), 0644)
Expect(err).To(BeNil())

err = os.MkdirAll(filepath.Join(buildDir, ".cloudfoundry"), 0755)
Expand All @@ -277,7 +276,7 @@ config:
err = os.MkdirAll(filepath.Join(buildDir, ".profile.d"), 0755)
Expect(err).To(BeNil())

err = ioutil.WriteFile(filepath.Join(buildDir, ".profile.d", "filename.sh"), []byte("xx"), 0644)
err = os.WriteFile(filepath.Join(buildDir, ".profile.d", "filename.sh"), []byte("xx"), 0644)
Expect(err).To(BeNil())
})

Expand Down Expand Up @@ -473,7 +472,7 @@ config:

BeforeEach(func() {
mainPackageName = "a/package/name"
goPath, err = ioutil.TempDir("", "go-buildpack.package")
goPath, err = os.MkdirTemp("", "go-buildpack.package")
Expect(err).To(BeNil())

mainPackagePath = filepath.Join(goPath, "src", mainPackageName)
Expand Down Expand Up @@ -515,7 +514,7 @@ config:

BeforeEach(func() {
mainPackageName = "a/package/name"
goPath, err = ioutil.TempDir("", "go-buildpack.package")
goPath, err = os.MkdirTemp("", "go-buildpack.package")
Expect(err).To(BeNil())

mainPackagePath = filepath.Join(goPath, "src", mainPackageName)
Expand Down Expand Up @@ -641,7 +640,7 @@ config:

BeforeEach(func() {
mainPackageName = "a/package/name"
goPath, err = ioutil.TempDir("", "go-buildpack.package")
goPath, err = os.MkdirTemp("", "go-buildpack.package")
Expect(err).To(BeNil())

mainPackagePath = filepath.Join(goPath, "src", mainPackageName)
Expand Down Expand Up @@ -984,7 +983,7 @@ config:
packageList = []string{"first", "second"}
buildFlags = []string{"-a=1", "-b=2"}

goPath, err = ioutil.TempDir("", "go-buildpack.gopath")
goPath, err = os.MkdirTemp("", "go-buildpack.gopath")
Expect(err).To(BeNil())

mainPackagePath = filepath.Join(goPath, "src", "first")
Expand Down Expand Up @@ -1102,15 +1101,15 @@ config:
err = os.MkdirAll(goDir, 0755)
Expect(err).To(BeNil())

tempDir, err = ioutil.TempDir("", "gobuildpack.releaseyml")
tempDir, err = os.MkdirTemp("", "gobuildpack.releaseyml")
Expect(err).To(BeNil())
})

It("writes the buildpack-release-step.yml file", func() {
err = gf.CreateStartupEnvironment(tempDir)
Expect(err).To(BeNil())

contents, err := ioutil.ReadFile(filepath.Join(tempDir, "buildpack-release-step.yml"))
contents, err := os.ReadFile(filepath.Join(tempDir, "buildpack-release-step.yml"))
Expect(err).To(BeNil())

yaml := `---
Expand All @@ -1124,7 +1123,7 @@ default_process_types:
err = gf.CreateStartupEnvironment(tempDir)
Expect(err).To(BeNil())

contents, err := ioutil.ReadFile(filepath.Join(gf.Stager.DepDir(), "profile.d", "go.sh"))
contents, err := os.ReadFile(filepath.Join(gf.Stager.DepDir(), "profile.d", "go.sh"))
Expect(err).To(BeNil())

Expect(string(contents)).To(Equal("PATH=$PATH:$HOME/bin\n"))
Expand All @@ -1135,10 +1134,10 @@ default_process_types:
err = os.MkdirAll(filepath.Join(depsDir, "06", "go3.4.5"), 0755)
Expect(err).To(BeNil())

err = ioutil.WriteFile(filepath.Join(depsDir, "06", "go3.4.5", "thing.txt"), []byte("abc"), 0644)
err = os.WriteFile(filepath.Join(depsDir, "06", "go3.4.5", "thing.txt"), []byte("abc"), 0644)
Expect(err).To(BeNil())

err = ioutil.WriteFile(filepath.Join(depsDir, "06", "config.yml"), []byte("some yaml"), 0644)
err = os.WriteFile(filepath.Join(depsDir, "06", "config.yml"), []byte("some yaml"), 0644)
Expect(err).To(BeNil())
})

Expand All @@ -1148,7 +1147,7 @@ default_process_types:

Expect(filepath.Join(depsDir, "06", "go3.4.5")).NotTo(BeADirectory())

content, err := ioutil.ReadFile(filepath.Join(filepath.Join(depsDir, "06"), "config.yml"))
content, err := os.ReadFile(filepath.Join(filepath.Join(depsDir, "06"), "config.yml"))
Expect(err).To(BeNil())
Expect(string(content)).To(Equal("some yaml"))
})
Expand Down Expand Up @@ -1214,7 +1213,7 @@ default_process_types:
err = gf.CreateStartupEnvironment(tempDir)
Expect(err).To(BeNil())

contents, err := ioutil.ReadFile(filepath.Join(gf.Stager.DepDir(), "profile.d", "zzgopath.sh"))
contents, err := os.ReadFile(filepath.Join(gf.Stager.DepDir(), "profile.d", "zzgopath.sh"))
Expect(err).To(BeNil())

Expect(string(contents)).To(ContainSubstring("export GOPATH=$HOME"))
Expand Down
9 changes: 4 additions & 5 deletions src/go/hooks/appdynamics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package hooks_test

import (
"bytes"
"io/ioutil"
"os"
"path/filepath"

Expand Down Expand Up @@ -39,10 +38,10 @@ var _ = Describe("Appdynamics", func() {
)

BeforeEach(func() {
buildDir, err = ioutil.TempDir("", "go-buildpack.build.")
buildDir, err = os.MkdirTemp("", "go-buildpack.build.")
Expect(err).To(BeNil())

depsDir, err = ioutil.TempDir("", "go-buildpack.deps.")
depsDir, err = os.MkdirTemp("", "go-buildpack.deps.")
Expect(err).To(BeNil())

buffer = new(bytes.Buffer)
Expand Down Expand Up @@ -91,7 +90,7 @@ export APPD_KEY_2=APPD_VAL_2`

export APPD_KEY_1=APPD_VAL_1
export APPD_KEY_2=APPD_VAL_2`
script, err := ioutil.ReadFile(appdynamicsShellScript)
script, err := os.ReadFile(appdynamicsShellScript)
Expect(err).To(BeNil())
Expect(string(script)).To(Equal(expectedScript))
})
Expand Down Expand Up @@ -144,7 +143,7 @@ export APPD_KEY_2=APPD_VAL_2`
Expect(err).To(BeNil())

Expect(libbuildpack.FileExists(filepath.Join(stager.DepDir(), "profile.d", "appdynamics.sh"))).To(BeTrue())
appdynamicsInfo, err := ioutil.ReadFile(filepath.Join(stager.DepDir(), "profile.d", "appdynamics.sh"))
appdynamicsInfo, err := os.ReadFile(filepath.Join(stager.DepDir(), "profile.d", "appdynamics.sh"))
expectedInfo := `# Autogenerated Appdynamics Script

export APPD_ACCOUNT_ACCESS_KEY=key
Expand Down
5 changes: 2 additions & 3 deletions src/go/supply/supply.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"slices"
Expand Down Expand Up @@ -296,13 +295,13 @@ func (gs *Supplier) isGoPath() (bool, error) {
return false, nil
}

files, err := ioutil.ReadDir(filepath.Join(gs.Stager.BuildDir(), "src"))
files, err := os.ReadDir(filepath.Join(gs.Stager.BuildDir(), "src"))
if err != nil {
return false, err
}

for _, file := range files {
if file.Mode().IsDir() {
if file.IsDir() {
err = filepath.Walk(filepath.Join(srcDir, file.Name()), isGoFile)
if err != nil {
if err.Error() == "found Go file" {
Expand Down
Loading
Loading