diff --git a/cmd/osbuild-worker/jobimpl-ostree-resolve.go b/cmd/osbuild-worker/jobimpl-ostree-resolve.go index 227c0f759..13622dbda 100644 --- a/cmd/osbuild-worker/jobimpl-ostree-resolve.go +++ b/cmd/osbuild-worker/jobimpl-ostree-resolve.go @@ -58,7 +58,7 @@ func (impl *OSTreeResolveJobImpl) Run(job worker.Job) error { RHSM: s.RHSM, } - ref, checksum, err := ostree.ResolveParams(reqParams) + ref, checksum, err := ostree.Resolve(reqParams) if err != nil { logWithId.Infof("Resolving ostree params failed: %v", err) setError(err, &result) diff --git a/internal/ostree/ostree.go b/internal/ostree/ostree.go index 4fe37b7ac..22b2d3952 100644 --- a/internal/ostree/ostree.go +++ b/internal/ostree/ostree.go @@ -134,45 +134,45 @@ func ResolveRef(location, ref string, consumerCerts bool, subs *rhsm.Subscriptio return parent, nil } -// ResolveParams resolves the ostree request parameters into the necessary ref -// for the image build pipeline and a commit (checksum) to be fetched. +// Resolve the ostree source specification into the necessary ref for the image +// build pipeline and a commit (checksum) to be fetched. // -// If a URL is defined in the RequestParams, the checksum of the Parent ref is -// resolved, otherwise the checksum is an empty string. Specifying Parent -// without URL results in a ParameterComboError. Failure to resolve the +// If a URL is defined in the source specification, the checksum of the Parent +// ref is resolved, otherwise the checksum is an empty string. Specifying +// Parent without URL results in a ParameterComboError. Failure to resolve the // checksum results in a ResolveRefError. // // If Parent is not specified in the RequestParams, the value of Ref is used. // // If any ref (Ref or Parent) is malformed, the function returns with a RefError. -func ResolveParams(params SourceSpec) (ref, checksum string, err error) { - ref = params.Ref +func Resolve(source SourceSpec) (ref, checksum string, err error) { + ref = source.Ref // Determine value of ref - if !VerifyRef(params.Ref) { - return "", "", NewRefError("Invalid ostree ref %q", params.Ref) + if !VerifyRef(source.Ref) { + return "", "", NewRefError("Invalid ostree ref %q", source.Ref) } // Determine value of parentRef - parentRef := params.Parent + parentRef := source.Parent if parentRef != "" { // verify format of parent ref - if !VerifyRef(params.Parent) { - return "", "", NewRefError("Invalid ostree parent ref %q", params.Parent) + if !VerifyRef(source.Parent) { + return "", "", NewRefError("Invalid ostree parent ref %q", source.Parent) } - if params.URL == "" { + if source.URL == "" { // specifying parent ref also requires URL return "", "", NewParameterComboError("ostree parent ref specified, but no URL to retrieve it") } } else { // if parent is not provided, use ref - parentRef = params.Ref + parentRef = source.Ref } // Resolve parent checksum - if params.URL != "" { + if source.URL != "" { // If a URL is specified, we need to fetch the commit at the URL. - parent, err := ResolveRef(params.URL, parentRef, params.RHSM, nil, nil) + parent, err := ResolveRef(source.URL, parentRef, source.RHSM, nil, nil) if err != nil { return "", "", err // ResolveRefError } diff --git a/internal/weldr/api.go b/internal/weldr/api.go index ad890d02a..65893fe81 100644 --- a/internal/weldr/api.go +++ b/internal/weldr/api.go @@ -2463,7 +2463,7 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request if reqParams.Ref == "" { reqParams.Ref = imageType.OSTreeRef() } - ref, checksum, err := ostree.ResolveParams(reqParams) + ref, checksum, err := ostree.Resolve(reqParams) if err != nil { errors := responseError{ ID: "OSTreeOptionsError",