Skip to content

Commit

Permalink
Merge pull request containers#17364 from eriksjolund/add_return
Browse files Browse the repository at this point in the history
Add missing return after utils.Error()
  • Loading branch information
openshift-merge-robot authored Feb 7, 2023
2 parents a1f9c71 + 83a0e97 commit dcbe018
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/api/handlers/compat/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ func CreateImageFromSrc(w http.ResponseWriter, r *http.Request) {
source = f.Name()
if err := SaveFromBody(f, r); err != nil {
utils.Error(w, http.StatusInternalServerError, fmt.Errorf("failed to write temporary file: %w", err))
return
}
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/api/handlers/compat/images_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,12 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
anchorDir, err := os.MkdirTemp(parse.GetTempDir(), "libpod_builder")
if err != nil {
utils.InternalServerError(w, err)
return
}
tempDir, subDir, err := buildahDefine.TempDirForURL(anchorDir, "buildah", query.Remote)
if err != nil {
utils.InternalServerError(w, err)
return
}
if tempDir != "" {
// We had to download it to a temporary directory.
Expand All @@ -209,6 +211,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
absDir, err := filepath.Abs(query.Remote)
if err != nil {
utils.BadRequest(w, "remote", query.Remote, err)
return
}
contextDirectory = absDir
}
Expand All @@ -232,6 +235,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
containerFiles = []string{filepath.Join(contextDirectory, "Dockerfile")}
if _, err1 := os.Stat(containerFiles[0]); err1 != nil {
utils.BadRequest(w, "dockerfile", query.Dockerfile, err)
return
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/api/handlers/libpod/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ func UnmountContainer(w http.ResponseWriter, r *http.Request) {
// "container not mounted" error so we can surface that to the endpoint user
if err := conn.Unmount(false); err != nil {
utils.InternalServerError(w, err)
return
}
utils.WriteResponse(w, http.StatusNoContent, "")
}
Expand All @@ -178,6 +179,7 @@ func MountContainer(w http.ResponseWriter, r *http.Request) {
m, err := conn.Mount()
if err != nil {
utils.InternalServerError(w, err)
return
}
utils.WriteResponse(w, http.StatusOK, m)
}
Expand All @@ -188,11 +190,13 @@ func ShowMountedContainers(w http.ResponseWriter, r *http.Request) {
conns, err := runtime.GetAllContainers()
if err != nil {
utils.InternalServerError(w, err)
return
}
for _, conn := range conns {
mounted, mountPoint, err := conn.Mounted()
if err != nil {
utils.InternalServerError(w, err)
return
}
if !mounted {
continue
Expand Down
1 change: 1 addition & 0 deletions pkg/api/handlers/libpod/networks.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func UpdateNetwork(w http.ResponseWriter, r *http.Request) {
err := ic.NetworkUpdate(r.Context(), name, networkUpdateOptions)
if err != nil {
utils.Error(w, http.StatusInternalServerError, err)
return
}

utils.WriteResponse(w, http.StatusNoContent, nil)
Expand Down

0 comments on commit dcbe018

Please sign in to comment.