ostree: rewrite Resolve() to take SourceSpec and return CommitSpec

The Resolve() function is now only responsible for resolving a
SourceSpec to a CommitSpec.  It only resolves a checksum if a URL is set
and sets the option for the RHSM secrets.

The Parent has been removed from the SourceSpec.  The SourceSpec is a
simple reference to a single ostree ref and has no connection with the
ostree options.
This commit is contained in:
Achilleas Koutsou 2023-06-06 16:55:50 +02:00 committed by Ondřej Budai
parent 3a42770548
commit 7e2855bbb3
4 changed files with 35 additions and 56 deletions

View file

@ -2341,21 +2341,19 @@ func (api *API) resolveOSTreeCommits(sourceSpecs map[string][]ostree.SourceSpec,
for name, sources := range sourceSpecs {
commits := make([]ostree.CommitSpec, len(sources))
for idx, source := range sources {
var ref, checksum string
if test {
checksum = fmt.Sprintf("%x", sha256.Sum256([]byte(source.URL+source.Ref)))
ref = source.Ref
checksum := fmt.Sprintf("%x", sha256.Sum256([]byte(source.URL+source.Ref)))
commits[idx] = ostree.CommitSpec{
Ref: source.Ref,
URL: source.URL,
Checksum: checksum,
}
} else {
var err error
ref, checksum, err = ostree.Resolve(source)
commit, err := ostree.Resolve(source)
if err != nil {
return nil, err
}
}
commits[idx] = ostree.CommitSpec{
Ref: ref,
URL: source.URL,
Checksum: checksum,
commits[idx] = commit
}
}
commitSpecs[name] = commits