Skip to content

Commit

Permalink
many: update images Manifest() API for PR#1107
Browse files Browse the repository at this point in the history
This updates composer to use the updated API in images around the
seed handling for manifests, see images PR#1107 for details.

Note that this has no semantic changes yet. We could now simplfy
some things because images will auto-seed but that is for a followup.
  • Loading branch information
mvo5 authored and thozza committed Jan 20, 2025
1 parent 9dd8b2c commit af0543d
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion cmd/gen-manifests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func makeManifestJob(name string, imgType distro.ImageType, cr composeRequest, d
}
}

manifest, _, err := imgType.Manifest(&bp, options, repos, seedArg)
manifest, _, err := imgType.Manifest(&bp, options, repos, &seedArg)
if err != nil {
err = fmt.Errorf("[%s] failed: %s", filename, err)
return
Expand Down
4 changes: 2 additions & 2 deletions cmd/osbuild-dnf-json-tests/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestCrossArchDepsolve(t *testing.T) {
Customizations: customizations,
},
options,
repos[archStr], 0)
repos[archStr], nil)
assert.NoError(t, err)

for _, set := range manifest.GetPackageSetChains() {
Expand Down Expand Up @@ -105,7 +105,7 @@ func TestDepsolvePackageSets(t *testing.T) {
qcow2Image, err := x86Arch.GetImageType(qcow2ImageTypeName)
require.Nilf(t, err, "failed to get %q image type of %q/%q distro/arch", qcow2ImageTypeName, cs9.Name(), arch.ARCH_X86_64.String())

manifestSource, _, err := qcow2Image.Manifest(&blueprint.Blueprint{Packages: []blueprint.Package{{Name: "bind"}}}, distro.ImageOptions{}, x86Repos, 0)
manifestSource, _, err := qcow2Image.Manifest(&blueprint.Blueprint{Packages: []blueprint.Package{{Name: "bind"}}}, distro.ImageOptions{}, x86Repos, nil)
require.Nilf(t, err, "failed to initialise manifest for %q image type of %q/%q distro/arch", qcow2ImageTypeName, cs9.Name(), arch.ARCH_X86_64.String())
imagePkgSets := manifestSource.GetPackageSetChains()

Expand Down
2 changes: 1 addition & 1 deletion cmd/osbuild-store-dump/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

func getManifest(bp blueprint.Blueprint, t distro.ImageType, a distro.Arch, d distro.Distro, cacheDir string, repos []rpmmd.RepoConfig) (manifest.OSBuildManifest, []rpmmd.PackageSpec) {
ibp := blueprint.Convert(bp)
manifest, _, err := t.Manifest(&ibp, distro.ImageOptions{}, repos, 0)
manifest, _, err := t.Manifest(&ibp, distro.ImageOptions{}, repos, nil)
if err != nil {
panic(err)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/cloudapi/v2/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (s *Server) enqueueCompose(irs []imageRequest, channel string) (uuid.UUID,
arch := ir.imageType.Arch()
distribution := arch.Distro()

manifestSource, _, err := ir.imageType.Manifest(&ibp, ir.imageOptions, ir.repositories, ir.manifestSeed)
manifestSource, _, err := ir.imageType.Manifest(&ibp, ir.imageOptions, ir.repositories, &ir.manifestSeed)
if err != nil {
logrus.Warningf("ErrorEnqueueingJob, failed generating manifest: %v", err)
return id, HTTPErrorWithInternal(ErrorEnqueueingJob, err)
Expand Down Expand Up @@ -287,14 +287,14 @@ func (s *Server) enqueueKojiCompose(taskID uint64, server, name, version, releas

var kojiFilenames []string
var buildIDs []uuid.UUID
for _, ir := range irs {
for idx, ir := range irs {
ibp := blueprint.Convert(ir.blueprint)

// shortcuts
arch := ir.imageType.Arch()
distribution := arch.Distro()

manifestSource, _, err := ir.imageType.Manifest(&ibp, ir.imageOptions, ir.repositories, ir.manifestSeed)
manifestSource, _, err := ir.imageType.Manifest(&ibp, ir.imageOptions, ir.repositories, &irs[idx].manifestSeed)
if err != nil {
logrus.Errorf("ErrorEnqueueingJob, failed generating manifest: %v", err)
return id, HTTPErrorWithInternal(ErrorEnqueueingJob, err)
Expand Down
6 changes: 3 additions & 3 deletions internal/store/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func FixtureBase(hostDistroName, hostArchName string) *Fixture {
if err != nil {
panic(fmt.Sprintf("failed to get image type %s for a test distro architecture: %v", test_distro.TestImageTypeName, err))
}
manifest, _, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, 0)
manifest, _, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil)
if err != nil {
panic(fmt.Sprintf("failed to create a manifest: %v", err))
}
Expand Down Expand Up @@ -231,7 +231,7 @@ func FixtureFinished(hostDistroName, hostArchName string) *Fixture {
if err != nil {
panic(fmt.Sprintf("failed to get image type %s for a test distro architecture: %v", test_distro.TestImageTypeName, err))
}
manifest, _, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, 0)
manifest, _, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil)
if err != nil {
panic(fmt.Sprintf("failed to create a manifest: %v", err))
}
Expand Down Expand Up @@ -465,7 +465,7 @@ func FixtureJobs(hostDistroName, hostArchName string) *Fixture {
if err != nil {
panic(fmt.Sprintf("failed to get image type %s for a test distro architecture: %v", test_distro.TestImageTypeName, err))
}
manifest, _, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, 0)
manifest, _, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil)
if err != nil {
panic(fmt.Sprintf("failed to create a manifest: %v", err))
}
Expand Down
2 changes: 1 addition & 1 deletion internal/store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (suite *storeTest) SetupSuite() {
suite.myImageType, err = suite.myArch.GetImageType(test_distro.TestImageTypeName)
suite.NoError(err)
ibp := blueprint.Convert(suite.myBP)
manifest, _, _ := suite.myImageType.Manifest(&ibp, suite.myImageOptions, suite.myRepoConfig, 0)
manifest, _, _ := suite.myImageType.Manifest(&ibp, suite.myImageOptions, suite.myRepoConfig, nil)
suite.myManifest, _ = manifest.Serialize(nil, nil, nil, nil)
suite.mySourceConfig = SourceConfig{
Name: "testSourceConfig",
Expand Down
2 changes: 1 addition & 1 deletion internal/weldr/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2567,7 +2567,7 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
}

ibp := blueprint.Convert(*bp)
manifest, warnings, err := imageType.Manifest(&ibp, options, imageRepos, seed)
manifest, warnings, err := imageType.Manifest(&ibp, options, imageRepos, &seed)
if err != nil {
errors := responseError{
ID: "ManifestCreationFailed",
Expand Down
10 changes: 5 additions & 5 deletions internal/weldr/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ func TestCompose(t *testing.T) {
require.NoError(t, err)
imgType, err := arch.GetImageType(test_distro.TestImageTypeName)
require.NoError(t, err)
manifest, _, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, 0)
manifest, _, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil)
require.NoError(t, err)

rPkgs, rContainers, rCommits := ResolveContent(manifest.GetPackageSetChains(), manifest.GetContainerSourceSpecs(), manifest.GetOSTreeSourceSpecs())
Expand All @@ -1012,7 +1012,7 @@ func TestCompose(t *testing.T) {
ostreeImgType, err := arch.GetImageType(test_distro.TestImageTypeOSTree)
require.NoError(t, err)
ostreeOptions := ostree.ImageOptions{URL: ostreeRepoDefault.Server.URL}
ostreeManifest, _, err := ostreeImgType.Manifest(nil, distro.ImageOptions{OSTree: &ostreeOptions}, nil, 0)
ostreeManifest, _, err := ostreeImgType.Manifest(nil, distro.ImageOptions{OSTree: &ostreeOptions}, nil, nil)
require.NoError(t, err)

rPkgs, rContainers, rCommits = ResolveContent(ostreeManifest.GetPackageSetChains(), ostreeManifest.GetContainerSourceSpecs(), ostreeManifest.GetOSTreeSourceSpecs())
Expand Down Expand Up @@ -1123,7 +1123,7 @@ func TestCompose(t *testing.T) {
}

ostreeOptionsOther := ostree.ImageOptions{ImageRef: otherRef, URL: ostreeRepoOther.Server.URL}
ostreeManifestOther, _, err := ostreeImgType.Manifest(nil, distro.ImageOptions{OSTree: &ostreeOptionsOther}, nil, 0)
ostreeManifestOther, _, err := ostreeImgType.Manifest(nil, distro.ImageOptions{OSTree: &ostreeOptionsOther}, nil, nil)
require.NoError(t, err)

rPkgs, rContainers, rCommits = ResolveContent(ostreeManifestOther.GetPackageSetChains(), ostreeManifestOther.GetContainerSourceSpecs(), ostreeManifestOther.GetOSTreeSourceSpecs())
Expand Down Expand Up @@ -1166,7 +1166,7 @@ func TestCompose(t *testing.T) {
require.NoError(t, err)
imgType2, err := arch2.GetImageType(test_distro.TestImageTypeName)
require.NoError(t, err)
manifest2, _, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, 0)
manifest2, _, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil)
require.NoError(t, err)

rPkgs, rContainers, rCommits = ResolveContent(manifest2.GetPackageSetChains(), manifest2.GetContainerSourceSpecs(), manifest2.GetOSTreeSourceSpecs())
Expand Down Expand Up @@ -2204,7 +2204,7 @@ func TestComposePOST_ImageTypeDenylist(t *testing.T) {
require.NoError(t, err)
imgType2, err := arch.GetImageType(test_distro.TestImageType2Name)
require.NoError(t, err)
manifest, _, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, 0)
manifest, _, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil)
require.NoError(t, err)

rPkgs, rContainers, rCommits := ResolveContent(manifest.GetPackageSetChains(), manifest.GetContainerSourceSpecs(), manifest.GetOSTreeSourceSpecs())
Expand Down
4 changes: 2 additions & 2 deletions internal/weldr/compose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestComposeStatusFromLegacyError(t *testing.T) {
if err != nil {
t.Fatalf("error getting image type from arch: %v", err)
}
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, 0)
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil)
if err != nil {
t.Fatalf("error creating osbuild manifest: %v", err)
}
Expand Down Expand Up @@ -90,7 +90,7 @@ func TestComposeStatusFromJobError(t *testing.T) {
if err != nil {
t.Fatalf("error getting image type from arch: %v", err)
}
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, 0)
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil)
if err != nil {
t.Fatalf("error creating osbuild manifest: %v", err)
}
Expand Down
18 changes: 9 additions & 9 deletions internal/worker/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func TestCreate(t *testing.T) {
if err != nil {
t.Fatalf("error getting image type from arch: %v", err)
}
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, 0)
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil)
if err != nil {
t.Fatalf("error creating osbuild manifest: %v", err)
}
Expand Down Expand Up @@ -178,7 +178,7 @@ func TestCancel(t *testing.T) {
if err != nil {
t.Fatalf("error getting image type from arch: %v", err)
}
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, 0)
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil)
if err != nil {
t.Fatalf("error creating osbuild manifest: %v", err)
}
Expand Down Expand Up @@ -222,7 +222,7 @@ func TestUpdate(t *testing.T) {
if err != nil {
t.Fatalf("error getting image type from arch: %v", err)
}
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, 0)
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil)
if err != nil {
t.Fatalf("error creating osbuild manifest: %v", err)
}
Expand Down Expand Up @@ -261,7 +261,7 @@ func TestArgs(t *testing.T) {
require.NoError(t, err)
imageType, err := arch.GetImageType(test_distro.TestImageTypeName)
require.NoError(t, err)
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, 0)
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil)
require.NoError(t, err)

mf, err := manifest.Serialize(nil, nil, nil, nil)
Expand Down Expand Up @@ -310,7 +310,7 @@ func TestUpload(t *testing.T) {
if err != nil {
t.Fatalf("error getting image type from arch: %v", err)
}
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, 0)
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil)
if err != nil {
t.Fatalf("error creating osbuild manifest: %v", err)
}
Expand Down Expand Up @@ -346,7 +346,7 @@ func TestUploadNotAcceptingArtifacts(t *testing.T) {
if err != nil {
t.Fatalf("error getting image type from arch: %v", err)
}
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, 0)
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil)
if err != nil {
t.Fatalf("error creating osbuild manifest: %v", err)
}
Expand Down Expand Up @@ -380,7 +380,7 @@ func TestUploadAlteredBasePath(t *testing.T) {
if err != nil {
t.Fatalf("error getting image type from arch: %v", err)
}
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, 0)
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil)
if err != nil {
t.Fatalf("error creating osbuild manifest: %v", err)
}
Expand Down Expand Up @@ -1554,7 +1554,7 @@ func TestRequestJobForWorker(t *testing.T) {
if err != nil {
t.Fatalf("error getting image type from arch: %v", err)
}
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, 0)
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil)
if err != nil {
t.Fatalf("error creating osbuild manifest: %v", err)
}
Expand Down Expand Up @@ -1589,7 +1589,7 @@ func TestJobHeartbeats(t *testing.T) {
if err != nil {
t.Fatalf("error getting image type from arch: %v", err)
}
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, 0)
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil)
if err != nil {
t.Fatalf("error creating osbuild manifest: %v", err)
}
Expand Down

0 comments on commit af0543d

Please sign in to comment.