job: pass manifest instead of pipeline to osbuild
This is not a behavioral change, as all distros currently use empty source objects. But when we move over to rpm-based pipelines, this will change. Make the same change to osbuild-pipeline, so these stay in sync. Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
parent
919c484c79
commit
571932db37
7 changed files with 31 additions and 29 deletions
|
|
@ -106,14 +106,14 @@ func main() {
|
|||
}
|
||||
|
||||
size := d.GetSizeForOutputType(imageType, 0)
|
||||
pipeline, err := d.Pipeline(blueprint, nil, packageSpecs, buildPackageSpecs, checksums, archArg, imageType, size)
|
||||
manifest, err := d.Manifest(blueprint, nil, packageSpecs, buildPackageSpecs, checksums, archArg, imageType, size)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
bytes, err := json.Marshal(pipeline)
|
||||
bytes, err := json.Marshal(manifest)
|
||||
if err != nil {
|
||||
panic("could not marshal pipeline into JSON")
|
||||
panic("could not marshal manifest into JSON")
|
||||
}
|
||||
|
||||
os.Stdout.Write(bytes)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ type ImageBuild struct {
|
|||
Distro common.Distribution `json:"distro"`
|
||||
QueueStatus common.ImageBuildState `json:"queue_status"`
|
||||
ImageType common.ImageType `json:"image_type"`
|
||||
Pipeline *osbuild.Pipeline `json:"pipeline"`
|
||||
Manifest *osbuild.Manifest `json:"manifest"`
|
||||
Targets []*target.Target `json:"targets"`
|
||||
JobCreated time.Time `json:"job_created"`
|
||||
JobStarted time.Time `json:"job_started"`
|
||||
|
|
@ -35,10 +35,10 @@ type ImageBuild struct {
|
|||
|
||||
// DeepCopy creates a copy of the ImageBuild structure
|
||||
func (ib *ImageBuild) DeepCopy() ImageBuild {
|
||||
var newPipelinePtr *osbuild.Pipeline = nil
|
||||
if ib.Pipeline != nil {
|
||||
pipelineCopy := *ib.Pipeline
|
||||
newPipelinePtr = &pipelineCopy
|
||||
var newManifestPtr *osbuild.Manifest = nil
|
||||
if ib.Manifest != nil {
|
||||
manifestCopy := *ib.Manifest
|
||||
newManifestPtr = &manifestCopy
|
||||
}
|
||||
var newTargets []*target.Target
|
||||
for _, t := range ib.Targets {
|
||||
|
|
@ -51,7 +51,7 @@ func (ib *ImageBuild) DeepCopy() ImageBuild {
|
|||
Distro: ib.Distro,
|
||||
QueueStatus: ib.QueueStatus,
|
||||
ImageType: ib.ImageType,
|
||||
Pipeline: newPipelinePtr,
|
||||
Manifest: newManifestPtr,
|
||||
Targets: newTargets,
|
||||
JobCreated: ib.JobCreated,
|
||||
JobStarted: ib.JobStarted,
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ func (api *API) addJobHandler(writer http.ResponseWriter, request *http.Request,
|
|||
ID: nextJob.ComposeID,
|
||||
ImageBuildID: nextJob.ImageBuildID,
|
||||
Distro: nextJob.Distro,
|
||||
Pipeline: nextJob.Pipeline,
|
||||
Manifest: nextJob.Manifest,
|
||||
Targets: nextJob.Targets,
|
||||
OutputType: nextJob.ImageType,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
package jobqueue_test
|
||||
|
||||
import (
|
||||
distro_mock "github.com/osbuild/osbuild-composer/internal/mocks/distro"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
distro_mock "github.com/osbuild/osbuild-composer/internal/mocks/distro"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
test_distro "github.com/osbuild/osbuild-composer/internal/distro/fedoratest"
|
||||
"github.com/osbuild/osbuild-composer/internal/jobqueue"
|
||||
|
|
@ -60,7 +61,7 @@ func TestCreate(t *testing.T) {
|
|||
}
|
||||
|
||||
test.TestRoute(t, api, false, "POST", "/job-queue/v1/jobs", `{}`, http.StatusCreated,
|
||||
`{"distro":"fedora-30","id":"ffffffff-ffff-ffff-ffff-ffffffffffff","image_build_id":0,"output_type":"qcow2","pipeline":{},"targets":[]}`, "created", "uuid")
|
||||
`{"id":"ffffffff-ffff-ffff-ffff-ffffffffffff","image_build_id":0,"distro":"fedora-30","manifest":{"sources":{},"pipeline":{}},"targets":[],"output_type":"qcow2"}`, "created", "uuid")
|
||||
}
|
||||
|
||||
func testUpdateTransition(t *testing.T, from, to string, expectedStatus int, expectedResponse string) {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ type Job struct {
|
|||
ID uuid.UUID `json:"id"`
|
||||
ImageBuildID int `json:"image_build_id"`
|
||||
Distro string `json:"distro"`
|
||||
Pipeline *osbuild.Pipeline `json:"pipeline"`
|
||||
Manifest *osbuild.Manifest `json:"manifest"`
|
||||
Targets []*target.Target `json:"targets"`
|
||||
OutputType string `json:"output_type"`
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ func (job *Job) Run(uploader LocalTargetUploader) (*common.ComposeResult, error)
|
|||
return nil, fmt.Errorf("error starting osbuild: %v", err)
|
||||
}
|
||||
|
||||
err = json.NewEncoder(stdin).Encode(job.Pipeline)
|
||||
err = json.NewEncoder(stdin).Encode(job.Manifest)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error encoding osbuild pipeline: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ type Job struct {
|
|||
ComposeID uuid.UUID
|
||||
ImageBuildID int
|
||||
Distro string
|
||||
Pipeline *osbuild.Pipeline
|
||||
Manifest *osbuild.Manifest
|
||||
Targets []*target.Target
|
||||
ImageType string
|
||||
}
|
||||
|
|
@ -179,7 +179,7 @@ func New(stateDir *string, distroArg distro.Distro, distroRegistryArg distro.Reg
|
|||
ComposeID: composeID,
|
||||
ImageBuildID: imgBuild.Id,
|
||||
Distro: distroStr,
|
||||
Pipeline: imgBuild.Pipeline,
|
||||
Manifest: imgBuild.Manifest,
|
||||
Targets: imgBuild.Targets,
|
||||
ImageType: imageTypeCompat,
|
||||
}
|
||||
|
|
@ -509,7 +509,7 @@ func (s *Store) PushCompose(composeID uuid.UUID, bp *blueprint.Blueprint, packag
|
|||
repos = append(repos, source.RepoConfig())
|
||||
}
|
||||
|
||||
pipelineStruct, err := s.distro.Pipeline(bp, repos, packages, buildPackages, checksums, arch, composeType, size)
|
||||
manifestStruct, err := s.distro.Manifest(bp, repos, packages, buildPackages, checksums, arch, composeType, size)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -520,7 +520,7 @@ func (s *Store) PushCompose(composeID uuid.UUID, bp *blueprint.Blueprint, packag
|
|||
ImageBuilds: []compose.ImageBuild{
|
||||
{
|
||||
QueueStatus: common.IBWaiting,
|
||||
Pipeline: pipelineStruct,
|
||||
Manifest: manifestStruct,
|
||||
ImageType: imageType,
|
||||
Targets: targets,
|
||||
JobCreated: time.Now(),
|
||||
|
|
@ -534,7 +534,7 @@ func (s *Store) PushCompose(composeID uuid.UUID, bp *blueprint.Blueprint, packag
|
|||
ComposeID: composeID,
|
||||
ImageBuildID: 0,
|
||||
Distro: s.distro.Name(),
|
||||
Pipeline: pipelineStruct,
|
||||
Manifest: manifestStruct,
|
||||
Targets: targets,
|
||||
ImageType: composeType,
|
||||
}
|
||||
|
|
@ -545,7 +545,7 @@ func (s *Store) PushCompose(composeID uuid.UUID, bp *blueprint.Blueprint, packag
|
|||
// PushComposeRequest is an alternative to PushCompose which does not assume a pre-defined distro, as such it is better
|
||||
// suited for RCM API and possible future API that would respect the fact that we can build any distro and any arch
|
||||
func (s *Store) PushComposeRequest(request common.ComposeRequest) error {
|
||||
// This should never happen and once distro.Pipeline is refactored this check will go away
|
||||
// This should never happen and once distro.Manifest is refactored this check will go away
|
||||
arch, exists := request.Arch.ToString()
|
||||
if !exists {
|
||||
panic("fatal error, arch should exist but it does not")
|
||||
|
|
@ -572,12 +572,12 @@ func (s *Store) PushComposeRequest(request common.ComposeRequest) error {
|
|||
for imageBuildID, imageRequest := range request.RequestedImages {
|
||||
// TODO: handle custom upload targets
|
||||
// TODO: this requires changes in the Compose Request struct
|
||||
// This should never happen and once distro.Pipeline is refactored this check will go away
|
||||
// This should never happen and once distro.Manifest is refactored this check will go away
|
||||
imgTypeCompatStr, exists := imageRequest.ImgType.ToCompatString()
|
||||
if !exists {
|
||||
panic("fatal error, image type should exist but it does not")
|
||||
}
|
||||
pipelineStruct, err := distroStruct.Pipeline(&request.Blueprint, request.Repositories, nil, nil, request.Checksums, arch, imgTypeCompatStr, 0)
|
||||
manifestStruct, err := distroStruct.Manifest(&request.Blueprint, request.Repositories, nil, nil, request.Checksums, arch, imgTypeCompatStr, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -594,7 +594,7 @@ func (s *Store) PushComposeRequest(request common.ComposeRequest) error {
|
|||
ComposeID: request.ComposeID,
|
||||
ImageBuildID: imageBuildID,
|
||||
Distro: distroString,
|
||||
Pipeline: pipelineStruct,
|
||||
Manifest: manifestStruct,
|
||||
Targets: []*target.Target{},
|
||||
ImageType: imgTypeCompatStr,
|
||||
})
|
||||
|
|
@ -603,7 +603,7 @@ func (s *Store) PushComposeRequest(request common.ComposeRequest) error {
|
|||
Distro: request.Distro,
|
||||
QueueStatus: common.IBWaiting,
|
||||
ImageType: imageRequest.ImgType,
|
||||
Pipeline: pipelineStruct,
|
||||
Manifest: manifestStruct,
|
||||
Targets: []*target.Target{},
|
||||
JobCreated: time.Now(),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -3,9 +3,6 @@ package weldr
|
|||
import (
|
||||
"archive/tar"
|
||||
"bytes"
|
||||
"github.com/osbuild/osbuild-composer/internal/common"
|
||||
"github.com/osbuild/osbuild-composer/internal/compose"
|
||||
"github.com/osbuild/osbuild-composer/internal/target"
|
||||
"io"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
|
|
@ -15,6 +12,10 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/common"
|
||||
"github.com/osbuild/osbuild-composer/internal/compose"
|
||||
"github.com/osbuild/osbuild-composer/internal/target"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
test_distro "github.com/osbuild/osbuild-composer/internal/distro/fedoratest"
|
||||
rpmmd_mock "github.com/osbuild/osbuild-composer/internal/mocks/rpmmd"
|
||||
|
|
@ -447,11 +448,11 @@ func TestCompose(t *testing.T) {
|
|||
break
|
||||
}
|
||||
|
||||
if composeStruct.ImageBuilds[0].Pipeline == nil {
|
||||
if composeStruct.ImageBuilds[0].Manifest == nil {
|
||||
t.Fatalf("%s: the compose in the store did not contain a blueprint", c.Path)
|
||||
} else {
|
||||
// TODO: find some (reasonable) way to verify the contents of the pipeline
|
||||
composeStruct.ImageBuilds[0].Pipeline = nil
|
||||
composeStruct.ImageBuilds[0].Manifest = nil
|
||||
}
|
||||
|
||||
if diff := cmp.Diff(composeStruct, *c.ExpectedCompose, test.IgnoreDates(), test.IgnoreUuids(), test.Ignore("Targets.Options.Location")); diff != "" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue