mirror of
https://github.com/containers/podman.git
synced 2025-07-02 08:47:43 +08:00
Merge pull request #15890 from cevich/more_ioutil_fixes
Fix a few missed io/ioutil -> os updates
This commit is contained in:
@ -12,7 +12,6 @@ import (
|
|||||||
"go/ast"
|
"go/ast"
|
||||||
"go/parser"
|
"go/parser"
|
||||||
"go/token"
|
"go/token"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
@ -72,7 +71,7 @@ func main() {
|
|||||||
)
|
)
|
||||||
srcFile := os.Getenv("GOFILE")
|
srcFile := os.Getenv("GOFILE")
|
||||||
inputStructName := os.Args[1]
|
inputStructName := os.Args[1]
|
||||||
b, err := ioutil.ReadFile(srcFile)
|
b, err := os.ReadFile(srcFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
@ -395,11 +394,11 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
|
|||||||
dontexcludes := []string{"!Dockerfile", "!Containerfile", "!.dockerignore", "!.containerignore"}
|
dontexcludes := []string{"!Dockerfile", "!Containerfile", "!.dockerignore", "!.containerignore"}
|
||||||
for _, c := range containerFiles {
|
for _, c := range containerFiles {
|
||||||
if c == "/dev/stdin" {
|
if c == "/dev/stdin" {
|
||||||
content, err := ioutil.ReadAll(os.Stdin)
|
content, err := io.ReadAll(os.Stdin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
tmpFile, err := ioutil.TempFile("", "build")
|
tmpFile, err := os.CreateTemp("", "build")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -465,7 +464,7 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
|
|||||||
if arr[0] == "src" {
|
if arr[0] == "src" {
|
||||||
// read specified secret into a tmp file
|
// read specified secret into a tmp file
|
||||||
// move tmp file to tar and change secret source to relative tmp file
|
// move tmp file to tar and change secret source to relative tmp file
|
||||||
tmpSecretFile, err := ioutil.TempFile(options.ContextDirectory, "podman-build-secret")
|
tmpSecretFile, err := os.CreateTemp(options.ContextDirectory, "podman-build-secret")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -531,7 +530,7 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
|
|||||||
if logrus.IsLevelEnabled(logrus.DebugLevel) {
|
if logrus.IsLevelEnabled(logrus.DebugLevel) {
|
||||||
if v, found := os.LookupEnv("PODMAN_RETAIN_BUILD_ARTIFACT"); found {
|
if v, found := os.LookupEnv("PODMAN_RETAIN_BUILD_ARTIFACT"); found {
|
||||||
if keep, _ := strconv.ParseBool(v); keep {
|
if keep, _ := strconv.ParseBool(v); keep {
|
||||||
t, _ := ioutil.TempFile("", "build_*_client")
|
t, _ := os.CreateTemp("", "build_*_client")
|
||||||
defer t.Close()
|
defer t.Close()
|
||||||
body = io.TeeReader(response.Body, t)
|
body = io.TeeReader(response.Body, t)
|
||||||
}
|
}
|
||||||
@ -737,10 +736,10 @@ func nTar(excludes []string, sources ...string) (io.ReadCloser, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func parseDockerignore(root string) ([]string, error) {
|
func parseDockerignore(root string) ([]string, error) {
|
||||||
ignore, err := ioutil.ReadFile(filepath.Join(root, ".containerignore"))
|
ignore, err := os.ReadFile(filepath.Join(root, ".containerignore"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var dockerIgnoreErr error
|
var dockerIgnoreErr error
|
||||||
ignore, dockerIgnoreErr = ioutil.ReadFile(filepath.Join(root, ".dockerignore"))
|
ignore, dockerIgnoreErr = os.ReadFile(filepath.Join(root, ".dockerignore"))
|
||||||
if dockerIgnoreErr != nil && !os.IsNotExist(dockerIgnoreErr) {
|
if dockerIgnoreErr != nil && !os.IsNotExist(dockerIgnoreErr) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package bindings_test
|
package bindings_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -76,7 +75,7 @@ var _ = Describe("Podman images", func() {
|
|||||||
imageRef := imageRep + ":" + imageTag
|
imageRef := imageRep + ":" + imageTag
|
||||||
|
|
||||||
// Create a temporary authentication file.
|
// Create a temporary authentication file.
|
||||||
tmpFile, err := ioutil.TempFile("", "auth.json.")
|
tmpFile, err := os.CreateTemp("", "auth.json.")
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
_, err = tmpFile.Write([]byte{'{', '}'})
|
_, err = tmpFile.Write([]byte{'{', '}'})
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
@ -3,7 +3,6 @@ package bindings_test
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -146,7 +145,7 @@ func newBindingTest() *bindingTest {
|
|||||||
|
|
||||||
// createTempDirinTempDir create a temp dir with prefix podman_test
|
// createTempDirinTempDir create a temp dir with prefix podman_test
|
||||||
func createTempDirInTempDir() (string, error) {
|
func createTempDirInTempDir() (string, error) {
|
||||||
return ioutil.TempDir("", "libpod_api")
|
return os.MkdirTemp("", "libpod_api")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *bindingTest) startAPIService() *gexec.Session {
|
func (b *bindingTest) startAPIService() *gexec.Session {
|
||||||
@ -264,7 +263,7 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {
|
|||||||
// If running localized tests, the cache dir is created and populated. if the
|
// If running localized tests, the cache dir is created and populated. if the
|
||||||
// tests are remote, this is a no-op
|
// tests are remote, this is a no-op
|
||||||
createCache()
|
createCache()
|
||||||
path, err := ioutil.TempDir("", "libpodlock")
|
path, err := os.MkdirTemp("", "libpodlock")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -5,7 +5,6 @@ package integration
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
@ -48,7 +47,7 @@ func (p *PodmanTestIntegration) setDefaultRegistriesConfigEnv() {
|
|||||||
func (p *PodmanTestIntegration) setRegistriesConfigEnv(b []byte) {
|
func (p *PodmanTestIntegration) setRegistriesConfigEnv(b []byte) {
|
||||||
outfile := filepath.Join(p.TempDir, "registries.conf")
|
outfile := filepath.Join(p.TempDir, "registries.conf")
|
||||||
os.Setenv("CONTAINERS_REGISTRIES_CONF", outfile)
|
os.Setenv("CONTAINERS_REGISTRIES_CONF", outfile)
|
||||||
err := ioutil.WriteFile(outfile, b, 0644)
|
err := os.WriteFile(outfile, b, 0644)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@ var _ = Describe("Podman secret", func() {
|
|||||||
|
|
||||||
It("podman secret with labels", func() {
|
It("podman secret with labels", func() {
|
||||||
secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
|
secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
|
||||||
err := ioutil.WriteFile(secretFilePath, []byte("mysecret"), 0755)
|
err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
session := podmanTest.Podman([]string{"secret", "create", "--label", "foo=bar", "a", secretFilePath})
|
session := podmanTest.Podman([]string{"secret", "create", "--label", "foo=bar", "a", secretFilePath})
|
||||||
|
Reference in New Issue
Block a user