store/compose/ImageType: use distro.ImageType objects

This reduces the amount of resolving and error checking we have to do.
This exposed a bug in weldr's ComposeEntry type, which will be fixed in
a follow-up commit.

Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
Tom Gundersen 2020-05-11 22:54:28 +02:00
parent 5ba7e21a72
commit 2fe4450620
9 changed files with 77 additions and 54 deletions

View file

@ -28,7 +28,13 @@ func composeToComposeEntry(id uuid.UUID, compose store.Compose, state common.Com
composeEntry.ID = id
composeEntry.Blueprint = compose.Blueprint.Name
composeEntry.Version = compose.Blueprint.Version
composeEntry.ComposeType = compose.ImageBuilds[0].ImageType
var valid bool
// BUG: this leads to the wrong image type string being returned, we want the compat strings here
composeEntry.ComposeType, valid = common.ImageTypeFromCompatString(compose.ImageBuilds[0].ImageType.Name())
if !valid {
panic("compose contains invalid image type: " + compose.ImageBuilds[0].ImageType.Name())
}
if includeUploads {
composeEntry.Uploads = targetsToUploadResponses(compose.ImageBuilds[0].Targets)