distro: allow to return warnings in the Manifest function
This changes the `Manifest` function of the `ImageType` interface so that any warnings detected during the `checkOptions` step of the manifest initialization can be propagated back to the Weldr-API (see next commit). Signed-off-by: Irene Diez <idiez@redhat.com>
This commit is contained in:
parent
d952e41161
commit
8022c227ba
8 changed files with 22 additions and 21 deletions
|
|
@ -458,7 +458,7 @@ func generateManifest(ctx context.Context, workers *worker.Server, depsolveJobID
|
|||
options.OSTree.URL = result.Specs[0].URL
|
||||
}
|
||||
|
||||
manifest, err := imageType.Manifest(b, options, repos, depsolveResults.PackageSpecs, containerSpecs, seed)
|
||||
manifest, _, err := imageType.Manifest(b, options, repos, depsolveResults.PackageSpecs, containerSpecs, seed)
|
||||
if err != nil {
|
||||
reason := "Error generating manifest"
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorManifestGeneration, reason, nil)
|
||||
|
|
|
|||
|
|
@ -118,9 +118,10 @@ type ImageType interface {
|
|||
|
||||
// Returns an osbuild manifest, containing the sources and pipeline necessary
|
||||
// to build an image, given output format with all packages and customizations
|
||||
// specified in the given blueprint. The packageSpecSets must be labelled in
|
||||
// the same way as the originating PackageSets.
|
||||
Manifest(b *blueprint.Customizations, options ImageOptions, repos []rpmmd.RepoConfig, packageSpecSets map[string][]rpmmd.PackageSpec, containers []container.Spec, seed int64) (Manifest, error)
|
||||
// specified in the given blueprint; it also returns any warnings (e.g.
|
||||
// deprecation notices) generated by the manifest.
|
||||
// The packageSpecSets must be labelled in the same way as the originating PackageSets.
|
||||
Manifest(b *blueprint.Customizations, options ImageOptions, repos []rpmmd.RepoConfig, packageSpecSets map[string][]rpmmd.PackageSpec, containers []container.Spec, seed int64) (Manifest, []string, error)
|
||||
}
|
||||
|
||||
// The ImageOptions specify options for a specific image build
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ func TestImageTypePipelineNames(t *testing.T) {
|
|||
packageSets[plName] = minimalPackageSet
|
||||
}
|
||||
|
||||
m, err := imageType.Manifest(bp.Customizations, options, repos, packageSets, containers, seed)
|
||||
m, _, err := imageType.Manifest(bp.Customizations, options, repos, packageSets, containers, seed)
|
||||
require.NoError(err)
|
||||
pm := new(manifest)
|
||||
err = json.Unmarshal(m, pm)
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ func TestDistro_Manifest(t *testing.T, pipelinePath string, prefix string, regis
|
|||
imgPackageSpecSets = tt.PackageSpecSets
|
||||
}
|
||||
|
||||
got, err := imageType.Manifest(tt.ComposeRequest.Blueprint.Customizations,
|
||||
got, _, err := imageType.Manifest(tt.ComposeRequest.Blueprint.Customizations,
|
||||
options,
|
||||
repos,
|
||||
imgPackageSpecSets,
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ func (t *TestImageType) Exports() []string {
|
|||
return distro.ExportsFallback()
|
||||
}
|
||||
|
||||
func (t *TestImageType) Manifest(b *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSpecSets map[string][]rpmmd.PackageSpec, containers []container.Spec, seed int64) (distro.Manifest, error) {
|
||||
func (t *TestImageType) Manifest(b *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSpecSets map[string][]rpmmd.PackageSpec, containers []container.Spec, seed int64) (distro.Manifest, []string, error) {
|
||||
mountpoints := b.GetFilesystems()
|
||||
|
||||
invalidMountpoints := []string{}
|
||||
|
|
@ -250,15 +250,15 @@ func (t *TestImageType) Manifest(b *blueprint.Customizations, options distro.Ima
|
|||
}
|
||||
|
||||
if len(invalidMountpoints) > 0 {
|
||||
return nil, fmt.Errorf("The following custom mountpoints are not supported %+q", invalidMountpoints)
|
||||
return nil, nil, fmt.Errorf("The following custom mountpoints are not supported %+q", invalidMountpoints)
|
||||
}
|
||||
|
||||
return json.Marshal(
|
||||
ret, err := json.Marshal(
|
||||
osbuild.Manifest{
|
||||
Sources: osbuild.Sources{},
|
||||
Pipelines: []osbuild.Pipeline{},
|
||||
},
|
||||
)
|
||||
})
|
||||
return ret, nil, err
|
||||
}
|
||||
|
||||
// newTestDistro returns a new instance of TestDistro with the
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ func FixtureBase() *Store {
|
|||
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, nil, nil, 0)
|
||||
manifest, _, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil, nil, 0)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("failed to create a manifest: %v", err))
|
||||
}
|
||||
|
|
@ -188,7 +188,7 @@ func FixtureFinished() *Store {
|
|||
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, nil, nil, 0)
|
||||
manifest, _, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil, nil, 0)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("failed to create a manifest: %v", err))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ func (suite *storeTest) SetupSuite() {
|
|||
suite.myDistro = test_distro.New()
|
||||
suite.myArch, _ = suite.myDistro.GetArch(test_distro.TestArchName)
|
||||
suite.myImageType, _ = suite.myArch.GetImageType(test_distro.TestImageTypeName)
|
||||
suite.myManifest, _ = suite.myImageType.Manifest(&suite.myCustomizations, suite.myImageOptions, suite.myRepoConfig, nil, nil, 0)
|
||||
suite.myManifest, _, _ = suite.myImageType.Manifest(&suite.myCustomizations, suite.myImageOptions, suite.myRepoConfig, nil, nil, 0)
|
||||
suite.mySourceConfig = SourceConfig{
|
||||
Name: "testSourceConfig",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,7 +129,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, nil, nil, 0)
|
||||
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, nil, 0)
|
||||
if err != nil {
|
||||
t.Fatalf("error creating osbuild manifest: %v", err)
|
||||
}
|
||||
|
|
@ -154,7 +154,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, nil, nil, 0)
|
||||
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, nil, 0)
|
||||
if err != nil {
|
||||
t.Fatalf("error creating osbuild manifest: %v", err)
|
||||
}
|
||||
|
|
@ -191,7 +191,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, nil, nil, 0)
|
||||
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, nil, 0)
|
||||
if err != nil {
|
||||
t.Fatalf("error creating osbuild manifest: %v", err)
|
||||
}
|
||||
|
|
@ -221,7 +221,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, nil, nil, 0)
|
||||
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, nil, 0)
|
||||
require.NoError(t, err)
|
||||
|
||||
server := newTestServer(t, t.TempDir(), time.Duration(0), "/api/worker/v1", false)
|
||||
|
|
@ -267,7 +267,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, nil, nil, 0)
|
||||
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, nil, 0)
|
||||
if err != nil {
|
||||
t.Fatalf("error creating osbuild manifest: %v", err)
|
||||
}
|
||||
|
|
@ -297,7 +297,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, nil, nil, 0)
|
||||
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, nil, 0)
|
||||
if err != nil {
|
||||
t.Fatalf("error creating osbuild manifest: %v", err)
|
||||
}
|
||||
|
|
@ -327,7 +327,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, nil, nil, 0)
|
||||
manifest, _, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, nil, 0)
|
||||
if err != nil {
|
||||
t.Fatalf("error creating osbuild manifest: %v", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue