weldr: stop using Distro.FilenameFromType

The method is available in the Distro interface, but the distro does not
have the information needed to provide this kind of information any
more. The logic is now split into Arch and ImageType interfaces. This
patch will allow us to get rid of some old code and move forward.
This commit is contained in:
Martin Sehnoutka 2020-03-26 09:58:19 +01:00 committed by Tom Gundersen
parent 5fc1f10ecb
commit 2f576e0964

View file

@ -1754,16 +1754,18 @@ func (api *API) composeImageHandler(writer http.ResponseWriter, request *http.Re
imageBuild := compose.ImageBuilds[0]
imageType, _ := imageBuild.ImageType.ToCompatString()
imageName, imageMime, err := api.distro.FilenameFromType(imageType)
imageTypeStruct, err := api.arch.GetImageType(imageType)
if err != nil {
errors := responseError{
ID: "BadCompose",
Msg: fmt.Sprintf("Compose %s is ill-formed: output type %v is invalid for distro %s", uuidString, imageBuild.ImageType, api.distro.Name()),
ID: "BadCompose",
Msg: fmt.Sprintf("Compose %s is ill-formed: output type %v is invalid for distro %s on %s",
uuidString, imageBuild.ImageType, api.distro.Name(), api.arch.Name()),
}
statusResponseError(writer, http.StatusInternalServerError, errors)
return
}
imageName := imageTypeStruct.Filename()
imageMime := imageTypeStruct.MIMEType()
reader, fileSize, err := api.store.GetImageBuildImage(uuid, 0)