distro: replace ostree.RequestParams with new OSTreeImageOptions
Instead of using the ostree.RequestParams in the OSTReeImageOptions, define a new struct specific to ImageOptions for the ostree parameters. This is almost identical to the new ostree.CommitSpec but the meaning of the parameters changes based on image type and it would not be clear if the CommitSpec was used in all cases. For example, the parameters of the new OSTreeImageOptions do not always refer to the same commit. The URL and Checksum may point to a parent commit to be pulled in to base the new commit on, while the Ref refers to the new commit that will be built (which may have a different ref from the parent). The ostree.ResolveParams() function now returns two strings, the resolved ref, which is replaced by the defaultRef if it's not specified in the request, and the resolved parent checksum if a URL is specified. The URL does not need to be returned since it's always the same as the one specified in the request. The function has been rewritten to make the logic more clear. The docstring for the function has been rewritten to cover all use cases and error conditions.
This commit is contained in:
parent
c6b999f178
commit
390ae15eaa
16 changed files with 175 additions and 138 deletions
|
|
@ -298,7 +298,8 @@ func (h *apiHandlers) PostCompose(ctx echo.Context) error {
|
|||
ostreeOptions.Parent = *ir.Ostree.Parent
|
||||
}
|
||||
}
|
||||
if imageOptions.OSTree, err = ostree.ResolveParams(ostreeOptions, imageType.OSTreeRef()); err != nil {
|
||||
ref, checksum, err := ostree.ResolveParams(ostreeOptions, imageType.OSTreeRef())
|
||||
if err != nil {
|
||||
switch v := err.(type) {
|
||||
case ostree.RefError:
|
||||
return HTTPError(ErrorInvalidOSTreeRef)
|
||||
|
|
@ -311,6 +312,11 @@ func (h *apiHandlers) PostCompose(ctx echo.Context) error {
|
|||
return HTTPError(ErrorInvalidOSTreeParams)
|
||||
}
|
||||
}
|
||||
imageOptions.OSTree = distro.OSTreeImageOptions{
|
||||
ImageRef: ref,
|
||||
FetchChecksum: checksum,
|
||||
URL: ostreeOptions.URL,
|
||||
}
|
||||
|
||||
var irTarget *target.Target
|
||||
if ir.UploadOptions == nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue