ostree: use image options for request data

The ostree options for a compose request should be specified using the
ImageOptions struct, not the source spec.  The source spec should be
specifying the source parameters for a single ostree commit internally.
This commit is contained in:
Achilleas Koutsou 2023-06-05 23:07:00 +02:00 committed by Ondřej Budai
parent 56ea5db9a8
commit 7a23a81228
2 changed files with 18 additions and 24 deletions

View file

@ -19,13 +19,13 @@ import (
var ostreeRefRE = regexp.MustCompile(`^(?:[\w\d][-._\w\d]*\/)*[\w\d][-._\w\d]*$`)
// SourceSpec serves as input for ResolveParams, and contains all necessary variables to resolve
// a ref, which can then be turned into a CommitSpec.
// SourceSpec serves as input for ResolveParams, and contains all necessary
// variables to resolve a ref, which can then be turned into a CommitSpec.
type SourceSpec struct {
URL string `json:"url"`
Ref string `json:"ref"`
Parent string `json:"parent"`
RHSM bool `json:"rhsm"`
URL string
Ref string
Parent string
RHSM bool
}
// CommitSpec specifies an ostree commit using any combination of Ref (branch), URL (source), and Checksum (commit ID).
@ -54,22 +54,22 @@ type ImageOptions struct {
// built.
// For ostree installers and raw images: The ref of the commit being
// embedded in the installer or deployed in the image.
ImageRef string
ImageRef string `json:"ref"`
// For ostree commit and container types: The ParentRef specifies the parent
// ostree commit that the new commit will be based on.
// For ostree installers and raw images: The ParentRef does not apply.
ParentRef string
ParentRef string `json:"parent"`
// The URL from which to fetch the commit specified by the checksum.
URL string
URL string `json:"url"`
// If specified, the URL will be used only for metadata.
ContentURL string
ContentURL string `json:"contenturl"`
// Indicate if the 'org.osbuild.rhsm.consumer' secret should be added when pulling from the
// remote.
RHSM bool
RHSM bool `json:"rhsm"`
}
// Remote defines the options that can be set for an OSTree Remote configuration.

View file

@ -2372,12 +2372,12 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
// https://weldr.io/lorax/pylorax.api.html#pylorax.api.v0.v0_compose_start
type ComposeRequest struct {
BlueprintName string `json:"blueprint_name"`
ComposeType string `json:"compose_type"`
Size uint64 `json:"size"`
OSTree ostree.SourceSpec `json:"ostree"`
Branch string `json:"branch"`
Upload *uploadRequest `json:"upload"`
BlueprintName string `json:"blueprint_name"`
ComposeType string `json:"compose_type"`
Size uint64 `json:"size"`
OSTree ostree.ImageOptions `json:"ostree"`
Branch string `json:"branch"`
Upload *uploadRequest `json:"upload"`
}
type ComposeReply struct {
BuildID uuid.UUID `json:"build_id"`
@ -2469,12 +2469,6 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
statusResponseError(writer, http.StatusBadRequest, errors)
return
}
ostreeOptions := &ostree.ImageOptions{
ImageRef: cr.OSTree.Ref,
ParentRef: cr.OSTree.Parent,
URL: cr.OSTree.URL,
RHSM: cr.OSTree.RHSM,
}
var size uint64
@ -2495,7 +2489,7 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
options := distro.ImageOptions{
Size: size,
OSTree: ostreeOptions,
OSTree: &cr.OSTree,
}
options.Facts = &facts.ImageOptions{
APIType: facts.WELDR_APITYPE,