Skip to content

Commit 3a318cf

Browse files
committed
bib: use manifestmock.ResolveContainers from images
With that we can compare manifests between bib and images, e.g. ``` $ go build && sudo IMAGE_BUILDER_EXPERIMENTAL=bib-mock-resolvers ./bootc-image-builder manifest -v --type qcow2 quay.io/centos-bootc/centos-bootc:stream9 |jq > bootc_centos_9-x86_64-qcow2-bootc_empty.json && diff -u bootc_centos_9-x86_64-qcow2-bootc_empty.json /tmp/new/bootc_centos_9-x86_64-qcow2-bootc_empty.json ``` to see the difference between bib and images for the same container.
1 parent e52bdf7 commit 3a318cf

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

bib/cmd/bootc-image-builder/main.go

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/osbuild/images/pkg/dnfjson"
2727
"github.com/osbuild/images/pkg/experimentalflags"
2828
"github.com/osbuild/images/pkg/manifest"
29+
"github.com/osbuild/images/pkg/manifestgen/manifestmock"
2930
"github.com/osbuild/images/pkg/osbuild"
3031
"github.com/osbuild/images/pkg/rpmmd"
3132

@@ -140,20 +141,24 @@ func makeManifest(c *ManifestConfig, solver *dnfjson.Solver, cacheRoot string) (
140141
resolver := container.NewResolver(c.Architecture.String())
141142

142143
containerSpecs := make(map[string][]container.Spec)
143-
for plName, sourceSpecs := range mani.GetContainerSourceSpecs() {
144-
for _, c := range sourceSpecs {
145-
resolver.Add(c)
146-
}
147-
specs, err := resolver.Finish()
148-
if err != nil {
149-
return nil, nil, fmt.Errorf("cannot resolve containers: %w", err)
150-
}
151-
for _, spec := range specs {
152-
if spec.Arch != c.Architecture {
153-
return nil, nil, fmt.Errorf("image found is for unexpected architecture %q (expected %q), if that is intentional, please make sure --target-arch matches", spec.Arch, c.Architecture)
144+
if experimentalflags.Bool("bib-mock-resolvers") {
145+
containerSpecs = manifestmock.ResolveContainers(mani.GetContainerSourceSpecs())
146+
} else {
147+
for plName, sourceSpecs := range mani.GetContainerSourceSpecs() {
148+
for _, c := range sourceSpecs {
149+
resolver.Add(c)
150+
}
151+
specs, err := resolver.Finish()
152+
if err != nil {
153+
return nil, nil, fmt.Errorf("cannot resolve containers: %w", err)
154+
}
155+
for _, spec := range specs {
156+
if spec.Arch != c.Architecture {
157+
return nil, nil, fmt.Errorf("image found is for unexpected architecture %q (expected %q), if that is intentional, please make sure --target-arch matches", spec.Arch, c.Architecture)
158+
}
154159
}
160+
containerSpecs[plName] = specs
155161
}
156-
containerSpecs[plName] = specs
157162
}
158163

159164
var opts manifest.SerializeOptions

0 commit comments

Comments
 (0)