distro: use the ostree URL when checking options
The checksum won't be resolved before initialising the manifest (where checkOptions() is called), so we can't rely on it for validating options. Instead, we can just make sure that the URL was provided, when required by the image type. Also, if a parent ref is specified in the options, a URL *must* be specified regardless of image type, so verify this combination here and return the same error message that is returned from ostree.Resolve(). The parameter combination check will soon be removed from the ostree.Resolve() function.
This commit is contained in:
parent
5c921f0b27
commit
8a0f3ce4a3
3 changed files with 31 additions and 16 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue