distro: simplify checkOptions() arguments
Make checkOptions() take the whole blueprint and options. There is no need to pass in the resolved containers separately since we only care whether there are any containers defined for image types that don't support them.
This commit is contained in:
parent
e4e411a4c1
commit
ea305d9c0f
4 changed files with 23 additions and 16 deletions
|
|
@ -144,7 +144,7 @@ func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOpti
|
|||
}
|
||||
}
|
||||
|
||||
_, err := t.checkOptions(bp.Customizations, options, containers)
|
||||
_, err := t.checkOptions(&bp, options)
|
||||
if err != nil {
|
||||
logrus.Errorf("Initializing the manifest failed for %s (%s/%s): %v", t.Name(), t.arch.distro.Name(), t.arch.Name(), err)
|
||||
return nil
|
||||
|
|
@ -286,7 +286,7 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations,
|
|||
repos = mergedRepos
|
||||
|
||||
var packageSets map[string]rpmmd.PackageSet
|
||||
warnings, err := t.checkOptions(bp.Customizations, options, containers)
|
||||
warnings, err := t.checkOptions(bp, options)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
|
@ -328,10 +328,12 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations,
|
|||
|
||||
// checkOptions checks the validity and compatibility of options and customizations for the image type.
|
||||
// Returns ([]string, error) where []string, if non-nil, will hold any generated warnings (e.g. deprecation notices).
|
||||
func (t *imageType) checkOptions(customizations *blueprint.Customizations, options distro.ImageOptions, containers []container.Spec) ([]string, error) {
|
||||
func (t *imageType) checkOptions(bp *blueprint.Blueprint, options distro.ImageOptions) ([]string, error) {
|
||||
|
||||
customizations := bp.Customizations
|
||||
|
||||
// we do not support embedding containers on ostree-derived images, only on commits themselves
|
||||
if len(containers) > 0 && t.rpmOstree && (t.name != "iot-commit" && t.name != "iot-container") {
|
||||
if len(bp.Containers) > 0 && t.rpmOstree && (t.name != "iot-commit" && t.name != "iot-container") {
|
||||
return nil, fmt.Errorf("embedding containers is not supported for %s on %s", t.name, t.arch.distro.name)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations,
|
|||
}
|
||||
repos = mergedRepos
|
||||
|
||||
warnings, err := t.checkOptions(bp.Customizations, options, containers)
|
||||
warnings, err := t.checkOptions(bp, options)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
|
@ -265,7 +265,7 @@ func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOpti
|
|||
}
|
||||
}
|
||||
|
||||
_, err := t.checkOptions(bp.Customizations, options, containers)
|
||||
_, err := t.checkOptions(&bp, options)
|
||||
if err != nil {
|
||||
logrus.Errorf("Initializing the manifest failed for %s (%s/%s): %v", t.Name(), t.arch.distro.Name(), t.arch.Name(), err)
|
||||
return nil
|
||||
|
|
@ -343,7 +343,8 @@ func overridePackageNames(packages []string) []string {
|
|||
|
||||
// checkOptions checks the validity and compatibility of options and customizations for the image type.
|
||||
// Returns ([]string, error) where []string, if non-nil, will hold any generated warnings (e.g. deprecation notices).
|
||||
func (t *imageType) checkOptions(customizations *blueprint.Customizations, options distro.ImageOptions, containers []container.Spec) ([]string, error) {
|
||||
func (t *imageType) checkOptions(bp *blueprint.Blueprint, options distro.ImageOptions) ([]string, error) {
|
||||
customizations := bp.Customizations
|
||||
// holds warnings (e.g. deprecation notices)
|
||||
var warnings []string
|
||||
if t.workload != nil {
|
||||
|
|
@ -357,7 +358,7 @@ func (t *imageType) checkOptions(customizations *blueprint.Customizations, optio
|
|||
}
|
||||
}
|
||||
|
||||
if len(containers) > 0 {
|
||||
if len(bp.Containers) > 0 {
|
||||
return warnings, fmt.Errorf("embedding containers is not supported for %s on %s", t.name, t.arch.distro.name)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations,
|
|||
}
|
||||
repos = mergedRepos
|
||||
|
||||
warnings, err := t.checkOptions(bp.Customizations, options, containers)
|
||||
warnings, err := t.checkOptions(bp, options)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
|
@ -316,7 +316,7 @@ func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOpti
|
|||
}
|
||||
}
|
||||
|
||||
_, err := t.checkOptions(bp.Customizations, options, containers)
|
||||
_, err := t.checkOptions(&bp, options)
|
||||
if err != nil {
|
||||
logrus.Errorf("Initializing the manifest failed for %s (%s/%s): %v", t.Name(), t.arch.distro.Name(), t.arch.Name(), err)
|
||||
return nil
|
||||
|
|
@ -391,7 +391,8 @@ func overridePackageNames(packages []string) []string {
|
|||
|
||||
// checkOptions checks the validity and compatibility of options and customizations for the image type.
|
||||
// Returns ([]string, error) where []string, if non-nil, will hold any generated warnings (e.g. deprecation notices).
|
||||
func (t *imageType) checkOptions(customizations *blueprint.Customizations, options distro.ImageOptions, containers []container.Spec) ([]string, error) {
|
||||
func (t *imageType) checkOptions(bp *blueprint.Blueprint, options distro.ImageOptions) ([]string, error) {
|
||||
customizations := bp.Customizations
|
||||
// holds warnings (e.g. deprecation notices)
|
||||
var warnings []string
|
||||
if t.workload != nil {
|
||||
|
|
@ -405,7 +406,7 @@ func (t *imageType) checkOptions(customizations *blueprint.Customizations, optio
|
|||
}
|
||||
}
|
||||
// we do not support embedding containers on ostree-derived images, only on commits themselves
|
||||
if len(containers) > 0 && t.rpmOstree && (t.name != "edge-commit" && t.name != "edge-container") {
|
||||
if len(bp.Containers) > 0 && t.rpmOstree && (t.name != "edge-commit" && t.name != "edge-container") {
|
||||
return warnings, fmt.Errorf("embedding containers is not supported for %s on %s", t.name, t.arch.distro.name)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ func (t *imageType) Manifest(customizations *blueprint.Customizations,
|
|||
}
|
||||
|
||||
repos = mergedRepos
|
||||
warnings, err := t.checkOptions(bp.Customizations, options, containers)
|
||||
warnings, err := t.checkOptions(bp, options)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
|
@ -316,7 +316,7 @@ func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOpti
|
|||
}
|
||||
}
|
||||
|
||||
_, err := t.checkOptions(bp.Customizations, options, containers)
|
||||
_, err := t.checkOptions(&bp, options)
|
||||
if err != nil {
|
||||
logrus.Errorf("Initializing the manifest failed for %s (%s/%s): %v", t.Name(), t.arch.distro.Name(), t.arch.Name(), err)
|
||||
return nil
|
||||
|
|
@ -358,7 +358,10 @@ func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOpti
|
|||
|
||||
// checkOptions checks the validity and compatibility of options and customizations for the image type.
|
||||
// Returns ([]string, error) where []string, if non-nil, will hold any generated warnings (e.g. deprecation notices).
|
||||
func (t *imageType) checkOptions(customizations *blueprint.Customizations, options distro.ImageOptions, containers []container.Spec) ([]string, error) {
|
||||
func (t *imageType) checkOptions(bp *blueprint.Blueprint, options distro.ImageOptions) ([]string, error) {
|
||||
|
||||
customizations := bp.Customizations
|
||||
|
||||
// holds warnings (e.g. deprecation notices)
|
||||
var warnings []string
|
||||
if t.workload != nil {
|
||||
|
|
@ -373,7 +376,7 @@ func (t *imageType) checkOptions(customizations *blueprint.Customizations, optio
|
|||
}
|
||||
|
||||
// we do not support embedding containers on ostree-derived images, only on commits themselves
|
||||
if len(containers) > 0 && t.rpmOstree && (t.name != "edge-commit" && t.name != "edge-container") {
|
||||
if len(bp.Containers) > 0 && t.rpmOstree && (t.name != "edge-commit" && t.name != "edge-container") {
|
||||
return warnings, fmt.Errorf("embedding containers is not supported for %s on %s", t.name, t.arch.distro.name)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue