From d0ba17cfe16df37c15a6e8ec60ed2bd0614560be Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Thu, 11 May 2023 19:30:45 +0200 Subject: [PATCH] distro: move the checkOptions() call to the top of Manifest() There's no need to do anything if the options fail to validate, so do that first. --- internal/distro/fedora/imagetype.go | 10 +++++----- internal/distro/rhel7/imagetype.go | 10 +++++----- internal/distro/rhel8/imagetype.go | 10 +++++----- internal/distro/rhel9/imagetype.go | 10 +++++----- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/internal/distro/fedora/imagetype.go b/internal/distro/fedora/imagetype.go index 9a3d3db25..0d70e04d8 100644 --- a/internal/distro/fedora/imagetype.go +++ b/internal/distro/fedora/imagetype.go @@ -265,6 +265,11 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint, containers []container.Spec, seed int64) (*manifest.Manifest, []string, error) { + warnings, err := t.checkOptions(bp, options) + if err != nil { + return nil, nil, err + } + // merge package sets that appear in the image type with the package sets // of the same name from the distro and arch staticPackageSets := make(map[string]rpmmd.PackageSet) @@ -289,11 +294,6 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint, } } - warnings, err := t.checkOptions(bp, options) - if err != nil { - return nil, nil, err - } - w := t.workload if w == nil { cw := &workload.Custom{ diff --git a/internal/distro/rhel7/imagetype.go b/internal/distro/rhel7/imagetype.go index 090b057f8..ad750a60a 100644 --- a/internal/distro/rhel7/imagetype.go +++ b/internal/distro/rhel7/imagetype.go @@ -156,6 +156,11 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint, containers []container.Spec, seed int64) (*manifest.Manifest, []string, error) { + warnings, err := t.checkOptions(bp, options) + if err != nil { + return nil, nil, err + } + // merge package sets that appear in the image type with the package sets // of the same name from the distro and arch staticPackageSets := make(map[string]rpmmd.PackageSet) @@ -180,11 +185,6 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint, } } - warnings, err := t.checkOptions(bp, options) - if err != nil { - return nil, nil, err - } - w := t.workload if w == nil { cw := &workload.Custom{ diff --git a/internal/distro/rhel8/imagetype.go b/internal/distro/rhel8/imagetype.go index bc942d2f1..df89993f2 100644 --- a/internal/distro/rhel8/imagetype.go +++ b/internal/distro/rhel8/imagetype.go @@ -190,6 +190,11 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint, containers []container.Spec, seed int64) (*manifest.Manifest, []string, error) { + warnings, err := t.checkOptions(bp, options) + if err != nil { + return nil, nil, err + } + // merge package sets that appear in the image type with the package sets // of the same name from the distro and arch staticPackageSets := make(map[string]rpmmd.PackageSet) @@ -214,11 +219,6 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint, } } - warnings, err := t.checkOptions(bp, options) - if err != nil { - return nil, nil, err - } - w := t.workload if w == nil { cw := &workload.Custom{ diff --git a/internal/distro/rhel9/imagetype.go b/internal/distro/rhel9/imagetype.go index 160225b6a..0b2ea9028 100644 --- a/internal/distro/rhel9/imagetype.go +++ b/internal/distro/rhel9/imagetype.go @@ -193,6 +193,11 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint, containers []container.Spec, seed int64) (*manifest.Manifest, []string, error) { + warnings, err := t.checkOptions(bp, options) + if err != nil { + return nil, nil, err + } + // merge package sets that appear in the image type with the package sets // of the same name from the distro and arch staticPackageSets := make(map[string]rpmmd.PackageSet) @@ -217,11 +222,6 @@ func (t *imageType) Manifest(bp *blueprint.Blueprint, } } - warnings, err := t.checkOptions(bp, options) - if err != nil { - return nil, nil, err - } - w := t.workload if w == nil { cw := &workload.Custom{