mirror of https://github.com/containers/podman.git
pkg/domain: use fileutils.(Le|E)xists
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
bd00c6fef9
commit
cbffddc72e
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
@ -14,6 +15,7 @@ import (
|
|||
"github.com/containers/podman/v5/pkg/domain/entities"
|
||||
envLib "github.com/containers/podman/v5/pkg/env"
|
||||
"github.com/containers/podman/v5/utils"
|
||||
"github.com/containers/storage/pkg/fileutils"
|
||||
"github.com/google/shlex"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
@ -276,7 +278,7 @@ func substituteCommand(cmd string) (string, error) {
|
|||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if _, err := os.Stat(res); !os.IsNotExist(err) {
|
||||
if err := fileutils.Exists(res); !errors.Is(err, fs.ErrNotExist) {
|
||||
return res, nil
|
||||
} else if err != nil {
|
||||
return "", err
|
||||
|
|
|
@ -37,6 +37,7 @@ import (
|
|||
"github.com/containers/podman/v5/pkg/systemd/notifyproxy"
|
||||
"github.com/containers/podman/v5/pkg/util"
|
||||
"github.com/containers/podman/v5/utils"
|
||||
"github.com/containers/storage/pkg/fileutils"
|
||||
"github.com/coreos/go-systemd/v22/daemon"
|
||||
"github.com/opencontainers/go-digest"
|
||||
"github.com/opencontainers/selinux/go-selinux"
|
||||
|
@ -1465,7 +1466,7 @@ func getBuildFile(imageName string, cwd string) (string, error) {
|
|||
containerfilePath := filepath.Join(cwd, buildDirName, "Containerfile")
|
||||
dockerfilePath := filepath.Join(cwd, buildDirName, "Dockerfile")
|
||||
|
||||
_, err := os.Stat(containerfilePath)
|
||||
err := fileutils.Exists(containerfilePath)
|
||||
if err == nil {
|
||||
logrus.Debugf("Building %s with %s", imageName, containerfilePath)
|
||||
return containerfilePath, nil
|
||||
|
@ -1477,7 +1478,7 @@ func getBuildFile(imageName string, cwd string) (string, error) {
|
|||
logrus.Error(err.Error())
|
||||
}
|
||||
|
||||
_, err = os.Stat(dockerfilePath)
|
||||
err = fileutils.Exists(dockerfilePath)
|
||||
if err == nil {
|
||||
logrus.Debugf("Building %s with %s", imageName, dockerfilePath)
|
||||
return dockerfilePath, nil
|
||||
|
|
|
@ -15,6 +15,7 @@ import (
|
|||
"github.com/containers/podman/v5/pkg/util"
|
||||
"github.com/containers/storage"
|
||||
"github.com/containers/storage/pkg/directory"
|
||||
"github.com/containers/storage/pkg/fileutils"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
|
@ -51,7 +52,7 @@ func (ic *ContainerEngine) Info(ctx context.Context) (*define.Info, error) {
|
|||
}
|
||||
|
||||
if uri.Scheme == "unix" {
|
||||
_, err := os.Stat(uri.Path)
|
||||
err := fileutils.Exists(uri.Path)
|
||||
info.Host.RemoteSocket.Exists = err == nil
|
||||
} else {
|
||||
info.Host.RemoteSocket.Exists = true
|
||||
|
|
Loading…
Reference in New Issue