pkg/api: use fileutils.(Le|E)xists
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
5656ad40b1
commit
bd00c6fef9
|
@ -27,6 +27,7 @@ import (
|
|||
"github.com/containers/podman/v5/pkg/specgen"
|
||||
"github.com/containers/podman/v5/pkg/specgenutil"
|
||||
"github.com/containers/storage"
|
||||
"github.com/containers/storage/pkg/fileutils"
|
||||
"github.com/docker/docker/api/types/mount"
|
||||
)
|
||||
|
||||
|
@ -527,7 +528,7 @@ func cliOpts(cc handlers.CreateContainerConfig, rtc *config.Config) (*entities.C
|
|||
continue
|
||||
}
|
||||
// If volume already exists, there is nothing to do
|
||||
if _, err := os.Stat(vol); err == nil {
|
||||
if err := fileutils.Exists(vol); err == nil {
|
||||
continue
|
||||
}
|
||||
if err := os.MkdirAll(vol, 0o755); err != nil {
|
||||
|
|
|
@ -27,6 +27,7 @@ import (
|
|||
"github.com/containers/podman/v5/pkg/rootless"
|
||||
"github.com/containers/podman/v5/pkg/util"
|
||||
"github.com/containers/storage/pkg/archive"
|
||||
"github.com/containers/storage/pkg/fileutils"
|
||||
"github.com/docker/docker/pkg/jsonmessage"
|
||||
"github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
@ -248,9 +249,9 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
|
|||
containerFiles = []string{filepath.Join(contextDirectory, "Dockerfile")}
|
||||
if utils.IsLibpodRequest(r) {
|
||||
containerFiles = []string{filepath.Join(contextDirectory, "Containerfile")}
|
||||
if _, err = os.Stat(containerFiles[0]); err != nil {
|
||||
if err = fileutils.Exists(containerFiles[0]); err != nil {
|
||||
containerFiles = []string{filepath.Join(contextDirectory, "Dockerfile")}
|
||||
if _, err1 := os.Stat(containerFiles[0]); err1 != nil {
|
||||
if err1 := fileutils.Exists(containerFiles[0]); err1 != nil {
|
||||
utils.BadRequest(w, "dockerfile", query.Dockerfile, err)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/containers/podman/v5/pkg/api/handlers/utils"
|
||||
"github.com/containers/storage/pkg/fileutils"
|
||||
)
|
||||
|
||||
// DefaultPodmanSwaggerSpec provides the default path to the podman swagger spec file
|
||||
|
@ -17,7 +18,7 @@ func ServeSwagger(w http.ResponseWriter, r *http.Request) {
|
|||
if p, found := os.LookupEnv("PODMAN_SWAGGER_SPEC"); found {
|
||||
path = p
|
||||
}
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
if err := fileutils.Exists(path); err != nil {
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
utils.InternalServerError(w, fmt.Errorf("swagger spec %q does not exist", path))
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue