diff --git a/internal/distro/fedora/imagetype.go b/internal/distro/fedora/imagetype.go index 4a5313efd..86a3068a5 100644 --- a/internal/distro/fedora/imagetype.go +++ b/internal/distro/fedora/imagetype.go @@ -14,6 +14,7 @@ import ( "github.com/osbuild/osbuild-composer/internal/image" "github.com/osbuild/osbuild-composer/internal/manifest" "github.com/osbuild/osbuild-composer/internal/oscap" + "github.com/osbuild/osbuild-composer/internal/ostree" "github.com/osbuild/osbuild-composer/internal/pathpolicy" "github.com/osbuild/osbuild-composer/internal/platform" "github.com/osbuild/osbuild-composer/internal/rpmmd" @@ -247,14 +248,18 @@ func (t *imageType) checkOptions(bp *blueprint.Blueprint, options distro.ImageOp return nil, fmt.Errorf("embedding containers is not supported for %s on %s", t.name, t.arch.distro.name) } - ostreeChecksum := "" + ostreeURL := "" if options.OSTree != nil { - ostreeChecksum = options.OSTree.ParentRef + if options.OSTree.ParentRef != "" && options.OSTree.URL == "" { + // specifying parent ref also requires URL + return nil, ostree.NewParameterComboError("ostree parent ref specified, but no URL to retrieve it") + } + ostreeURL = options.OSTree.URL } if t.bootISO && t.rpmOstree { - // check the checksum instead of the URL, because the URL should have been used to resolve the checksum and we need both - if ostreeChecksum == "" { + // ostree-based ISOs require a URL from which to pull a payload commit + if ostreeURL == "" { return nil, fmt.Errorf("boot ISO image type %q requires specifying a URL from which to retrieve the OSTree commit", t.name) } } diff --git a/internal/distro/rhel8/imagetype.go b/internal/distro/rhel8/imagetype.go index 9d1c25469..ef41855d6 100644 --- a/internal/distro/rhel8/imagetype.go +++ b/internal/distro/rhel8/imagetype.go @@ -17,6 +17,7 @@ import ( "github.com/osbuild/osbuild-composer/internal/image" "github.com/osbuild/osbuild-composer/internal/manifest" "github.com/osbuild/osbuild-composer/internal/oscap" + "github.com/osbuild/osbuild-composer/internal/ostree" "github.com/osbuild/osbuild-composer/internal/pathpolicy" "github.com/osbuild/osbuild-composer/internal/platform" "github.com/osbuild/osbuild-composer/internal/rpmmd" @@ -313,14 +314,18 @@ func (t *imageType) checkOptions(bp *blueprint.Blueprint, options distro.ImageOp return warnings, fmt.Errorf("embedding containers is not supported for %s on %s", t.name, t.arch.distro.name) } - ostreeChecksum := "" + ostreeURL := "" if options.OSTree != nil { - ostreeChecksum = options.OSTree.ParentRef + if options.OSTree.ParentRef != "" && options.OSTree.URL == "" { + // specifying parent ref also requires URL + return nil, ostree.NewParameterComboError("ostree parent ref specified, but no URL to retrieve it") + } + ostreeURL = options.OSTree.URL } if t.bootISO && t.rpmOstree { - // check the checksum instead of the URL, because the URL should have been used to resolve the checksum and we need both - if ostreeChecksum == "" { + // ostree-based ISOs require a URL from which to pull a payload commit + if ostreeURL == "" { return warnings, fmt.Errorf("boot ISO image type %q requires specifying a URL from which to retrieve the OSTree commit", t.name) } @@ -360,8 +365,8 @@ func (t *imageType) checkOptions(bp *blueprint.Blueprint, options distro.ImageOp } if t.name == "edge-raw-image" { - // check the checksum instead of the URL, because the URL should have been used to resolve the checksum and we need both - if ostreeChecksum == "" { + // ostree-based bootable images require a URL from which to pull a payload commit + if ostreeURL == "" { return warnings, fmt.Errorf("edge raw images require specifying a URL from which to retrieve the OSTree commit") } diff --git a/internal/distro/rhel9/imagetype.go b/internal/distro/rhel9/imagetype.go index 0843d9a6a..cefc8d10d 100644 --- a/internal/distro/rhel9/imagetype.go +++ b/internal/distro/rhel9/imagetype.go @@ -17,6 +17,7 @@ import ( "github.com/osbuild/osbuild-composer/internal/image" "github.com/osbuild/osbuild-composer/internal/manifest" "github.com/osbuild/osbuild-composer/internal/oscap" + "github.com/osbuild/osbuild-composer/internal/ostree" "github.com/osbuild/osbuild-composer/internal/pathpolicy" "github.com/osbuild/osbuild-composer/internal/platform" "github.com/osbuild/osbuild-composer/internal/rpmmd" @@ -284,14 +285,18 @@ func (t *imageType) checkOptions(bp *blueprint.Blueprint, options distro.ImageOp return warnings, fmt.Errorf("embedding containers is not supported for %s on %s", t.name, t.arch.distro.name) } - ostreeChecksum := "" + ostreeURL := "" if options.OSTree != nil { - ostreeChecksum = options.OSTree.ParentRef + if options.OSTree.ParentRef != "" && options.OSTree.URL == "" { + // specifying parent ref also requires URL + return nil, ostree.NewParameterComboError("ostree parent ref specified, but no URL to retrieve it") + } + ostreeURL = options.OSTree.URL } if t.bootISO && t.rpmOstree { - // check the checksum instead of the URL, because the URL should have been used to resolve the checksum and we need both - if ostreeChecksum == "" { + // ostree-based ISOs require a URL from which to pull a payload commit + if ostreeURL == "" { return warnings, fmt.Errorf("boot ISO image type %q requires specifying a URL from which to retrieve the OSTree commit", t.name) } @@ -342,8 +347,8 @@ func (t *imageType) checkOptions(bp *blueprint.Blueprint, options distro.ImageOp } if t.name == "edge-raw-image" || t.name == "edge-ami" { - // check the checksum instead of the URL, because the URL should have been used to resolve the checksum and we need both - if ostreeChecksum == "" { + // ostree-based bootable images require a URL from which to pull a payload commit + if ostreeURL == "" { return warnings, fmt.Errorf("%q images require specifying a URL from which to retrieve the OSTree commit", t.name) }