ostree: simplify ResolveParams arguments
No need to pass the entire image type. We just need the default ref. This removes the distro package dependency from the ostree package, which we will need so distro can use the ostree types and functions.
This commit is contained in:
parent
b92754b135
commit
102c322ec9
2 changed files with 3 additions and 5 deletions
|
|
@ -9,8 +9,6 @@ import (
|
|||
"path"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
)
|
||||
|
||||
var ostreeRefRE = regexp.MustCompile(`^(?:[\w\d][-._\w\d]*\/)*[\w\d][-._\w\d]*$`)
|
||||
|
|
@ -54,12 +52,12 @@ func ResolveRef(location, ref string) (string, error) {
|
|||
return parent, nil
|
||||
}
|
||||
|
||||
func ResolveParams(params RequestParams, imageType distro.ImageType) (RequestParams, error) {
|
||||
func ResolveParams(params RequestParams, defaultRef string) (RequestParams, error) {
|
||||
resolved := RequestParams{}
|
||||
resolved.Ref = params.Ref
|
||||
// if ref is not provided, use distro default
|
||||
if resolved.Ref == "" {
|
||||
resolved.Ref = imageType.OSTreeRef()
|
||||
resolved.Ref = defaultRef
|
||||
} else if !VerifyRef(params.Ref) { // only verify if specified in params
|
||||
return resolved, fmt.Errorf("Invalid ostree ref %q", params.Ref)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2247,7 +2247,7 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
|
|||
// Fake a parent commit for test requests
|
||||
cr.OSTree.Parent = "02604b2da6e954bd34b8b82a835e5a77d2b60ffa"
|
||||
} else {
|
||||
ostreeParams, err := ostree.ResolveParams(cr.OSTree, imageType)
|
||||
ostreeParams, err := ostree.ResolveParams(cr.OSTree, imageType.OSTreeRef())
|
||||
if err != nil {
|
||||
errors := responseError{
|
||||
ID: "OSTreeOptionsError",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue