The FetchChecksum on ostree.ImageOptions was the resolved commit ID of the parent ref to be pulled (for ostree commits and containers) or the commit ID of the content ref (for ostree installers and raw images). With the new process of manifest creation and serialisation, using the image options to transport resolved content references is bad and confusing. Image options should only reflect user and image type options before any references are resolved. With this change, the ostree.ImageOptions should only reflect the ostree-related options specified by the user. Commit IDs will only be available after the manifest is initialised when the commit sources are resolved (before serialisation).
63 lines
1.4 KiB
Go
63 lines
1.4 KiB
Go
// Simple tool to dump a JSON object containing all package sets for a specific
|
|
// distro x arch x image type.
|
|
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
|
"github.com/osbuild/osbuild-composer/internal/distro"
|
|
"github.com/osbuild/osbuild-composer/internal/distroregistry"
|
|
"github.com/osbuild/osbuild-composer/internal/ostree"
|
|
)
|
|
|
|
func main() {
|
|
var distroName string
|
|
var archName string
|
|
var imageName string
|
|
|
|
flag.StringVar(&distroName, "distro", "", "Distribution name")
|
|
flag.StringVar(&archName, "arch", "", "Architecture name")
|
|
flag.StringVar(&imageName, "image", "", "Image name")
|
|
flag.Parse()
|
|
|
|
if distroName == "" || archName == "" || imageName == "" {
|
|
flag.Usage()
|
|
os.Exit(1)
|
|
}
|
|
|
|
dr := distroregistry.NewDefault()
|
|
|
|
d := dr.GetDistro(distroName)
|
|
if d == nil {
|
|
panic(fmt.Errorf("Distro %q does not exist", distroName))
|
|
}
|
|
|
|
arch, err := d.GetArch(archName)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
image, err := arch.GetImageType(imageName)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
encoder := json.NewEncoder(os.Stdout)
|
|
encoder.SetIndent("", " ")
|
|
options := distro.ImageOptions{
|
|
OSTree: &ostree.ImageOptions{
|
|
URL: "foo",
|
|
ImageRef: "bar",
|
|
ParentRef: "baz",
|
|
},
|
|
}
|
|
manifest, _, err := image.Manifest(&blueprint.Blueprint{}, options, nil, 0)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
_ = encoder.Encode(manifest.Content.PackageSets)
|
|
}
|