Add missing early returns in compat API

[NO TESTS NEEDED]

Signed-off-by: Riyad Preukschas <riyad@informatik.uni-bremen.de>
This commit is contained in:
Riyad Preukschas
2021-02-13 22:48:52 +01:00
parent 50042120e9
commit 68a8d397ce
3 changed files with 8 additions and 2 deletions

View File

@ -47,6 +47,7 @@ func CreateContainer(w http.ResponseWriter, r *http.Request) {
rtc, err := runtime.GetConfig() rtc, err := runtime.GetConfig()
if err != nil { if err != nil {
utils.Error(w, "unable to obtain runtime config", http.StatusInternalServerError, errors.Wrap(err, "unable to get runtime config")) utils.Error(w, "unable to obtain runtime config", http.StatusInternalServerError, errors.Wrap(err, "unable to get runtime config"))
return
} }
newImage, err := runtime.ImageRuntime().NewFromLocal(body.Config.Image) newImage, err := runtime.ImageRuntime().NewFromLocal(body.Config.Image)

View File

@ -30,7 +30,9 @@ func ListSecrets(w http.ResponseWriter, r *http.Request) {
return return
} }
if len(query.Filters) > 0 { if len(query.Filters) > 0 {
utils.Error(w, "filters not supported", http.StatusBadRequest, errors.New("bad parameter")) utils.Error(w, "filters not supported", http.StatusBadRequest,
errors.Wrapf(errors.New("bad parameter"), "filters not supported"))
return
} }
ic := abi.ContainerEngine{Libpod: runtime} ic := abi.ContainerEngine{Libpod: runtime}
reports, err := ic.SecretList(r.Context()) reports, err := ic.SecretList(r.Context())
@ -95,7 +97,9 @@ func CreateSecret(w http.ResponseWriter, r *http.Request) {
return return
} }
if len(createParams.Labels) > 0 { if len(createParams.Labels) > 0 {
utils.Error(w, "labels not supported", http.StatusBadRequest, errors.New("bad parameter")) utils.Error(w, "labels not supported", http.StatusBadRequest,
errors.Wrapf(errors.New("bad parameter"), "labels not supported"))
return
} }
decoded, _ := base64.StdEncoding.DecodeString(createParams.Data) decoded, _ := base64.StdEncoding.DecodeString(createParams.Data)

View File

@ -19,6 +19,7 @@ func GetDiskUsage(w http.ResponseWriter, r *http.Request) {
df, err := ic.SystemDf(r.Context(), options) df, err := ic.SystemDf(r.Context(), options)
if err != nil { if err != nil {
utils.InternalServerError(w, err) utils.InternalServerError(w, err)
return
} }
imgs := make([]*docker.ImageSummary, len(df.Images)) imgs := make([]*docker.ImageSummary, len(df.Images))