From 20bf90264a9720492d623322989284b938601a5d Mon Sep 17 00:00:00 2001 From: Jon Johnson Date: Mon, 6 Jan 2025 15:34:42 -0800 Subject: [PATCH] Return err if locking fails (#1464) Missed this return in a refactor. Fixes https://github.com/chainguard-dev/apko/issues/1448 Signed-off-by: Jon Johnson --- internal/cli/build.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/internal/cli/build.go b/internal/cli/build.go index 3926c796c..69380aa4f 100644 --- a/internal/cli/build.go +++ b/internal/cli/build.go @@ -189,6 +189,10 @@ func buildImageComponents(ctx context.Context, workDir string, archs []types.Arc return nil, nil, err } + if ic.Contents.BaseImage != nil && o.Lockfile == "" { + return nil, nil, fmt.Errorf("building with base image is supported only with a lockfile") + } + // cases: // - archs set: use those archs // - archs not set, bc.ImageConfiguration.Archs set: use Config archs @@ -202,7 +206,6 @@ func buildImageComponents(ctx context.Context, workDir string, archs []types.Arc ic.Archs = types.AllArchs } // save the final set we will build - archs = ic.Archs log.Infof("Building images for %d architectures: %+v", len(ic.Archs), ic.Archs) // Probe the VCS URL if it is not set and we are asked to do so. @@ -239,15 +242,8 @@ func buildImageComponents(ctx context.Context, workDir string, archs []types.Arc multiArchBDE := o.SourceDateEpoch configs, _, err := build.LockImageConfiguration(ctx, *ic, opts...) - mc, err := build.NewMultiArch(ctx, archs, opts...) if err != nil { - return nil, nil, err - } - - for _, bc := range mc.Contexts { - if bc.ImageConfiguration().Contents.BaseImage != nil && o.Lockfile == "" { - return nil, nil, fmt.Errorf("building with base image is supported only with a lockfile") - } + return nil, nil, fmt.Errorf("locking config: %w", err) } for arch, ic := range configs {