blueprints: Fix commit message when version is empty

With an empty or missing version number the commit message would not
include the version (which is set to 0.0.0 by calling Initialize).  This
adds a call to Initialize() in the API code before constructing the
commit message. It also moves the check for non-empty blueprint name
into the Initialize call where it belongs.
This commit is contained in:
Brian C. Lane 2022-09-27 15:57:41 -07:00 committed by Ondřej Budai
parent 8fcbeaadb3
commit d42d5fa17f
3 changed files with 18 additions and 7 deletions

View file

@ -1945,6 +1945,17 @@ func (api *API) blueprintsNewHandler(writer http.ResponseWriter, request *http.R
}
}
// Make sure the blueprint has default values and that the version is valid
err = blueprint.Initialize()
if err != nil {
errors := responseError{
ID: "BlueprintsError",
Msg: err.Error(),
}
statusResponseError(writer, http.StatusBadRequest, errors)
return
}
commitMsg := "Recipe " + blueprint.Name + ", version " + blueprint.Version + " saved."
err = api.store.PushBlueprint(blueprint, commitMsg)
if err != nil {