ostree: rename CommitSource to CommitSpec and add Ref

The CommitSource was used to specify the source URL and checksum of a
commit for use in manifest sources.  Renaming to CommitSpec and adding a
Ref parameter generalises the type so that we can use it to specify
commits in various situations.  This is building towards separating when
ostree parameters are used for fetching a commit, fetching a parent
commit, and building one.

The CommitSpec is (very roughly) analogous to the rpmmd.PackageSpec.
This commit is contained in:
Achilleas Koutsou 2022-09-30 14:05:55 +02:00 committed by Tomáš Hozza
parent 938bc7bafd
commit c6b999f178
5 changed files with 17 additions and 11 deletions

View file

@ -546,9 +546,9 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations,
}
// handle OSTree commit inputs
var commits []ostree.CommitSource
var commits []ostree.CommitSpec
if options.OSTree.Parent != "" && options.OSTree.URL != "" {
commits = []ostree.CommitSource{{Checksum: options.OSTree.Parent, URL: options.OSTree.URL}}
commits = []ostree.CommitSpec{{Checksum: options.OSTree.Parent, URL: options.OSTree.URL}}
}
// handle inline sources

View file

@ -512,9 +512,9 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations,
}
// handle OSTree commit inputs
var commits []ostree.CommitSource
var commits []ostree.CommitSpec
if options.OSTree.Parent != "" && options.OSTree.URL != "" {
commits = []ostree.CommitSource{{Checksum: options.OSTree.Parent, URL: options.OSTree.URL}}
commits = []ostree.CommitSpec{{Checksum: options.OSTree.Parent, URL: options.OSTree.URL}}
}
// handle inline sources

View file

@ -61,14 +61,14 @@ func (m Manifest) GetPackageSetChains() map[string][]rpmmd.PackageSet {
func (m Manifest) Serialize(packageSets map[string][]rpmmd.PackageSpec) (distro.Manifest, error) {
pipelines := make([]osbuild.Pipeline, 0)
packages := make([]rpmmd.PackageSpec, 0)
commits := make([]ostree.CommitSource, 0)
commits := make([]ostree.CommitSpec, 0)
inline := make([]string, 0)
for _, pipeline := range m.pipelines {
pipeline.serializeStart(packageSets[pipeline.Name()])
}
for _, pipeline := range m.pipelines {
for _, commit := range pipeline.getOSTreeCommits() {
commits = append(commits, ostree.CommitSource{
commits = append(commits, ostree.CommitSpec{
Checksum: commit.checksum, URL: commit.url,
})
}

View file

@ -54,7 +54,7 @@ func (sources *Sources) UnmarshalJSON(data []byte) error {
return nil
}
func GenSources(packages []rpmmd.PackageSpec, ostreeCommits []ostree.CommitSource, inlineData []string, containers []container.Spec) Sources {
func GenSources(packages []rpmmd.PackageSpec, ostreeCommits []ostree.CommitSpec, inlineData []string, containers []container.Spec) Sources {
sources := Sources{}
curl := &CurlSource{
Items: make(map[string]CurlSourceItem),

View file

@ -18,11 +18,17 @@ type RequestParams struct {
Parent string `json:"parent"`
}
// CommitSource defines the source URL from which to fetch a specific commit
// identified by its checksum.
type CommitSource struct {
// CommitSpec specifies an ostree commit using any combination of Ref (branch), URL (source), and Checksum (commit ID).
type CommitSpec struct {
// Ref for the commit. Can be empty.
Ref string
// URL of the repo where the commit can be fetched, if available.
URL string
// Checksum of the commit.
Checksum string
URL string
}
// Remote defines the options that can be set for an OSTree Remote configuration.