web/api/v1: fix optional skip_head for snapshot (#4674)

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
Simon Pasquier 2018-10-02 12:48:07 +02:00 committed by Goutham Veeramachaneni
parent 7225919760
commit 3c00eeaf16
1 changed files with 9 additions and 3 deletions

View File

@ -892,9 +892,15 @@ func (api *API) snapshot(r *http.Request) (interface{}, *apiError, func()) {
if !api.enableAdmin {
return nil, &apiError{errorUnavailable, errors.New("Admin APIs disabled")}, nil
}
skipHead, err := strconv.ParseBool(r.FormValue("skip_head"))
if err != nil {
return nil, &apiError{errorUnavailable, fmt.Errorf("unable to parse boolean 'skip_head' argument: %v", err)}, nil
var (
skipHead bool
err error
)
if r.FormValue("skip_head") != "" {
skipHead, err = strconv.ParseBool(r.FormValue("skip_head"))
if err != nil {
return nil, &apiError{errorUnavailable, fmt.Errorf("unable to parse boolean 'skip_head' argument: %v", err)}, nil
}
}
db := api.db()