internal/ostree: offload using default ostree ref to caller

If params.Ref is an empty string, it's set to the distro's default
ref. The only difference here is that the default ref also gets
verified.

It makes splitting out resolving ostree refs to a new job easier.

In the weldr and cloud apis, ostree.ResolveParams always got executed,
also for non-ostree image types. Make it more explicit by only resolving
if the image type is actually an ostree image.
This commit is contained in:
Sanne Raymaekers 2022-10-14 18:08:49 +02:00
parent ae04c56c32
commit b01792d9dd
3 changed files with 48 additions and 42 deletions

View file

@ -2357,8 +2357,13 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
if testMode == "1" || testMode == "2" {
// Fake a parent commit for test requests
cr.OSTree.Parent = "02604b2da6e954bd34b8b82a835e5a77d2b60ffa"
} else {
ref, checksum, err := ostree.ResolveParams(cr.OSTree, imageType.OSTreeRef())
} else if imageType.OSTreeRef() != "" {
// If the image type has a default ostree ref, assume this is an OSTree image
reqParams := cr.OSTree
if reqParams.Ref == "" {
reqParams.Ref = imageType.OSTreeRef()
}
ref, checksum, err := ostree.ResolveParams(reqParams)
if err != nil {
errors := responseError{
ID: "OSTreeOptionsError",